diff options
author | Jose M. Guisado <jguisado@soleta.eu> | 2022-09-22 17:22:56 +0200 |
---|---|---|
committer | Jose M. Guisado <jguisado@soleta.eu> | 2022-09-23 12:12:35 +0200 |
commit | f2515fcde9d6c0e6aa2069afe3bf5ceb6fc5022f (patch) | |
tree | f2e07441d003b314887f058435d42ddbc4850cbb /src | |
parent | 00a95bdb61aae943c670eed6fd59185546adc777 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/live/ogOperations.py | 8 |
1 files 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) |