Beispiel #1
0
 def CheckMountPointFinished(self, result, retval, extra_args):
     print("[AutoMount.py] CheckMountPointFinished", result, retval)
     (data, callback) = extra_args
     path = os.path.join('/media/net', data['sharename'])
     if os.path.exists(path):
         if os.path.ismount(path):
             if data['sharename'] in self.automounts:
                 self.automounts[data['sharename']]['isMounted'] = True
                 desc = data['sharename']
                 if self.automounts[data['sharename']][
                         'hdd_replacement'] == 'True':  #hdd replacement hack
                     self.makeHDDlink(path)
                 harddiskmanager.addMountedPartition(path, desc)
         else:
             if data['sharename'] in self.automounts:
                 self.automounts[data['sharename']]['isMounted'] = False
             if os.path.exists(path):
                 if not os.path.ismount(path):
                     try:
                         os.rmdir(path)
                         harddiskmanager.removeMountedPartition(path)
                     except Exception as ex:
                         print("Failed to remove", path, "Error:", ex)
     if self.checkList:
         # Go to next item in list...
         self.CheckMountPoint(self.checkList.pop(), callback)
     if self.MountConsole:
         if len(self.MountConsole.appContainers) == 0:
             if callback is not None:
                 self.callback = callback
                 self.timer.startLongTimer(1)
Beispiel #2
0
 def CheckMountPointFinished(self, extra_args):
     (data, callback,) = extra_args
     if data['hdd_replacement'] == 'True' or data['hdd_replacement'] is True:
         path = os.path.join('/media/hdd')
         sharepath = os.path.join('/media/net', data['sharename'])
     else:
         path = os.path.join('/media/net', data['sharename'])
         sharepath = ''
     if os.path.exists(path):
         if os.path.ismount(path):
             if self.automounts.has_key(data['sharename']):
                 self.automounts[data['sharename']]['isMounted'] = True
                 desc = data['sharename']
                 harddiskmanager.addMountedPartition(path, desc)
         else:
             if self.automounts.has_key(data['sharename']):
                 self.automounts[data['sharename']]['isMounted'] = False
             if os.path.exists(path):
                 if not os.path.ismount(path):
                     try:
                         os.rmdir(path)
                         harddiskmanager.removeMountedPartition(path)
                     except Exception as ex:
                         print 'Failed to remove',
                         print path,
                         print 'Error:',
                         print ex
     if self.checkList:
         self.CheckMountPoint(self.checkList.pop(), callback)
     if self.MountConsole:
         if len(self.MountConsole.appContainers) == 0:
             if callback is not None:
                 self.callback = callback
                 self.timer.startLongTimer(1)
Beispiel #3
0
	def removeMount(self, mountpoint, callback=None):
		res = False
		entry = Util.findInFstab(src=None, dst=mountpoint)
		if entry:
			sharename=os_path.basename(mountpoint)
			if sharename in self._mounts:
				del self._mounts[sharename]
			self._unmount(mountpoint)
			harddiskmanager.modifyFstabEntry(entry['src'], entry['dst'], mode="remove")
			harddiskmanager.removeMountedPartition(mountpoint)
			res = True
		if callback is not None:
			callback(res)
Beispiel #4
0
 def deactivateMount(self, mountpoint, callback=None):
     logger.debug("mountpoint: %s", mountpoint)
     res = False
     entry = Util.findInFstab(src=None, dst=mountpoint)
     if entry:
         self._unmount(mountpoint)
         harddiskmanager.modifyFstabEntry(entry["src"],
                                          entry["dst"],
                                          mode="remove")
         harddiskmanager.removeMountedPartition(mountpoint)
         res = True
     if callback is not None:
         callback(res)
Beispiel #5
0
	def removeMount(self, mountpoint, callback=None):
		res = False
		entry = Util.findInFstab(src=None, dst=mountpoint)
		if entry:
			sharename=os_path.basename(mountpoint)
			if sharename in self._mounts:
				del self._mounts[sharename]
			self._unmount(mountpoint)
			harddiskmanager.modifyFstabEntry(entry['src'], entry['dst'], mode="remove")
			harddiskmanager.removeMountedPartition(mountpoint)
			res = True
		if callback is not None:
			callback(res)
Beispiel #6
0
    def CheckMountPointFinished(self, extra_args):
        # 		print("[NetworkBrowser] CheckMountPointFinished")
        (data, callback, restart) = extra_args
        hdd_dir = '/media/hdd'
        sharepath = os.path.join('/media/net', data['sharename'])
        if data['mountusing'] == 'autofs':
            sharepath = os.path.join('/media/autofs', data['sharename'])
            path = os.path.join('/media/autofs', data['sharename'])
        elif data['hdd_replacement'] == 'True' or data[
                'hdd_replacement'] is True:
            path = os.path.join('/media/hdd')
        else:
            path = os.path.join('/media/net', data['sharename'])

        if os.path.exists(path):
            if data['mountusing'] == 'autofs':
                if self.automounts.has_key(data['sharename']):
                    self.automounts[data['sharename']]['isMounted'] = True
                    desc = data['sharename']
                    harddiskmanager.addMountedPartition(sharepath, desc)
                if data['hdd_replacement'] == 'True' or data[
                        'hdd_replacement'] is True:
                    if os.path.islink(hdd_dir):
                        if os.readlink(hdd_dir) != path:
                            os.unlink(hdd_dir)
                            os.symlink(path, hdd_dir)
                    elif not os.path.exists(hdd_dir):
                        os.symlink(path, hdd_dir)
            elif os.path.ismount(path):
                if self.automounts.has_key(data['sharename']):
                    self.automounts[data['sharename']]['isMounted'] = True
                    desc = data['sharename']
                    harddiskmanager.addMountedPartition(path, desc)
            else:
                if self.automounts.has_key(data['sharename']):
                    self.automounts[data['sharename']]['isMounted'] = False
                if os.path.exists(path):
                    if not os.path.ismount(path):
                        try:
                            rmtree(path)
                            harddiskmanager.removeMountedPartition(path)
                        except Exception as ex:
                            print("Failed to remove", path, "Error:", ex)
        if self.checkList:
            # Go to next item in list...
            self.CheckMountPoint(self.checkList.pop(), callback, restart)
        if self.MountConsole:
            if len(self.MountConsole.appContainers) == 0:
                if callback is not None:
                    self.callback = callback
                    self.timer.startLongTimer(1)
