Mount the device if not already mounted.

        :param device: device object, block device path or mount path
        :returns: whether the device is mounted.
175632
async def mount(self, device):
        
        device = self._find_device(device)
        if not self.is_handleable(device) or not device.is_filesystem:
            self._log.warn(_('not mounting {0}: unhandled device', device))
            return False
        if device.is_mounted:
            self._log.info(_('not mounting {0}: already mounted', device))
            return True
        options = match_config(self._config, device, 'options', None)
        kwargs = dict(options=options)
        self._log.debug(_('mounting {0} with {1}', device, kwargs))
        self._check_device_before_mount(device)
        mount_path = await device.mount(**kwargs)
        self._log.info(_('mounted {0} on {1}', device, mount_path))
        return True
59501
def setDevice(self, device): 
        
        print(self.pre, "setDevice :", device)
        
        if (not device and not self.device): # None can be passed as an argument when the device has not been set yet
            return
            
        if (self.device):
            if self.device == device:
                print(self.pre, "setDevice : same device")
                return
            
        if self.filterchain: # there's video already
            self.clearDevice()
        
        self.device = device
        self.video.setDevice(self.device) # inform the video widget so it can start drags
        
        # ManagedFilterChain.addViewPort accepts ViewPort instance
        self.filterchain = self.filterchain_group.get(_id = self.device._id)
        
        if self.filterchain:
            self.viewport.setXScreenNum(self.n_xscreen)
            self.viewport.setWindowId  (int(self.video.winId()))
            self.filterchain.addViewPort(self.viewport)
1155070
def _check_device_exists_in_device_group(self, device_name):
        '''
        '''

        dg = self._get_device_group(self.devices[0])
        dg.devices_s.devices.load(name=device_name, partition=self.partition)
995063
def _on_connected(self, device):
        
        self._logger.debug("Device connected event: {}".format(device))

        self.connected = True
        self._connection_handle = device['connection_handle']
        self.device.connected = True
        self._audit('ClientConnected')
143645
def do_set_device(self, args):
        
        params = args.split()
        device = None

        try:
            device = params[0]
        except IndexError:
            _LOGGING.error('Device name required.')
            self.do_help('set_device')

        if device:
            self.tools.device = device
168698
async def eject(self, device, force=False):
        
        device = self._find_device(device)
        if not self.is_handleable(device):
            self._log.warn(_('not ejecting {0}: unhandled device'))
            return False
        drive = device.drive
        if not (drive.is_drive and drive.is_ejectable):
            self._log.warn(_('not ejecting {0}: drive not ejectable', drive))
            return False
        if force:
            # Can't autoremove 'device.drive', because that will be filtered
            # due to block=False:
            await self.auto_remove(device.root, force=True)
        self._log.debug(_('ejecting {0}', device))
        await drive.eject()
        self._log.info(_('ejected {0}', device))
        return True
1326091
def is_mount(self, name):
        """"""
        if self.mount_prefix.startswith(self.module_prefix):
            return name.startswith(self.mount_prefix)
        return name.startswith(self.mount_prefix) and not name.startswith(self.module_prefix)
967457
def ensure_block_device(block_device):
    '''
    
    '''
    _none = ['None', 'none', None]
    if (block_device in _none):
        error_out('prepare_storage(): Missing required input: block_device=%s.'
                  % block_device)

    if block_device.startswith('/dev/'):
        bdev = block_device
    elif block_device.startswith('/'):
        _bd = block_device.split('|')
        if len(_bd) == 2:
            bdev, size = _bd
        else:
            bdev = block_device
            size = DEFAULT_LOOPBACK_SIZE
        bdev = ensure_loopback_device(bdev, size)
    else:
        bdev = '/dev/%s' % block_device

    if not is_block_device(bdev):
        error_out('Failed to locate valid block device at %s' % bdev)

    return bdev
423284
def is_removable(self, device):
        """"""
        if not self.is_handleable(device):
            return False
        if device.is_filesystem:
            return device.is_mounted
        if device.is_crypto:
            return device.is_unlocked
        if device.is_partition_table or device.is_drive:
            return any(self.is_removable(dev)
                       for dev in self.get_all_handleable()
                       if _is_parent_of(device, dev))
        return False
28011
def is_dock_obj_mounted(docker_obj):
    '''
    
    '''
    mount_info = get_mounts_by_path()
    devices = [x['device'] for x in mount_info]
    # If we can find the ID of the object in the list
    # of devices which comes from mount, safe to assume
    # it is busy.
    return any(docker_obj in x for x in devices)
1167402
def mount_point(self):
        
        if self._mount_point is None:
            cmd_create = ["podman", "create", self.target_name, "some-cmd"]
            self._mounted_container_id = subprocess.check_output(cmd_create).decode().rstrip()
            cmd_mount = ["podman", "mount", self._mounted_container_id]
            self._mount_point = subprocess.check_output(cmd_mount).decode().rstrip()
        return self._mount_point
244208
def if_device_path_exists(device_serial, device_path)
      return if run_adb_command("adb -s #{device_serial} shell ls #{device_path}",
                                print_all: false,
                                print_command: false).include?('No such file')

      yield(device_path)
    rescue
      # Some versions of ADB will have a non-zero exit status for this, which will cause the executor to raise.
      # We can safely ignore that and treat it as if it returned 'No such file'
    end
628424
def in_use(self):
        """"""
        if self.is_mounted or self.is_unlocked:
            return True
        if self.is_partition_table:
            for device in self._daemon:
                if device.partition_slave == self and device.in_use:
                    return True
        return False
1023996
def IsDevice(self):
    
    if self._stat_object is None:
      self._stat_object = self._GetStat()
    if self._stat_object is not None:
      self.entry_type = self._stat_object.type
    return self.entry_type == definitions.FILE_ENTRY_TYPE_DEVICE
34487
def device_is_attached_to_network(device, network_name):
        
        try:
            backing = device.backing
        except:
            return False
        if hasattr(backing, 'network') and hasattr(backing.network, 'name'):
            return network_name == backing.network.name
        elif hasattr(backing, 'port') and hasattr(backing.port, 'portgroupKey'):
            return network_name == backing.port.portgroupKey

        return False
601057
async def delete(self, device, remove=True):
        
        device = self._find_device(device)
        if not self.is_handleable(device) or not device.is_loop:
            self._log.warn(_('not deleting {0}: unhandled device', device))
            return False
        if remove:
            await self.auto_remove(device, force=True)
        self._log.debug(_('deleting {0}', device))
        await device.delete()
        self._log.info(_('deleted {0}', device))
        return True
1262605
protected static function is_device($device)
    {
        $ua = $_SERVER['HTTP_USER_AGENT'];
        return (bool)preg_match("/" . self::$devices[$device] . "/i", $ua);
    }