Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test-spice] Add applet reload after successful copy #6616

Merged
merged 2 commits into from
Nov 24, 2024
Merged
Changes from 1 commit
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
27 changes: 24 additions & 3 deletions test-spice
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ def validate_spice(uuid):
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if out.returncode != 0:
print(out.stdout.decode('ascii') + '\nValidation failed!')
return False
return True
except FileNotFoundError:
print('Errors encountered! Please try running again from the top-level'
' directory of the repository.')

return False

def copy_xlet(uuid):
"""
Expand All @@ -42,10 +44,29 @@ def copy_xlet(uuid):
data['uuid'] = f"{DEV_PREFIX}{data['uuid']}"
data['name'] = f"({DEV_PREFIX.replace('-', '')}) {data['name']}"
json.dump(data, metadata, indent=4)
reload_xlet(f'{DEV_PREFIX}{uuid}')
except (FileNotFoundError, KeyError):
# metadata.json file not found or missing valid keys
pass

def reload_xlet(uuid):
"""
Reloads the Spice via dbus-send.
"""
args = ['dbus-send',
'--dest=org.Cinnamon',
'--print-reply',
'--type=method_call',
'/org/Cinnamon',
'org.Cinnamon.ReloadXlet',
f'string:{uuid}',
'string:APPLET'
]
timfeierabend marked this conversation as resolved.
Show resolved Hide resolved
out = subprocess.run(args, check=False,
stdout=subprocess.DEVNULL, stderr=subprocess.PIPE
)
if out.returncode != 0:
print(out.stderr.decode('ascii') + '\nReload error!')

def main():
"""
Expand All @@ -71,8 +92,8 @@ def main():
elif args.skip and args.uuid:
copy_xlet(args.uuid.rstrip('/'))
elif args.uuid and not args.remove:
validate_spice(args.uuid.rstrip('/'))
copy_xlet(args.uuid.rstrip('/'))
if validate_spice(args.uuid.rstrip('/')):
copy_xlet(args.uuid.rstrip('/'))
else:
parser.print_help()
sys.exit(2)
Expand Down