Don't use asserts for error handling
This commit is contained in:
parent
8f9989a61d
commit
f3305b8288
@ -45,14 +45,27 @@ def _run_qrexec_repo(service, arg=''):
|
|||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE
|
stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
assert not p.stderr
|
if p.stderr:
|
||||||
assert p.returncode == 0
|
raise RuntimeError('qrexec call stderr was not empty', stderr=p.stderr)
|
||||||
|
if p.returncode != 0:
|
||||||
|
raise RuntimeError('qrexec call exited with non-zero return code',
|
||||||
|
returncode=p.returncode)
|
||||||
return p.stdout.decode('utf-8')
|
return p.stdout.decode('utf-8')
|
||||||
|
|
||||||
def _manage_repos(repolist, action):
|
def _manage_repos(repolist, action):
|
||||||
for i in repolist:
|
for i in repolist:
|
||||||
result = _run_qrexec_repo('qubes.repos.' + action, i)
|
try:
|
||||||
assert result == 'ok\n'
|
result = _run_qrexec_repo('qubes.repos.' + action, i)
|
||||||
|
if result != 'ok\n':
|
||||||
|
raise RuntimeError(
|
||||||
|
'qrexec call stdout did not contain "ok" as expected',
|
||||||
|
result=result)
|
||||||
|
except RuntimeError as ex:
|
||||||
|
QtGui.QMessageBox.warning(
|
||||||
|
None,
|
||||||
|
self.tr("ERROR!"),
|
||||||
|
self.tr("Error managing repository settings: {e}".format(
|
||||||
|
e=str(ex))))
|
||||||
|
|
||||||
def _handle_dom0_updates_combobox(idx):
|
def _handle_dom0_updates_combobox(idx):
|
||||||
idx += 1
|
idx += 1
|
||||||
|
Loading…
Reference in New Issue
Block a user