aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/isodumper.py2
-rwxr-xr-xlib/raw_format.py33
2 files changed, 2 insertions, 33 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py
index d8b4a8f..9b67c2f 100755
--- a/lib/isodumper.py
+++ b/lib/isodumper.py
@@ -275,6 +275,8 @@ class IsoDumper(object):
self.dialog.pollEvent()
def raw_format(self, usb_path, fstype, label):
+ self.u.do_unmount(usb_path)
+ self.udev_wait(_("unmounting"))
self.operation = True
if os.geteuid() > 0:
launcher = 'pkexec'
diff --git a/lib/raw_format.py b/lib/raw_format.py
index b3bdb42..bf57ba5 100755
--- a/lib/raw_format.py
+++ b/lib/raw_format.py
@@ -29,41 +29,8 @@ from subprocess import call
sys.path.append('/usr/lib/isodumper')
-
-def do_umount(target):
- mounts = get_mounted(target)
- if mounts:
- print('Unmounting all partitions of ' + target + ':')
- for mount in mounts:
- print('Trying to unmount ' + mount[0] + '...')
- try:
- retcode = call('umount ' + mount[0], shell=True)
- if retcode < 0:
- print('Error, umount ' + mount[0] + ' was terminated by signal ' + str(retcode))
- sys.exit(6)
- else:
- if retcode == 0:
- print(mount[0] + ' successfully unmounted')
- else:
- print('Error, umount ' + mount[0] + ' returned ' + str(retcode))
- sys.exit(6)
- except OSError as e:
- print('Execution failed: ' + str(e))
- sys.exit(6)
-
-
-def get_mounted(target):
- try:
- lines = [line.strip("\n").split(" ") for line in open("/etc/mtab", "r").readlines()]
- return [mount for mount in lines if mount[0].startswith(target)]
- except:
- print('Could not read mtab !')
- sys.exit(6)
-
-
def raw_format(device_path, fstype, volume_label, uid, gid):
import parted
- do_umount(device_path)
# First erase MBR and partition table , if any
call(["dd", "if=/dev/zero", "of=%s" % device_path, "bs=512", "count=1"])