-# about mount funcs..
- def doUmount(self, mountpoint, callback):
- cmd = "umount %s"%mountpoint
- print "[DeviceManager] cmd : %s"%cmd
- os.system(cmd)
- if not path.ismount(mountpoint):
- pass
- else:
- self.session.open(MessageBox, _("Can't umount %s. \nMaybe device or resource busy.")%mountpoint, MessageBox.TYPE_ERROR, timeout = 10)
- callback()
-
- def getDefaultMountPoint(self):
- return self.defaultMountPoint
-
- def getAutoMountPoint(self):
- mountPoint = "/media/"+self.currDevice["model"]
- mountPoint = mountPoint.replace(' ','-')
- if path.ismount(mountPoint):
- partnum = 2
- while 1:
- mountPoint_fix = mountPoint+str(partnum)
- if not path.ismount(mountPoint_fix):
- break
- partnum +=1
- mountPoint = mountPoint_fix
- return mountPoint
-
- def doMount(self, partition, mountpoint):
- try:
-# check mountpoint is in partition list.
- if mountpoint != self.getDefaultMountPoint():
- for p in harddiskmanager.partitions:
- if p.mountpoint == mountpoint:
- self.session.open(MessageBox, _("Can not use this mount point.(%s) \nPlease select another mount point.")%mountpoint, MessageBox.TYPE_ERROR, timeout = 10)
- return
-#
- device = partition["partition"]
- filesystem = partition["fstype"]
- uuid = partition["uuid"]
- if mountpoint.endswith("/"):
- mountpoint = retval[:-1]
- if mountpoint.find(' ') != -1:
- mountpoint = mountpoint.replace(' ','-')
- devpath = "/dev/"+device
- if deviceinfo.isMounted(devpath, mountpoint):
- print "[DeviceManager] '%s -> %s' is already mounted."%(devpath, mountpoint)
- return
-
-# check current device mounted on another mountpoint.
- mp_list = deviceinfo.checkMountDev(devpath)
- for mp in mp_list:
- if mp != mountpoint and path.ismount(mp):
- deviceinfo.umountByMountpoint(mp)
-# check another device mounted on configmountpoint
- devpath_list = deviceinfo.checkMountPoint(mountpoint)
- for devpath_ in devpath_list:
- if devpath_ != devpath:
- self.session.open(MessageBox, _("Mount Failed!\nCurrent path is already mounted by \"%s\"")%devpath_list[0], MessageBox.TYPE_ERROR, timeout = 10)
- return
-# do mount
- print "[DeviceManagerHotplugDevice] doMount"
- if not path.exists(mountpoint):
- os.system("mkdir %s"%mountpoint)
- if path.exists(mountpoint):
- if not path.ismount(mountpoint):
- if filesystem == "ntfs":
- cmd = "ntfs-3g %s %s"%(devpath, mountpoint)
- elif filesystem is None:
- cmd = "mount %s %s"%(devpath, mountpoint)
- else:
- cmd = "mount -t %s %s %s"%(filesystem, devpath, mountpoint)
- print "[DeviceManager] cmd : %s"%cmd
- self.DeviceManagerConsole.ePopen(cmd, self.doMountFinished, (devpath, mountpoint) )
- except:
- self.session.open(MessageBox, _("Mount Failed!\n(%s -> %s)")%(device, mountpoint), MessageBox.TYPE_ERROR, timeout = 10)
-
- def doMountFinished(self, result, retval, extra_args = None):
- (devpath, mountpoint) = extra_args
- if retval == 0:
- if not deviceinfo.isMounted(devpath, mountpoint):
-# print "[DeviceManager] %s doMount failed!"%devpath
- self.session.open(MessageBox, _("Mount Failed!\n(%s -> %s)")%(devpath, mountpoint), MessageBox.TYPE_ERROR, timeout = 10)
- return
- else:
-# make movie directory
- if mountpoint == "/media/hdd":
- movieDir = mountpoint + "/movie"
- if not pathExists(movieDir):
- print "[DeviceManager] make dir %s"%movieDir
- os.makedirs(movieDir)
- self.showPartitionList()
-# update current mount state ,devicemanager.cfg
- pass
-
- def MountpointBrowserCB(self, retval = None):
- if retval and retval is not None:
- mountPoint = retval.strip().replace(' ','')
- if retval.endswith("/"):
- mountPoint = retval[:-1]
- print "Mount point from MountpointBrowser : %s"%mountPoint
- if not path.exists(mountPoint):
- self.session.open(MessageBox, _("Mount Point is not writeable.\nPath : %s")%mountPoint, MessageBox.TYPE_ERROR, timeout = 10)
-
- else:
- self.doMount(self.currPartition, mountPoint)
-# mount funcs end..
-