Skip to content

Commit

Permalink
spice updater (python module) - Improve error reporting.
Browse files Browse the repository at this point in the history
This is to give mintupdate something to catch when updates fail.
  • Loading branch information
mtwebster committed Sep 23, 2024
1 parent f6f05cb commit 93b99a8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
26 changes: 17 additions & 9 deletions python3/cinnamon/harvester.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/python3

import os
import sys
import subprocess
import json
import locale
Expand Down Expand Up @@ -321,7 +322,7 @@ def _load_metadata(self):
self.meta_map[uuid] = metadata
except Exception as detail:
debug(detail)
debug(f"Skipping {uuid}: there was a problem trying to read metadata.json")
print(f"Skipping {uuid}: there was a problem trying to read metadata.json", file=sys.stderr)
except FileNotFoundError:
# debug("%s does not exist! Creating it now." % directory)
try:
Expand Down Expand Up @@ -359,9 +360,13 @@ def _generate_update_list(self):
self.updates = []

for uuid in self.index_cache:
if uuid in self.meta_map and self._spice_has_update(uuid):
update = SpiceUpdate(self.spice_type, uuid, self.index_cache[uuid], self.meta_map[uuid])
self.updates.append(update)
try:
if uuid in self.meta_map and self._spice_has_update(uuid):
update = SpiceUpdate(self.spice_type, uuid, self.index_cache[uuid], self.meta_map[uuid])
self.updates.append(update)
except Exception as e:
debug(f"Error checking updates for {uuid}: {e}", file=sys.stderr)
raise

return self.updates

Expand All @@ -374,11 +379,13 @@ def _spice_has_update(self, uuid):
def _install_by_uuid(self, uuid):
action = "upgrade" if uuid in self.meta_map else "install"

error_message = None
uuid = uuid + "poo"
try:
item = self.index_cache[uuid]
except KeyError:
debug(f"Can't install {uuid} - it doesn't seem to exist on the server")
return
print(f"Can't install {uuid} - it doesn't seem to exist on the server", file=sys.stderr)
raise

paths = SpicePathSet(item, spice_type=self.spice_type)

Expand All @@ -389,8 +396,8 @@ def _install_by_uuid(self, uuid):
params={"time": get_current_timestamp()})
r.raise_for_status()
except Exception as e:
print(f"Could not download zip for {uuid}: {e}")
return
debug(f"Could not download zip for {uuid}: {e}", file=sys.stderr)
raise

try:
tmp_name = None
Expand All @@ -408,7 +415,8 @@ def _install_by_uuid(self, uuid):

self._load_metadata()
except Exception as e:
debug(f"couldn't install: {e}")
debug(f"couldn't install: {e}", file=sys.stderr)
raise

def _install_from_folder(self, folder, base_folder, uuid, from_spices=False):
contents = os.listdir(folder)
Expand Down
1 change: 0 additions & 1 deletion python3/cinnamon/updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
SPICE_TYPES = [SPICE_TYPE_APPLET, SPICE_TYPE_DESKLET, SPICE_TYPE_THEME,
SPICE_TYPE_EXTENSION, SPICE_TYPE_ACTION]


class UpdateManager:
def __init__(self):
self.harvesters = {}
Expand Down

0 comments on commit 93b99a8

Please sign in to comment.