mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Plugin.call() now uses errors2 version of SubprocessError
This commit is contained in:
@@ -67,15 +67,19 @@ class SubprocessError(PrivateError):
|
|||||||
|
|
||||||
For example:
|
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 = SubprocessError(returncode=1, argv=('/bin/false',))
|
||||||
>>> e.returncode
|
>>> e.returncode
|
||||||
1
|
1
|
||||||
>>> e.argv
|
>>> e.argv # argv is also available
|
||||||
('/bin/false',)
|
('/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'
|
format = 'return code %(returncode)d from %(argv)r'
|
||||||
|
|||||||
@@ -291,9 +291,9 @@ class Plugin(ReadOnly):
|
|||||||
"""
|
"""
|
||||||
argv = (executable,) + args
|
argv = (executable,) + args
|
||||||
self.debug('Calling %r', argv)
|
self.debug('Calling %r', argv)
|
||||||
returncode = subprocess.call(argv)
|
code = subprocess.call(argv)
|
||||||
if returncode != 0:
|
if code != 0:
|
||||||
raise errors.SubprocessError(returncode, argv)
|
raise errors2.SubprocessError(returncode=code, argv=argv)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -372,8 +372,7 @@ class test_Plugin(ClassChecker):
|
|||||||
"""
|
"""
|
||||||
o = self.cls()
|
o = self.cls()
|
||||||
o.call('/bin/true') is None
|
o.call('/bin/true') is None
|
||||||
e = raises(errors.SubprocessError, o.call, '/bin/false')
|
e = raises(errors2.SubprocessError, o.call, '/bin/false')
|
||||||
assert str(e) == 'return code %d from %r' % (1, ('/bin/false',))
|
|
||||||
assert e.returncode == 1
|
assert e.returncode == 1
|
||||||
assert e.argv == ('/bin/false',)
|
assert e.argv == ('/bin/false',)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user