[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7025 - trunk/gnue-common/src/apps
From: |
btami |
Subject: |
[gnue] r7025 - trunk/gnue-common/src/apps |
Date: |
Tue, 15 Feb 2005 03:04:45 -0600 (CST) |
Author: btami
Date: 2005-02-15 03:04:45 -0600 (Tue, 15 Feb 2005)
New Revision: 7025
Modified:
trunk/gnue-common/src/apps/GBaseApp.py
Log:
added --silent option to GBaseApp
Modified: trunk/gnue-common/src/apps/GBaseApp.py
===================================================================
--- trunk/gnue-common/src/apps/GBaseApp.py 2005-02-15 08:45:55 UTC (rev
7024)
+++ trunk/gnue-common/src/apps/GBaseApp.py 2005-02-15 09:04:45 UTC (rev
7025)
@@ -105,6 +105,9 @@
help = _('Sends all debugging messages to a specified file '
'(e.g., "--debug-file trace.log" sends all output to '
'"trace.log")')),
+
+ CommandOption ('silent', category = "base",
+ help = _('Displays no output at all.')),
CommandOption ('help', category = "base", action = self.printHelp,
help = _('Displays this help screen.')),
@@ -254,6 +257,26 @@
task()
self._run = self.run
+
+ # Are we silent?
+ if self.OPTIONS['silent']:
+ # our file objects (/dev/null and nul) has no encoding, unlike stdout...
+ import __builtin__
+ __builtin__.__dict__['u_'] = __builtin__.__dict__['_']
+ if os.name == 'posix':
+ sout = open('/dev/null','w')
+ serr = open('/dev/null','w')
+ elif os.name == 'nt':
+ sout = open('nul', 'w')
+ serr = open('nul', 'w')
+
+ try:
+ sys.stdout.close()
+ sys.stdout = sout
+ sys.stderr.close()
+ sys.stderr = serr
+ except:
+ pass
# Should we profile?
if self.OPTIONS['profile']:
@@ -597,4 +620,3 @@
o(u_("For help, type: %s --help") % self.COMMAND))
else:
sys.stderr.write ("%s\n" % o(detail))
-
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7025 - trunk/gnue-common/src/apps,
btami <=