コード例 #1
0
    def install(self, source, target, persist, allow_system_internal=False):
        # TODO evand 2009-07-31: Lock source and target.
        logging.debug('install source: %s' % source)
        logging.debug('install target: %s' % target)
        logging.debug('install persistence: %d' % persist)

        # There's no going back now...
        self.bus.remove_signal_receiver(self._device_added, 'DeviceAdded',
                                        DISKS_IFACE, DISKS_IFACE,
                                        '/org/freedesktop/UDisks')
        self.bus.remove_signal_receiver(self._device_changed, 'DeviceChanged',
                                        DISKS_IFACE, DISKS_IFACE,
                                        '/org/freedesktop/UDisks')
        self.bus.remove_signal_receiver(self._device_removed, 'DeviceRemoved',
                                        DISKS_IFACE, DISKS_IFACE,
                                        '/org/freedesktop/UDisks')

        stype = self.sources[source]['type']
        if stype == misc.SOURCE_CD:
            dk = self.bus.get_object(DISKS_IFACE, source)

            def get_source(prop):
                return dk.Get(source, prop, dbus_interface=PROPS_IFACE)

            if not get_source('device-is-mounted'):
                source = dk.FilesystemMount('', [],
                                            dbus_interface=DEVICE_IFACE)
            else:
                source = get_source('device-mount-paths')[0]
        elif stype == misc.SOURCE_ISO:
            isofile = self.sources[source]['device']
            source = self.helper.MountISO(isofile)
            self.mounted_source = source

        dk = self.bus.get_object(DISKS_IFACE, target)

        def get_target(prop):
            return dk.Get(target, prop, dbus_interface=PROPS_IFACE)

        dev = get_target('device-file')
        if stype == misc.SOURCE_IMG:
            target = None
            self.helper.Unmount(target)
        else:
            if not get_target('device-is-mounted'):
                target = dk.FilesystemMount('', [],
                                            dbus_interface=DEVICE_IFACE)
            else:
                target = get_target('device-mount-paths')[0]
            self.helper.RemountRW(dev)
        Backend.install(self,
                        source,
                        target,
                        persist,
                        device=dev,
                        allow_system_internal=allow_system_internal)
コード例 #2
0
 def install(self, source, target, persist):
     target_dev = None
     source_type = self.sources[source]['type']
     if source_type == misc.SOURCE_IMG:
         target_dev = get_device_num_for_letter(target)
         if target_dev < 1:
             logging.error('Could not determine the disk number.  Got %d.' %
                           target_dev)
             # TODO evand 2009-08-28: Fail.
             return
         target_dev = '\\\\?\\Device\\Hardisk%d\\Partition0' % target_dev
     Backend.install(self, source, target, persist, device=target_dev)
コード例 #3
0
ファイル: backend.py プロジェクト: Alberto-Beralix/Beralix
    def install(self, source, target, persist, allow_system_internal=False):
        # TODO evand 2009-07-31: Lock source and target.
        logging.debug('install source: %s' % source)
        logging.debug('install target: %s' % target)
        logging.debug('install persistence: %d' % persist)

        # There's no going back now...
        self.bus.remove_signal_receiver(self._device_added,
            'DeviceAdded',
            DISKS_IFACE,
            DISKS_IFACE,
            '/org/freedesktop/UDisks')
        self.bus.remove_signal_receiver(self._device_changed,
            'DeviceChanged',
            DISKS_IFACE,
            DISKS_IFACE,
            '/org/freedesktop/UDisks')
        self.bus.remove_signal_receiver(self._device_removed,
            'DeviceRemoved',
            DISKS_IFACE,
            DISKS_IFACE,
            '/org/freedesktop/UDisks')

        stype = self.sources[source]['type']
        if stype == SOURCE_CD:
            dk = self.bus.get_object(DISKS_IFACE, source)
            def get(prop):
                return dk.Get(source, prop, dbus_interface=PROPS_IFACE)
            if not get('device-is-mounted'):
                source = dk.FilesystemMount('', [], dbus_interface=DEVICE_IFACE)
            else:
                source = get('device-mount-paths')[0]
        elif stype == SOURCE_ISO:
            isofile = self.sources[source]['device']
            source = self.helper.MountISO(isofile)
            self.mounted_source = source
        
        dk = self.bus.get_object(DISKS_IFACE, target)
        def get(prop):
            return dk.Get(target, prop, dbus_interface=PROPS_IFACE)
        dev = get('device-file')
        if stype == SOURCE_IMG:
            target = None
            self.helper.Unmount(target)
        else:
            if not get('device-is-mounted'):
                target = dk.FilesystemMount('', [], dbus_interface=DEVICE_IFACE)
            else:
                target = get('device-mount-paths')[0]
            self.helper.RemountRW(dev)
        Backend.install(self, source, target, persist, device=dev,
                        allow_system_internal=allow_system_internal)
コード例 #4
0
ファイル: backend.py プロジェクト: giorgi94/usb-creator
    def install(self, source, target, allow_system_internal=False):
        # TODO evand 2009-07-31: Lock source and target.
        logging.debug('install source: %s' % source)
        logging.debug('install target: %s' % target)

        # There's no going back now...
        for handle in self.handles:
            self.manager.disconnect(handle)

        dev = self.targets[target]['device']
        self.helper.Unmount(target)

        Backend.install(self, source, target, device=dev,
                        allow_system_internal=allow_system_internal)
コード例 #5
0
ファイル: backend.py プロジェクト: pombreda/OnionScraper
    def install(self, source, target, persist, allow_system_internal=False):
        # TODO evand 2009-07-31: Lock source and target.
        logging.debug('install source: %s' % source)
        logging.debug('install target: %s' % target)
        logging.debug('install persistence: %d' % persist)

        # There's no going back now...
        for handle in self.handles:
            self.manager.disconnect(handle)

        stype = self.sources[source]['type']
        if stype == misc.SOURCE_CD:
            source = self.sources[source]['mount']
        elif stype == misc.SOURCE_ISO:
            isofile = self.sources[source]['device']
            source = self.helper.MountISO(isofile)
            self.mounted_source = source

        dev = self.targets[target]['device']
        if stype == misc.SOURCE_IMG:
            target_path = None
            self.helper.Unmount(target)
        else:
            obj = self.udisks.get_object(target)
            fs = obj.get_filesystem()
            mount_points = fs.get_cached_property(
                'MountPoints').get_bytestring_array()
            if len(mount_points) == 0:
                target_path = fs.call_mount_sync(no_options, None)
            else:
                target_path = mount_points[0]
            self.helper.RemountRW(dev)
        Backend.install(self,
                        source,
                        target_path,
                        persist,
                        device=dev,
                        allow_system_internal=allow_system_internal)