Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/tools/qvm-appmenus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ OPTIONS
--set-default-whitelist PATH
Set the default list of applications to be included in the menus of VMs based on this template. Should only be used for TemplateVMs .The PATH can be either a path to file containing a list of .desktop files, or a single hyphen ('-') to read from standard input.

--get-available [EXPERIMENTAL] [REQUIRES --i-understand-format-is-unstable]
List all available applications for the VM. The current format is UNSTABLE.
--get-available
List all available applications for the VM.
The applications are listed as hyphen-separated pairs consisting of file name and application name.

--file-field FIELDNAME
.desktop file field to append to output for --get-available; can be used multiple times for multiple fields. This option changes output format to pipe-("|") separated. The current format is UNSTABLE.
.desktop file field to append to output for --get-available; can be used multiple times for multiple fields. This option changes output format to pipe-("|") separated.

AUTHORS
=======
Expand Down
9 changes: 4 additions & 5 deletions qubesappmenus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ def appmenus_update(self, vm, force=False):
parser.add_argument(
'--i-understand-format-is-unstable', dest='fool',
action='store_true',
help='required pledge for --get-available')
help='deprecated no-op for backward compatibility')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use "deprecated" option: https://docs.python.org/3/library/argparse.html#deprecated. This is only available in python3.13 and therefore cannot be backported to R4.2.

parser.add_argument(
'--file-field', action='append', dest='fields',
help='File field to append to output for --get-available; can be used'
Expand Down Expand Up @@ -795,6 +795,9 @@ def retrieve_list(path):
def main(args=None, app=None):
"""main function for qvm-appmenus tool"""
args = parser.parse_args(args=args, app=app)
if args.fool:
print('Warning: --i-understand-format-is-unstable is deprecated '
'and has no effect.', file=sys.stderr)
if not args.all_domains and not args.domains:
parser.error("one of the arguments --all VMNAME is required")
appmenus = Appmenus()
Expand Down Expand Up @@ -852,10 +855,6 @@ def main(args=None, app=None):
if args.update:
appmenus.appmenus_update(vm, force=args.force)
if args.get_available:
if not args.fool:
parser.error(
'this requires --i-understand-format-is-unstable '
'and a sacrifice of one cute kitten')
if not args.fields:
sys.stdout.write(''.join('{} - {}\n'.format(*available)
for available in
Expand Down
17 changes: 17 additions & 0 deletions qubesappmenus/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,23 @@ def test_131_set_get_default_whitelist(self, mock_subprocess):
self.ext.set_default_whitelist(tpl, whitelist)
self.assertEqual(whitelist, self.ext.get_default_whitelist(tpl))

@unittest.mock.patch('qubesappmenus.Appmenus')
def test_132_get_available_does_not_require_unstable_flag(
self, appmenus_cls):
vm = TestVM('test-inst-vm', klass='AppVM',
label=self.app.labels[1])
self.app.domains[vm.name] = vm
appmenus_cls.return_value.get_available.return_value = [
('xterm.desktop', 'XTerm')]

with unittest.mock.patch('sys.stdout', new_callable=io.StringIO) \
as stdout:
qubesappmenus.main(
['--force-root', '--get-available', vm.name], app=self.app)

appmenus_cls.return_value.get_available.assert_called_once_with(vm)
self.assertEqual(stdout.getvalue(), 'xterm.desktop - XTerm\n')


def list_tests():
return (TC_00_Appmenus,)
Expand Down