diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2009-01-03 18:02:58 -0700 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2009-01-03 18:02:58 -0700 |
commit | bb6e9cfe9ff25f3a018b23785f71302911eab435 (patch) | |
tree | 97ab1702d7dae6d2429788fbf9ada3f40c9d7926 | |
parent | 6b6e6b1cab7a633faf16631a565ecb6988dadb48 (diff) | |
download | freeipa-bb6e9cfe9ff25f3a018b23785f71302911eab435.tar.gz freeipa-bb6e9cfe9ff25f3a018b23785f71302911eab435.tar.xz freeipa-bb6e9cfe9ff25f3a018b23785f71302911eab435.zip |
Plugin.call() now uses errors2 version of SubprocessError
-rw-r--r-- | ipalib/errors2.py | 14 | ||||
-rw-r--r-- | ipalib/plugable.py | 6 | ||||
-rw-r--r-- | tests/test_ipalib/test_plugable.py | 3 |
3 files changed, 13 insertions, 10 deletions
diff --git a/ipalib/errors2.py b/ipalib/errors2.py index 7793a9146..7fd4b9c95 100644 --- a/ipalib/errors2.py +++ b/ipalib/errors2.py @@ -67,15 +67,19 @@ class SubprocessError(PrivateError): For example: + >>> raise SubprocessError(returncode=2, argv=('ls', '-lh', '/no-foo/')) + Traceback (most recent call last): + ... + SubprocessError: return code 2 from ('ls', '-lh', '/no-foo/') + + The exit code of the sub-process is available via the ``returncode`` + instance attribute. For example: + >>> e = SubprocessError(returncode=1, argv=('/bin/false',)) >>> e.returncode 1 - >>> e.argv + >>> e.argv # argv is also available ('/bin/false',) - >>> e.message - "return code 1 from ('/bin/false',)" - >>> str(e) - "return code 1 from ('/bin/false',)" """ format = 'return code %(returncode)d from %(argv)r' diff --git a/ipalib/plugable.py b/ipalib/plugable.py index 094634d33..f7baa2a1f 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -291,9 +291,9 @@ class Plugin(ReadOnly): """ argv = (executable,) + args self.debug('Calling %r', argv) - returncode = subprocess.call(argv) - if returncode != 0: - raise errors.SubprocessError(returncode, argv) + code = subprocess.call(argv) + if code != 0: + raise errors2.SubprocessError(returncode=code, argv=argv) def __repr__(self): """ diff --git a/tests/test_ipalib/test_plugable.py b/tests/test_ipalib/test_plugable.py index dbf0cc3ff..c6c84fa16 100644 --- a/tests/test_ipalib/test_plugable.py +++ b/tests/test_ipalib/test_plugable.py @@ -372,8 +372,7 @@ class test_Plugin(ClassChecker): """ o = self.cls() o.call('/bin/true') is None - e = raises(errors.SubprocessError, o.call, '/bin/false') - assert str(e) == 'return code %d from %r' % (1, ('/bin/false',)) + e = raises(errors2.SubprocessError, o.call, '/bin/false') assert e.returncode == 1 assert e.argv == ('/bin/false',) |