From 93b99a80c3f02e813a5ca2b4092263afd46dbc43 Mon Sep 17 00:00:00 2001 From: Michael Webster Date: Mon, 23 Sep 2024 10:55:56 -0400 Subject: [PATCH] spice updater (python module) - Improve error reporting. This is to give mintupdate something to catch when updates fail. --- python3/cinnamon/harvester.py | 26 +++++++++++++++++--------- python3/cinnamon/updates.py | 1 - 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/python3/cinnamon/harvester.py b/python3/cinnamon/harvester.py index 6d8296cdae..4e94b8a278 100644 --- a/python3/cinnamon/harvester.py +++ b/python3/cinnamon/harvester.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 import os +import sys import subprocess import json import locale @@ -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: @@ -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 @@ -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) @@ -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 @@ -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) diff --git a/python3/cinnamon/updates.py b/python3/cinnamon/updates.py index ef35cd7e0c..29d2f3ef88 100644 --- a/python3/cinnamon/updates.py +++ b/python3/cinnamon/updates.py @@ -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 = {}