diff options
Diffstat (limited to 'backend/raw_write.py')
-rwxr-xr-x | backend/raw_write.py | 40 |
1 files changed, 31 insertions, 9 deletions
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): |