Find the currently-unused root partition to write to
503586
def _find_unused_partition() -> RootPartitions:
    
    which = subprocess.check_output(['ot-unused-partition']).strip()
    return {b'2': RootPartitions.TWO,
            b'3': RootPartitions.THREE}[which]
816855
def drive(self):
        """"""
        if self.is_drive:
            return self
        cleartext = self.luks_cleartext_slave
        if cleartext:
            return cleartext.drive
        if self.is_block:
            return self._daemon[self._P.Block.Drive]
        return None
788491
def write(self):
        
        with root():
            self._write_log()
            with open(self.path, 'w') as f:
                # file owner
                os.chown(self.path, self.uid(), self.gid())

                # mode
                if self.mode:
                    oldmask = os.umask(0)
                    os.chmod(self.path, self.mode)
                    os.umask(oldmask)

                f.write(self.contents())
617728
def write(data, path, saltenv='base', index=0):
    '''
    
    '''
    if saltenv not in __opts__['pillar_roots']:
        return 'Named environment {0} is not present'.format(saltenv)
    if len(__opts__['pillar_roots'][saltenv]) <= index:
        return 'Specified index {0} in environment {1} is not present'.format(
                index, saltenv)
    if os.path.isabs(path):
        return ('The path passed in {0} is not relative to the environment '
                '{1}').format(path, saltenv)
    dest = os.path.join(__opts__['pillar_roots'][saltenv][index], path)
    dest_dir = os.path.dirname(dest)
    if not os.path.isdir(dest_dir):
        os.makedirs(dest_dir)
    with salt.utils.files.fopen(dest, 'w+') as fp_:
        fp_.write(salt.utils.stringutils.to_str(data))
    return 'Wrote data to file {0}'.format(dest)
732226
def get_all(root=None):
    '''
    
    '''
    ret = _get_systemd_services(root)
    ret.update(set(_get_sysv_services(root, systemd_services=ret)))
    return sorted(ret)
348084
def write_root(histogram: HistogramBase, hfile: uproot.write.TFile.TFileUpdate, name: str):
    
    hfile[name] = histogram
1335002
def get_unused_paths(self):
        
        return [path for path in self.filter.paths if path not in self.seen_paths]
66612
def fsroot(self):
        """"""
        if self.osname == 'windows':
            return '{}:\\'.format(
                self._handler.inspect_get_drive_mappings(self._root)[0][0])
        else:
            return self._handler.inspect_get_mountpoints(self._root)[0][0]
757167
def find_root(self):
        
        cmd = self
        while cmd.parent:
            cmd = cmd.parent
        return cmd
366691
def clean_tmp_rootdir(self):
        
        for tmp_rootdir in list(self._dir_clean_list):
            rm_file_or_dir(tmp_rootdir)
            self._dir_clean_list.remove(tmp_rootdir)
488802
def get_root_dir(self):
        
        if os.path.isdir(self.root_path):
            return self.root_path
        else:
            return os.path.dirname(self.root_path)
41001
def root_dir(self):
        
        if self.cfg.script:
            return os.path.dirname(self.cfg.script)
308071
def root_dir(relpath)
      r = relpath.match(%r(^[/]?.+?[/$]))
      return relpath if r.nil?
      r[0] || relpath
    end
422162
def GetRootFileEntry(self):
    
    path_spec = tsk_partition_path_spec.TSKPartitionPathSpec(
        location=self.LOCATION_ROOT, parent=self._path_spec.parent)
    return self.GetFileEntryByPathSpec(path_spec)
195090
def foldx_dir(self):
        """"""
        if self.root_dir:
            return op.join(self.root_dir, self._foldx_dirname)
        else:
            log.warning('Root directory not set')
            return None
466885
def get_user_root_directory():
    
    uname = platform.system()
    if uname == 'Windows':
        root = os.path.join(os.environ['APPDATA'], APP_NAME)
        root = os.path.abspath(root)
    elif uname == 'Linux':
        if os.path.exists(os.path.expanduser('~/.config')):
            root = os.path.join(os.path.expanduser('~/.config'), APP_NAME)
        else:
            root = os.path.join(os.path.expanduser('~'), '.%s' % APP_NAME)
        root = os.path.abspath(root)
    elif uname in ('Linux', 'Darwin'):
        root = os.path.join(os.path.expanduser('~'), '.%s' % APP_NAME)
        root = os.path.abspath(root)
    else:
        root = os.path.join(os.path.expanduser('~'), APP_NAME)
        root = os.path.abspath(root)
    return root
314081
def disk_usage(path, human=False):
    """"""
    command = ['du', '-s', path]
    if human:
        command.append('-h')

    return subprocess.check_output(command).split()[0].decode('utf-8')