Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/268'
Browse files Browse the repository at this point in the history
* origin/pr/268:
  qvm-prefs: Don't falsely report 'no such property'
  • Loading branch information
marmarek committed Dec 16, 2023
2 parents 6b5a7bd + 25c3254 commit 80695d1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions qubesadmin/tests/tools/qubes_prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_002_set_property(self):
def test_003_invalid_property(self):
self.app.expected_calls[
('dom0', 'admin.property.Get', 'no_such_property', None)] = \
b'2\x00AttributeError\x00\x00no_such_property\x00'
b'2\x00QubesNoSuchPropertyError\x00\x00no_such_property\x00'
with self.assertRaises(SystemExit):
with qubesadmin.tests.tools.StderrBuffer() as stderr:
qubesadmin.tools.qubes_prefs.main([
Expand All @@ -67,7 +67,7 @@ def test_003_invalid_property(self):
def test_004_set_invalid_property(self):
self.app.expected_calls[
('dom0', 'admin.property.Set', 'no_such_property', b'value')]\
= b'2\x00AttributeError\x00\x00no_such_property\x00'
= b'2\x00QubesNoSuchPropertyError\x00\x00no_such_property\x00'
with self.assertRaises(SystemExit):
with qubesadmin.tests.tools.StderrBuffer() as stderr:
qubesadmin.tools.qubes_prefs.main([
Expand Down
4 changes: 2 additions & 2 deletions qubesadmin/tests/tools/qvm_prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_003_invalid_property(self):
b'0\x00dom0 class=AdminVM state=Running\n'
self.app.expected_calls[
('dom0', 'admin.vm.property.Get', 'no_such_property', None)] = \
b'2\x00AttributeError\x00\x00no_such_property\x00'
b'2\x00QubesNoSuchPropertyError\x00\x00no_such_property\x00'
with self.assertRaises(SystemExit):
with qubesadmin.tests.tools.StderrBuffer() as stderr:
qubesadmin.tools.qvm_prefs.main([
Expand All @@ -92,7 +92,7 @@ def test_004_set_invalid_property(self):
b'0\x00dom0 class=AdminVM state=Running\n'
self.app.expected_calls[
('dom0', 'admin.vm.property.Set', 'no_such_property', b'value')] = \
b'2\x00AttributeError\x00\x00no_such_property\x00'
b'2\x00QubesNoSuchPropertyError\x00\x00no_such_property\x00'
with self.assertRaises(SystemExit):
with qubesadmin.tests.tools.StderrBuffer() as stderr:
qubesadmin.tools.qvm_prefs.main([
Expand Down
6 changes: 3 additions & 3 deletions qubesadmin/tools/qvm_prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def process_actions(parser, args, target):
args.value = ''
try:
setattr(target, args.property, args.value)
except AttributeError:
except qubesadmin.exc.QubesNoSuchPropertyError:
parser.error('no such property: {!r}'.format(args.property))
except qubesadmin.exc.QubesException as e:
parser.error_runtime(e)
Expand All @@ -134,7 +134,7 @@ def process_actions(parser, args, target):
if args.delete:
try:
delattr(target, args.property)
except AttributeError:
except qubesadmin.exc.QubesNoSuchPropertyError:
parser.error('no such property: {!r}'.format(args.property))
except qubesadmin.exc.QubesException as e:
parser.error_runtime(e)
Expand All @@ -144,7 +144,7 @@ def process_actions(parser, args, target):
value = getattr(target, args.property)
if value is not None:
print(str(value))
except AttributeError:
except qubesadmin.exc.QubesNoSuchPropertyError:
parser.error('no such property: {!r}'.format(args.property))
except qubesadmin.exc.QubesException as e:
parser.error_runtime(e)
Expand Down

0 comments on commit 80695d1

Please sign in to comment.