summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/live/ogOperations.py16
-rw-r--r--src/utils/tiptorrent.py11
2 files changed, 22 insertions, 5 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py
index 870ca12..61da45b 100644
--- a/src/live/ogOperations.py
+++ b/src/live/ogOperations.py
@@ -45,6 +45,7 @@ class OgLiveOperations:
proc = subprocess.call(["pkill", "-9", "browser"])
proc = subprocess.Popen(["browser", "-qws", url])
except:
+ logging.error('Cannot restart browser')
raise ValueError('Error: cannot restart browser')
def _refresh_payload_disk(self, cxt, part_setup, num_disk):
@@ -137,6 +138,7 @@ class OgLiveOperations:
def _restore_image_unicast(self, repo, name, devpath, cache=False):
if ogChangeRepo(repo).returncode != 0:
+ self._restartBrowser(self._url)
logging.error('ogChangeRepo could not change repository to %s', repo)
raise ValueError(f'Error: Cannot change repository to {repo}')
logging.debug(f'restore_image_unicast: name => {name}')
@@ -151,9 +153,13 @@ class OgLiveOperations:
def _restore_image_tiptorrent(self, repo, name, devpath):
image_path = f'/opt/opengnsys/cache/opt/opengnsys/images/{name}.img'
- if (not os.path.exists(image_path) or
- not tip_check_csum(repo, name)):
- tip_client_get(repo, name)
+ try:
+ if (not os.path.exists(image_path) or
+ not tip_check_csum(repo, name)):
+ tip_client_get(repo, name)
+ except:
+ self._restartBrowser(self._url)
+ raise ValueError('Error before restoring image')
self._restore_image(image_path, devpath)
def _restore_image(self, image_path, devpath):
@@ -361,6 +367,7 @@ class OgLiveOperations:
self._restartBrowser(self._url_log)
if ogChangeRepo(repo).returncode != 0:
+ self._restartBrowser(self._url)
logging.error('ogChangeRepo could not change repository to %s', repo)
raise ValueError(f'Error: Cannot change repository to {repo}')
@@ -371,6 +378,7 @@ class OgLiveOperations:
executable=OG_SHELL)
(output, error) = ogRest.proc.communicate()
except:
+ self._restartBrowser(self._url)
logging.error('Exception when running software inventory subprocess')
raise ValueError('Error: Incorrect command value')
@@ -387,6 +395,7 @@ class OgLiveOperations:
pa = cxt.partitions[i]
if pa is None:
+ self._restartBrowser(self._url)
logging.error('Target partition not found')
raise ValueError('Target partition number not found')
@@ -425,6 +434,7 @@ class OgLiveOperations:
image_info = ogGetImageInfo(image_path)
except:
+ self._restartBrowser(self._url)
logging.error('Exception when running "image create" subprocess')
raise ValueError('Error: Incorrect command value')
diff --git a/src/utils/tiptorrent.py b/src/utils/tiptorrent.py
index 25a3ab8..e749d96 100644
--- a/src/utils/tiptorrent.py
+++ b/src/utils/tiptorrent.py
@@ -21,8 +21,15 @@ def tip_fetch_csum(tip_addr, image_name):
"""
"""
url = f'http://{tip_addr}:9999/{image_name}.img.full.sum'
- with urllib.request.urlopen(f'{url}') as resp:
- r = resp.readline().rstrip().decode('utf-8')
+ try:
+ with urllib.request.urlopen(f'{url}') as resp:
+ r = resp.readline().rstrip().decode('utf-8')
+ except urllib.error.URLError as e:
+ logging.warning('URL error when fetching checksum: {e.reason}')
+ raise e
+ except urllib.error.HTTPError as e:
+ logging.warning(f'HTTP Error when fetching checksum: {e.reason}')
+ raise e
return r