updated on Thu Jan 12 08:01:00 UTC 2012
[aur-mirror.git] / mounty-xfce / diskimage.py
blobbd2a7eef7e0e015c8f88212be2b924251496c364
1 #!/usr/bin/python2
3 import os
4 import os.path
5 import sys
6 import subprocess
7 from ConfigParser import ConfigParser
8 from gettext import gettext as _
10 class DiskImage():
11 def __init__(self, image_file = None):
12 self.image_file = image_file
13 image_name = os.path.basename(self.image_file)
14 #Replace any characters that could screw us up.
15 self.mount_location = os.path.join(os.path.expanduser('~'), image_name.replace(' ', '_'))
16 self.mount_location = self.mount_location.replace('.', '_')
18 def mount(self):
19 if os.path.exists(self.mount_location) and os.listdir(self.mount_location) != []:
20 return False
22 mount_command = "fuseiso -p '%s' '%s'" % (self.image_file, self.mount_location)
23 if os.system(mount_command) != 0:
24 return False
25 else:
26 return True
30 def umount(self):
31 if os.path.exists(self.mount_location):
32 unmount_command = "fusermount -u '%s'" % (self.mount_location)
33 if os.system(unmount_command) != 0:
34 return False
35 else:
36 return True
37 else:
38 return False
40 def burn(self, is_brasero = True):
41 try:
42 if is_brasero:
43 burn_command = "brasero --image '%s'" % (self.image_file)
44 else:
45 burn_command = "nautilus-cd-burner --source-iso='%s'" % (self.image_file)
46 subprocess.Popen(burn_command, shell=True)
47 except:
48 raise
50 def browse(self):
51 browse_command = "Thunar '%s'" % (self.mount_location)
52 try:
53 if os.path.exists(self.mount_location):
54 subprocess.Popen(browse_command, shell=True)
55 except:
56 raise