diff options
author | Papoteur <papoteur@mageia.org> | 2020-10-10 12:52:06 +0200 |
---|---|---|
committer | Papoteur <papoteur@mageia.org> | 2020-10-10 12:52:06 +0200 |
commit | 194a1e4f3206bcd69a0d29a831d009d0aad49536 (patch) | |
tree | 703ee51786319e17a655d4eb518b9c92f5c4d42f /backend | |
parent | 80aa0733fac3bec248fc764ed44cb44d68899636 (diff) | |
download | isodumper-194a1e4f3206bcd69a0d29a831d009d0aad49536.tar isodumper-194a1e4f3206bcd69a0d29a831d009d0aad49536.tar.gz isodumper-194a1e4f3206bcd69a0d29a831d009d0aad49536.tar.bz2 isodumper-194a1e4f3206bcd69a0d29a831d009d0aad49536.tar.xz isodumper-194a1e4f3206bcd69a0d29a831d009d0aad49536.zip |
Add waiting step for table partition after new created partition
Move the do_persistence step in a thread a display progress
Diffstat (limited to 'backend')
-rwxr-xr-x | backend/magiback | 5 | ||||
-rwxr-xr-x | backend/raw_write.py | 40 |
2 files changed, 35 insertions, 10 deletions
diff --git a/backend/magiback b/backend/magiback index e7541c3..2ad748b 100755 --- a/backend/magiback +++ b/backend/magiback @@ -94,9 +94,12 @@ class Isodumper(raw_write.Dumper): def do_persistence(self, target, label, key): self.finished.clear() if self.writing_perm and self.writing_target == target : - self._do_persistence(target, label, key) + self.thread = threading.Thread(target=self._do_persistence, args=(target, label, key)) + self.thread.start() + logging.debug("Persistence thread started") else: self.return_message = "Persistence: Access denied" + self.finished.set() self.writing_perm = False self.writing_target = "" diff --git a/backend/raw_write.py b/backend/raw_write.py index 33279d7..0bdaf81 100755 --- a/backend/raw_write.py +++ b/backend/raw_write.py @@ -261,10 +261,24 @@ class Dumper(object): self.return_message = _("Error while doing persistent partition: ") + errs.decode('utf-8') return logging.debug("New partition created") - - # Wait some time to propagate the info of new partition table - time.sleep(1.0) + self._progress = 33 + # Wait for propagation of the info of new partition table + wait = Popen(["udevadm","settle","--timeout=15"], stderr=PIPE) + outs, errs = wait.communicate() + working=True + while working: + time.sleep(0.5) + wait.poll() + rc=wait.returncode + if not (rc is None): + wait = None + working= False + if rc != 0: + self.return_state = False + self.return_message = _("Timeout reached when creating a new partition table") + return + self._progress = 50 if key == "": # example mkfs.ext4 -L mgalive-persist /dev/sdf3 process = Popen(['mkfs.ext4','-L', label, target+"3"],stderr=PIPE) @@ -281,13 +295,14 @@ class Dumper(object): working= False if rc == 0: self.return_state = True + self._progress = 100 self.return_message = _("Persistent partition done") else: self.return_state = False - self.return_message = _("Error while doing persistent partition: ") + errs + self.return_message = _("Error while doing persistent partition: ") + errs.decode("utf-8") + self.finished.set() return logging.info("Persistent partition done") - else: # example cryptsetup luksFormat /dev/sdb3 print("Crypt key provided",file=sys.stderr) @@ -306,9 +321,11 @@ class Dumper(object): working= False if rc != 0: self.return_state = False - self.return_message = _("Error while doing persistent partition: ") + errs + self.return_message = _("Error while doing persistent partition: ") + errs.decode("utf-8") logging.error(self.return_message) + self.finished.set() return + self._progress = 75 # cryptsetup open /dev/sdb3 crypt_sdb3 process = Popen(['cryptsetup','luksOpen', target + "3", 'crypt_' + base_target ,'-d','-'],stdin=PIPE, stderr=PIPE) @@ -325,8 +342,9 @@ class Dumper(object): working= False if rc != 0: self.return_state = False - self.return_message = _("Error while doing persistent partition: ") + errs + self.return_message = _("Error while doing persistent partition: ") + errs.decode("utf-8") logging.error(self.return_message) + self.finished.set() return # mkfs.ext4 -L mgalive-persist /dev/mapper/crypt_sdb3 @@ -344,8 +362,9 @@ class Dumper(object): working= False if rc != 0: self.return_state = False - self.return_message = _("Error while doing persistent partition: ") + errs + self.return_message = _("Error while doing persistent partition: ") + errs.decode("utf-8") logging.error(self.return_message) + self.finished.set() return # cryptsetup close crypt_sdb3 @@ -363,12 +382,15 @@ class Dumper(object): working= False if rc != 0: self.return_state = False - self.return_message = _("Error while doing persistent partition: ") + errs + self.return_message = _("Error while doing persistent partition: ") + errs.decode("utf-8") logging.error(self.return_message) else: self.return_state = True self.return_message = _("Persistent partition done") logging.info("Persistent partition done") + self._progress = 100 + self.finished.set() + logging.debug("Finished") def __init__(self): |