From f8a462dbe5d240e504fc74d7fe2d084c5d536b2b Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Mon, 22 Jan 2024 19:29:33 -0500 Subject: [PATCH 1/2] cli: be defensive in device error message --- lib/solaar/cli/show.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solaar/cli/show.py b/lib/solaar/cli/show.py index b7fcd0093d..9d4e1fd0c5 100644 --- a/lib/solaar/cli/show.py +++ b/lib/solaar/cli/show.py @@ -86,7 +86,7 @@ def _print_device(dev, num=None): try: dev.ping() except _base.NoSuchDevice: - print(' %d: Device not found' % num or dev.number) + print(' %s: Device not found' % num or dev.number) return print(' %d: %s' % (num or dev.number, dev.name)) From 0db84f5aa4459907f03a11ce87bb3e14dce96ba3 Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Tue, 23 Jan 2024 07:07:30 -0500 Subject: [PATCH 2/2] rules: write empty file if there are no rules to save --- lib/logitech_receiver/diversion.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/logitech_receiver/diversion.py b/lib/logitech_receiver/diversion.py index 4dee89f3dd..8afaf97fd0 100644 --- a/lib/logitech_receiver/diversion.py +++ b/lib/logitech_receiver/diversion.py @@ -1545,7 +1545,8 @@ def convert(elem): _log.info('saving %d rule(s) to %s', len(rules_to_save), file_name) try: with open(file_name, 'w') as f: - f.write('%YAML 1.3\n') # Write version manually + if rules_to_save: + f.write('%YAML 1.3\n') # Write version manually _yaml_dump_all(convert([r['Rule'] for r in rules_to_save]), f, **dump_settings) except Exception as e: _log.error('failed to save to %s\n%s', file_name, e)