summaryrefslogtreecommitdiffstats
path: root/src/live/ogOperations.py
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2023-08-01 14:00:32 +0200
committerJose M. Guisado <jguisado@soleta.eu>2023-08-01 18:26:10 +0200
commit49038f125aaadc3967a8eec251a4ea69ec5a8869 (patch)
tree125edd5b8698c09c8ef9bb4e315d87a561517866 /src/live/ogOperations.py
parentee0d62db444441be41d99ac4ee5f2de5100cd934 (diff)
src: improve logging messages
Some users have mistakenly reported tiptorrent problems when the process takes a long time. Specifically by rebooting or powering off the client in the middle of the md5sum computation stage, just after the tiptorrent transfer. Same problem occurs when image creation command takes a long period of time. In order to help the user understand the different stages of commands such as image creation or image restore using tiptorrent, the following changes have been made to the current logging solution: - Add log messages to warn users not to reboot or shut down the client during a tiptorrent transfer, and also during the md5sum computation stage. - Add a log message telling the user that the image creation processes have started. - Use logging.exception inside "except:" blocks to print a traceback with the log messsage. (https://docs.python.org/3/library/logging.html#logging.exception)
Diffstat (limited to 'src/live/ogOperations.py')
-rw-r--r--src/live/ogOperations.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py
index df13816..0998b18 100644
--- a/src/live/ogOperations.py
+++ b/src/live/ogOperations.py
@@ -49,7 +49,7 @@ class OgLiveOperations:
proc = subprocess.call(["pkill", "-9", "browser"])
proc = subprocess.Popen(["browser", "-qws", url])
except:
- logging.error('Cannot restart browser')
+ logging.exception('Cannot restart browser')
raise ValueError('Error: cannot restart browser')
def _refresh_payload_disk(self, cxt, part_setup, num_disk):
@@ -137,7 +137,7 @@ class OgLiveOperations:
r = shutil.copy(src, dst)
tip_write_csum(image_name)
except:
- logging.error('Error copying image to cache')
+ logging.exception('Error copying image to cache')
raise ValueError(f'Error: Cannot copy image {image_name} to cache')
def _restore_image_unicast(self, repo, name, devpath, cache=False):
@@ -168,6 +168,7 @@ class OgLiveOperations:
def _restore_image(self, image_path, devpath):
logging.debug(f'Restoring image at {image_path} into {devpath}')
+ logging.debug(f'This process can take some time, please *DO NOT SHUT DOWN OR REBOOT* this client')
cmd_lzop = shlex.split(f'lzop -dc {image_path}')
cmd_pc = shlex.split(f'partclone.restore -d0 -C -I -o {devpath}')
cmd_mbuffer = shlex.split('mbuffer -q -m 40M') if shutil.which('mbuffer') else None
@@ -237,7 +238,7 @@ class OgLiveOperations:
executable=OG_SHELL)
(output, error) = ogRest.proc.communicate()
except:
- logging.error('Exception when running "shell run" subprocess')
+ logging.exception('Exception when running "shell run" subprocess')
raise ValueError('Error: Incorrect command value')
if ogRest.proc.returncode != 0:
@@ -261,7 +262,7 @@ class OgLiveOperations:
executable=OG_SHELL)
(output, error) = ogRest.proc.communicate()
except:
- logging.error('Exception when running session subprocess')
+ logging.exception('Exception when running session subprocess')
raise ValueError('Error: Incorrect command value')
logging.info('Starting OS at disk %s partition %s', disk, partition)
@@ -298,7 +299,7 @@ class OgLiveOperations:
try:
inventory = get_hardware_inventory()
except ValueError as e:
- logging.error('Error occurred while running get_hardware_inventory')
+ logging.exception('Error occurred while running get_hardware_inventory')
raise e
finally:
self._restartBrowser(self._url)
@@ -456,10 +457,12 @@ class OgLiveOperations:
p2 = Popen(cmd2, stdin=p1.stdout)
p1.stdout.close()
+ logging.info(f'Running image creation process, please do not shut down or reboot the client')
+
try:
retdata = p2.communicate()
except OSError as e:
- logging.error('Unexpected error when running partclone and lzop commands')
+ logging.exception('Unexpected error when running partclone and lzop commands')
finally:
logfile.close()
p2.terminate()
@@ -473,7 +476,7 @@ class OgLiveOperations:
image_info = ogGetImageInfo(image_path)
except:
self._restartBrowser(self._url)
- logging.error('Exception when running "image create" subprocess')
+ logging.exception('Exception when running "image create" subprocess')
raise ValueError('Error: Incorrect command value')
self._write_md5_file(f'/opt/opengnsys/images/{name}.img')