From 23d3880725da4cb92062b5945b7c93202f4ea504 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Nov 2011 16:39:47 +0100 Subject: samba.netcmd: Pass in outf/errf. Autobuild-User: Jelmer Vernooij Autobuild-Date: Wed Nov 2 20:09:40 CET 2011 on sn-devel-104 --- source4/scripting/python/samba/netcmd/__init__.py | 7 ++++--- source4/scripting/python/samba/tests/netcmd.py | 4 +--- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/python/samba/netcmd/__init__.py b/source4/scripting/python/samba/netcmd/__init__.py index bf0845726c..58353a07f4 100644 --- a/source4/scripting/python/samba/netcmd/__init__.py +++ b/source4/scripting/python/samba/netcmd/__init__.py @@ -30,7 +30,6 @@ class Option(optparse.Option): pass - class Command(object): """A samba-tool command.""" @@ -63,8 +62,10 @@ class Command(object): "credopts": options.CredentialsOptions, "versionopts": options.VersionOptions, } - outf = sys.stdout - errf = sys.stderr + + def __init__(self, outf=sys.stdout, errf=sys.stderr): + self.outf = outf + self.errf = errf def usage(self, prog, *args): parser, _ = self._create_parser(prog) diff --git a/source4/scripting/python/samba/tests/netcmd.py b/source4/scripting/python/samba/tests/netcmd.py index d7c6482a46..66646ff00e 100644 --- a/source4/scripting/python/samba/tests/netcmd.py +++ b/source4/scripting/python/samba/tests/netcmd.py @@ -28,9 +28,7 @@ import samba.tests class NetCmdTestCase(samba.tests.TestCase): def run_netcmd(self, cmd_klass, args, retcode=0): - cmd = cmd_klass() - cmd.outf = StringIO() - cmd.errf = StringIO() + cmd = cmd_klass(outf=StringIO(), errf=StringIO()) try: retval = cmd._run(cmd_klass.__name__, *args) except Exception, e: -- cgit