summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2011-10-12 23:19:12 +0200
committerJelmer Vernooij <jelmer@samba.org>2011-10-13 00:23:39 +0200
commit63c9186e92ae2c7f1f7383352cc95d38b2efc45a (patch)
tree0f20a60286a1d7c4198ebe79231dc1218c0fe82b /source4
parentfba4b7a5b9cba2c5319793fcf8bda9767836419e (diff)
downloadsamba-63c9186e92ae2c7f1f7383352cc95d38b2efc45a.tar.gz
samba-63c9186e92ae2c7f1f7383352cc95d38b2efc45a.tar.bz2
samba-63c9186e92ae2c7f1f7383352cc95d38b2efc45a.zip
netcmd: Add errf stream to command instances.
Diffstat (limited to 'source4')
-rwxr-xr-xsource4/scripting/bin/samba-tool3
-rw-r--r--source4/scripting/python/samba/netcmd/__init__.py14
2 files changed, 9 insertions, 8 deletions
diff --git a/source4/scripting/bin/samba-tool b/source4/scripting/bin/samba-tool
index f05fa3c023..9f06e8daae 100755
--- a/source4/scripting/bin/samba-tool
+++ b/source4/scripting/bin/samba-tool
@@ -45,7 +45,7 @@ from samba.netcmd.vampire import cmd_vampire
class cmd_sambatool(SuperCommand):
"""samba-tool SuperCommand"""
-
+
subcommands = {}
subcommands["dbcheck"] = cmd_dbcheck()
subcommands["delegation"] = cmd_delegation()
@@ -81,4 +81,5 @@ if __name__ == '__main__':
retval = -1
except Exception, e:
cmd.show_command_error(e)
+ retval = 1
sys.exit(retval)
diff --git a/source4/scripting/python/samba/netcmd/__init__.py b/source4/scripting/python/samba/netcmd/__init__.py
index 58d566071f..3acd1022bf 100644
--- a/source4/scripting/python/samba/netcmd/__init__.py
+++ b/source4/scripting/python/samba/netcmd/__init__.py
@@ -50,6 +50,7 @@ class Command(object):
"versionopts": options.VersionOptions,
}
outf = sys.stdout
+ errf = sys.stderr
def usage(self, *args):
parser, _ = self._create_parser()
@@ -70,24 +71,23 @@ class Command(object):
if isinstance(inner_exception, LdbError):
(ldb_ecode, ldb_emsg) = inner_exception
- print >>sys.stderr, "ERROR(ldb): %s - %s" % (message, ldb_emsg)
+ self.errf.write("ERROR(ldb): %s - %s\n" % (message, ldb_emsg))
elif isinstance(inner_exception, AssertionError):
- print >>sys.stderr, "ERROR(assert): %s" % message
+ self.errf.write("ERROR(assert): %s\n" % message)
force_traceback = True
elif isinstance(inner_exception, RuntimeError):
- print >>sys.stderr, "ERROR(runtime): %s - %s" % (message, evalue)
+ self.errf.write("ERROR(runtime): %s - %s\n" % (message, evalue))
elif type(inner_exception) is Exception:
- print >>sys.stderr, "ERROR(exception): %s - %s" % (message, evalue)
+ self.errf.write("ERROR(exception): %s - %s\n" % (message, evalue))
force_traceback = True
elif inner_exception is None:
- print >>sys.stderr, "ERROR: %s" % (message)
+ self.errf.write("ERROR: %s\n" % (message))
else:
- print >>sys.stderr, "ERROR(%s): %s - %s" % (str(etype), message, evalue)
+ self.errf.write("ERROR(%s): %s - %s\n" % (str(etype), message, evalue))
force_traceback = True
if force_traceback or samba.get_debug_level() >= 3:
traceback.print_tb(etraceback)
- sys.exit(1)
def _create_parser(self):
parser = optparse.OptionParser(usage=self.synopsis,