vm: raise CalledProcessError instead of QubesVMError on failed service call
follow core-admin change.
This commit is contained in:
parent
ba2057a2c6
commit
5ac7632dd0
@ -21,6 +21,9 @@
|
|||||||
'''Qubes VM objects.'''
|
'''Qubes VM objects.'''
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
|
||||||
import qubesadmin.base
|
import qubesadmin.base
|
||||||
import qubesadmin.exc
|
import qubesadmin.exc
|
||||||
import qubesadmin.storage
|
import qubesadmin.storage
|
||||||
@ -273,10 +276,10 @@ class QubesVM(qubesadmin.base.PropertyHolder):
|
|||||||
stdouterr = p.communicate(input=input)
|
stdouterr = p.communicate(input=input)
|
||||||
|
|
||||||
if p.returncode:
|
if p.returncode:
|
||||||
raise qubesadmin.exc.QubesVMError(
|
exc = subprocess.CalledProcessError(p.returncode, service)
|
||||||
'VM {}: service {!r} failed with retcode {!r}; '
|
# Python < 3.5 didn't have those
|
||||||
'stdout={!r} stderr={!r}'.format(self,
|
exc.output, exc.stderr = stdouterr
|
||||||
service, p.returncode, *stdouterr))
|
raise exc
|
||||||
|
|
||||||
return stdouterr
|
return stdouterr
|
||||||
|
|
||||||
@ -293,8 +296,13 @@ class QubesVM(qubesadmin.base.PropertyHolder):
|
|||||||
'''Run a shell command inside the domain using qubes.VMShell qrexec.
|
'''Run a shell command inside the domain using qubes.VMShell qrexec.
|
||||||
|
|
||||||
''' # pylint: disable=redefined-builtin
|
''' # pylint: disable=redefined-builtin
|
||||||
return self.run_service_for_stdio('qubes.VMShell',
|
try:
|
||||||
input=self.prepare_input_for_vmshell(command, input), **kwargs)
|
return self.run_service_for_stdio('qubes.VMShell',
|
||||||
|
input=self.prepare_input_for_vmshell(command, input), **kwargs)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
e.cmd = command
|
||||||
|
raise e
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=abstract-method
|
# pylint: disable=abstract-method
|
||||||
class AdminVM(QubesVM):
|
class AdminVM(QubesVM):
|
||||||
|
Loading…
Reference in New Issue
Block a user