aboutsummaryrefslogtreecommitdiffstats
path: root/lib/raw_format.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/raw_format.py')
-rwxr-xr-xlib/raw_format.py46
1 files changed, 23 insertions, 23 deletions
diff --git a/lib/raw_format.py b/lib/raw_format.py
index 84ca8c7..00b1f97 100755
--- a/lib/raw_format.py
+++ b/lib/raw_format.py
@@ -31,22 +31,22 @@ sys.path.append('/usr/lib/isodumper')
def do_umount(target):
mounts = get_mounted(target)
if mounts:
- print 'Unmounting all partitions of '+target+':'
+ print('Unmounting all partitions of '+target+':')
for mount in mounts:
- print 'Trying to unmount '+mount[0]+'...'
+ 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)
+ print('Error, umount '+mount[0]+' was terminated by signal '+str(retcode))
sys.exit(6)
else:
if retcode == 0:
- print mount[0]+' successfully unmounted'
+ print(mount[0]+' successfully unmounted')
else:
- print 'Error, umount '+mount[0]+' returned '+str(retcode)
+ print('Error, umount '+mount[0]+' returned '+str(retcode))
sys.exit(6)
- except OSError, e:
- print 'Execution failed: '+str(e)
+ except OSError as e:
+ print('Execution failed: '+str(e))
sys.exit(6)
@@ -55,7 +55,7 @@ def get_mounted(target):
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 !'
+ print('Could not read mtab !')
sys.exit(6)
def raw_format(device_path, fstype, volume_label, uid, gid):
@@ -73,7 +73,7 @@ def raw_format(device_path, fstype, volume_label, uid, gid):
disk.commit()
except:
# Unable to write the new partition
- print "Can't create partition. The device could be read-only."
+ print("Can't create partition. The device could be read-only.")
sys.exit(5)
regions = disk.getFreeSpaceRegions()
@@ -92,7 +92,7 @@ def raw_format(device_path, fstype, volume_label, uid, gid):
try:
geometry = parted.Geometry(device=device, start=start, end=end)
except:
- print "Geometry error - Can't create partition"
+ print("Geometry error - Can't create partition")
sys.exit(5)
# fstype
@@ -121,26 +121,26 @@ def main():
# parse command line options
try:
opts, args = getopt.getopt(sys.argv[1:], "hd:f:l:u:g:", ["help", "device=","filesystem=","label=","uid=","gid="])
- except getopt.error, msg:
- print msg
- print "for help use --help"
+ except getopt.error as msg:
+ print(msg)
+ print("for help use --help")
sys.exit(2)
for o, a in opts:
if o in ("-h", "--help"):
- print "Usage: %s -d device -f filesystem -l volume_label\n" % sys.argv[0]
- print "-d|--device : device path"
- print "-f|--filesystem : filesystem\n"
- print "-l|--label : volume label\n"
- print "-u|--uid : uid of user\n"
- print "-g|--gid : gid of user\n"
- print "Example : %s -d /dev/sdj -f fat32 -l \"USB Stick\" -u 1000 -g 1000" % sys.argv[0]
+ print("Usage: %s -d device -f filesystem -l volume_label\n" % sys.argv[0])
+ print("-d|--device : device path")
+ print("-f|--filesystem : filesystem\n")
+ print("-l|--label : volume label\n")
+ print("-u|--uid : uid of user\n")
+ print("-g|--gid : gid of user\n")
+ print("Example : %s -d /dev/sdj -f fat32 -l \"USB Stick\" -u 1000 -g 1000" % sys.argv[0])
sys.exit(0)
elif o in ("-d"):
device = a
elif o in ("-f"):
if a not in [ "fat32", "ntfs", "ext4" ]:
- print "Specify fat32, ntfs or ext4"
+ print("Specify fat32, ntfs or ext4")
sys.exit(3)
fstype = a
elif o in ("-l"):
@@ -152,8 +152,8 @@ def main():
argc = len(sys.argv)
if argc < 11:
- print "Too few arguments"
- print "for help use --help"
+ print("Too few arguments")
+ print("for help use --help")
exit(2)
raw_format(device, fstype, label, uid, gid)