Beispiel #7
0
	def removeMountPointFinished(self, extra_args):
		(path, callback) = extra_args
		if os.path.exists(path):
			if not os.path.ismount(path):
				try:
					os.rmdir(path)
					harddiskmanager.removeMountedPartition(path)
				except Exception as ex:
					print("Failed to remove", path, "Error:", ex)
		if self.removeConsole:
			if len(self.removeConsole.appContainers) == 0:
				if callback is not None:
					self.callback = callback
					self.timer.startLongTimer(1)
Beispiel #8
0
 def removeMountPointFinished(self, result, retval, extra_args):
     (path, callback,) = extra_args
     if os.path.exists(path):
         if not os.path.ismount(path):
             try:
                 os.rmdir(path)
                 harddiskmanager.removeMountedPartition(path)
             except Exception as ex:
                 print 'Failed to remove',
                 print path,
                 print 'Error:',
                 print ex
     if self.removeConsole:
         if len(self.removeConsole.appContainers) == 0:
             if callback is not None:
                 self.callback = callback
                 self.timer.startLongTimer(1)
Beispiel #9
0
 def _onSharesApplied(self):
     Log.d()
     for sharename, data in self._mounts.items():
         mountpoint = AutoMount.MOUNT_BASE + sharename
         Log.d("mountpoint: %s" % (mountpoint, ))
         if os_path.exists(mountpoint):
             if os_path.ismount(mountpoint):
                 Log.d("'%s' is mounted" % (mountpoint, ))
                 data['isMounted'] = True
                 desc = data['sharename']
                 if data['hdd_replacement']:  #hdd replacement hack
                     self._linkAsHdd(mountpoint)
                 harddiskmanager.addMountedPartition(mountpoint, desc)
             else:
                 Log.d("'%s' is NOT mounted" % (mountpoint, ))
                 sharename = self._mounts.get(data['sharename'], None)
                 if sharename:
                     data['isMounted'] = False
                 if os_path.exists(mountpoint):
                     if not os_path.ismount(mountpoint):
                         removeDir(mountpoint)
                         harddiskmanager.removeMountedPartition(mountpoint)
	def _onSharesApplied(self):
		Log.d()
		for sharename, data in self._mounts.items():
			mountpoint = AutoMount.MOUNT_BASE + sharename
			Log.d("mountpoint: %s" %(mountpoint,))
			if os_path.exists(mountpoint):
				if os_path.ismount(mountpoint):
					Log.d("'%s' is mounted" %(mountpoint,))
					data['isMounted'] = True
					desc = data['sharename']
					if data['hdd_replacement']: #hdd replacement hack
						self._linkAsHdd(mountpoint)
					harddiskmanager.addMountedPartition(mountpoint, desc)
				else:
					Log.d("'%s' is NOT mounted" %(mountpoint,))
					sharename = self._mounts.get(data['sharename'], None)
					if sharename:
						data['isMounted'] = False
					if os_path.exists(mountpoint):
						if not os_path.ismount(mountpoint):
							removeDir(mountpoint)
							harddiskmanager.removeMountedPartition(mountpoint)
Beispiel #11
0
 def CheckMountPointFinished(self, extra_args):
     (
         data,
         callback,
     ) = extra_args
     if data['hdd_replacement'] == 'True' or data['hdd_replacement'] is True:
         path = os.path.join('/media/hdd')
         sharepath = os.path.join('/media/net', data['sharename'])
     else:
         path = os.path.join('/media/net', data['sharename'])
         sharepath = ''
     if os.path.exists(path):
         if os.path.ismount(path):
             if self.automounts.has_key(data['sharename']):
                 self.automounts[data['sharename']]['isMounted'] = True
                 desc = data['sharename']
                 harddiskmanager.addMountedPartition(path, desc)
         else:
             if self.automounts.has_key(data['sharename']):
                 self.automounts[data['sharename']]['isMounted'] = False
             if os.path.exists(path):
                 if not os.path.ismount(path):
                     try:
                         os.rmdir(path)
                         harddiskmanager.removeMountedPartition(path)
                     except Exception as ex:
                         print 'Failed to remove',
                         print path,
                         print 'Error:',
                         print ex
     if self.checkList:
         self.CheckMountPoint(self.checkList.pop(), callback)
     if self.MountConsole:
         if len(self.MountConsole.appContainers) == 0:
             if callback is not None:
                 self.callback = callback
                 self.timer.startLongTimer(1)