Mount the device in a temporary place.
504686
def _mount(device):
    '''
    
    '''
    dest = tempfile.mkdtemp()
    res = __states__['mount.mounted'](dest, device=device, fstype='btrfs',
                                      opts='subvol=/', persist=False)
    if not res['result']:
        log.error('Cannot mount device %s in %s', device, dest)
        _umount(dest)
        return None
    return dest
1369391
def thing2place(self, name):
        """"""
        self.engine._set_thing_loc(
            self.name, name, None
        )
        if (self.name, name) in self.engine._node_objs:
            thing = self.engine._node_objs[self.name, name]
            place = Place(self, name)
            for port in thing.portals():
                port.origin = place
            for port in thing.preportals():
                port.destination = place
            self.engine._node_objs[self.name, name] = place
1380
def attach(self, remote_entry):
        """"""
        self.name = remote_entry.name
        self.sha = remote_entry.sha
        self.url = remote_entry.url
        self.author = remote_entry.author
        return self
875941
def attach_hardware(self, ticket_id=None, hardware_id=None):
        
        return self.ticket.addAttachedHardware(hardware_id, id=ticket_id)
745771
def temporary_object_path(self, name):
        
        return os.path.join(self._path, self.TMP_OBJ_DIR, name)
749931
def mount(name, device, mkmnt=False, fstype='', opts='defaults', user=None, util='mount'):
    '''
    
    '''
    if util != 'mount':
        # This functionality used to live in img.mount_image
        if util == 'guestfs':
            return __salt__['guestfs.mount'](name, root=device)
        elif util == 'qemu_nbd':
            mnt = __salt__['qemu_nbd.init'](name, device)
            if not mnt:
                return False
            first = next(six.iterkeys(mnt))
            __context__['img.mnt_{0}'.format(first)] = mnt
            return first
        return False

    # Darwin doesn't expect defaults when mounting without other options
    if 'defaults' in opts and __grains__['os'] in ['MacOS', 'Darwin', 'AIX']:
        opts = None

    if isinstance(opts, six.string_types):
        opts = opts.split(',')

    if not os.path.exists(name) and mkmnt:
        __salt__['file.mkdir'](name, user=user)

    args = ''
    if opts is not None:
        lopts = ','.join(opts)
        args = '-o {0}'.format(lopts)

    if fstype:
        # use of fstype on AIX differs from typical Linux use of -t
        # functionality AIX uses -v vfsname, -t fstype mounts all with
        # fstype in /etc/filesystems
        if 'AIX' in __grains__['os']:
            args += ' -v {0}'.format(fstype)
        elif 'solaris' in __grains__['os'].lower():
            args += ' -F {0}'.format(fstype)
        else:
            args += ' -t {0}'.format(fstype)

    cmd = 'mount {0} {1} {2} '.format(args, device, name)
    out = __salt__['cmd.run_all'](cmd, runas=user, python_shell=False)
    if out['retcode']:
        return out['stderr']
    return True
419666
def main(args):
  """"""
  random.seed()
  temp_dir = tempfile.mkdtemp()
  logging.info('Created temporary directory: %s', temp_dir)
  validator = SubmissionValidator(
      source_dir=args.source_dir,
      target_dir=args.target_dir,
      temp_dir=temp_dir,
      do_copy=args.copy,
      use_gpu=args.use_gpu,
      containers_file=args.containers_file)
  validator.run()
  logging.info('Deleting temporary directory: %s', temp_dir)
  subprocess.call(['rm', '-rf', temp_dir])
883097
def sync_set_heater_temp(self, device_id, set_temp):
        """"""
        loop = asyncio.get_event_loop()
        task = loop.create_task(self.set_heater_temp(device_id, set_temp))
        loop.run_until_complete(task)
1175262
def _default_temporary_directory(self, prefix):
    """"""
    try:
      self.temporary_file = tempfile.NamedTemporaryFile(prefix=prefix)

    except OSError as err: # pragma: no cover
      logger.critical('Cannot create a system temporary directory: '+repr(err))
      raise securesystemslib.exceptions.Error(err)
629165
def auto_mounter(original):
    """"""
    def mounter(*args):
        """If not mounted, mount."""
        self = args[0]
        if not self.is_mounted():
            self.mount()
        return original(*args)
    return mounter
917329
def install(self, to, chmod=0644):
        
        self.copy(to)
        path(to).chmod(chmod)
977011
def mount(self):
        """"""
        if not self.is_mounted():
            # OS X mounting is handled automagically in /Volumes:
            # DO NOT mkdir there!
            # For Linux, ensure the mountpoint exists.
            if not is_osx():
                if not os.path.exists(self.connection["mount_point"]):
                    os.mkdir(self.connection["mount_point"])
            self._mount()
770706
def Reposition(self):
        """"""

        rect = self.GetFieldRect(1)
        self.safemode_staticbmp.SetPosition((rect.x, rect.y))
        self.size_changed = False
159475
def _prepare_temp_dir(self):
    """"""
    shell_call(['rm', '-rf', os.path.join(self._temp_dir, '*')])
    # NOTE: we do not create self._extracted_submission_dir
    # this is intentional because self._tmp_extracted_dir or it's subdir
    # will be renames into self._extracted_submission_dir
    os.mkdir(self._tmp_extracted_dir)
    os.mkdir(self._sample_input_dir)
    os.mkdir(self._sample_output_dir)
    # make output dir world writable
    shell_call(['chmod', 'a+rwX', '-R', self._sample_output_dir])
103550
def temporary_file(mode):
    
    tempdir = tempfile.gettempdir()
    basename = 'tmpfile-%s' % (uuid.uuid4())
    full_filename = os.path.join(tempdir, basename)
    if 'w' not in mode:
        # We need to create the file before we can open
        # it in 'r' mode.
        open(full_filename, 'w').close()
    try:
        with open(full_filename, mode) as f:
            yield f
    finally:
        os.remove(f.name)
182460
def tdecode(pkt, *args):
    """"""
    if not args:
      args = [ "-V" ]
    fname = get_temp_file()
    wrpcap(fname,[pkt])
    subprocess.call(["tshark", "-r", fname] + list(args))
142006
def mount(nbd, root=None):
    '''
    
    '''
    __salt__['cmd.run'](
            'partprobe {0}'.format(nbd),
            python_shell=False,
            )
    ret = {}
    if root is None:
        root = os.path.join(
            tempfile.gettempdir(),
            'nbd',
            os.path.basename(nbd)
        )
    for part in glob.glob('{0}p*'.format(nbd)):
        m_pt = os.path.join(root, os.path.basename(part))
        time.sleep(1)
        mnt = __salt__['mount.mount'](m_pt, part, True)
        if mnt is not True:
            continue
        ret[m_pt] = part
    return ret