From f2515fcde9d6c0e6aa2069afe3bf5ceb6fc5022f Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Thu, 22 Sep 2022 17:22:56 +0200 Subject: live: don't use python open() when reading image Specifies the image path in the lzop subprocess string. It might be interesting to study efficient mechanisms to read large binary files in python before using open() with default parameters for buffered binary reading. --- src/live/ogOperations.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py index e99eb41..3e9216d 100644 --- a/src/live/ogOperations.py +++ b/src/live/ogOperations.py @@ -134,15 +134,13 @@ class OgLiveOperations: self._restore_image(image_path, devpath) def _restore_image(self, image_path, devpath): - cmd_lzop = shlex.split('lzop -dc -') + 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 - with open(image_path, 'rb') as imgfile, \ - open('/tmp/command.log', 'wb', 0) as logfile: + with open('/tmp/command.log', 'wb', 0) as logfile: proc_lzop = subprocess.Popen(cmd_lzop, - stdout=subprocess.PIPE, - stdin=imgfile) + stdout=subprocess.PIPE) proc_pc = subprocess.Popen(cmd_pc, stdin=proc_lzop.stdout, stderr=logfile) -- cgit v1.2.3-18-g5258