当前位置: 首页>>代码示例>>Python>>正文


Python os.access方法代码示例

本文整理汇总了Python中os.access方法的典型用法代码示例。如果您正苦于以下问题:Python os.access方法的具体用法?Python os.access怎么用?Python os.access使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在os的用法示例。


在下文中一共展示了os.access方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: find_executable

# 需要导入模块: import os [as 别名]
# 或者: from os import access [as 别名]
def find_executable(name) -> str:
    is_windows = os.name == 'nt'
    windows_exts = os.environ['PATHEXT'].split(ENV_PATH_SEP) if is_windows else None
    path_dirs = os.environ['PATH'].split(ENV_PATH_SEP)

    search_dirs = path_dirs + [os.getcwd()] # cwd is last in the list

    for dir in search_dirs:
        path = os.path.join(dir, name)

        if is_windows:
            for extension in windows_exts:
                path_with_ext = path + extension

                if os.path.isfile(path_with_ext) and os.access(path_with_ext, os.X_OK):
                    return path_with_ext
        else:
            if os.path.isfile(path) and os.access(path, os.X_OK):
                return path

    return '' 
开发者ID:godotengine,项目名称:godot-mono-builds,代码行数:23,代码来源:os_utils.py

示例2: start_download

# 需要导入模块: import os [as 别名]
# 或者: from os import access [as 别名]
def start_download(self):
        self.url.assert_no_error()
        self.username.assert_no_error()
        self.password.assert_no_error()
        self.proxy.assert_no_error()
        self.save_path.assert_no_error()

        url = self.url.get_input()
        proxy = self.proxy.get_input() or None
        username = self.username.get_input()
        password = self.password.get_input()
        path_prefix = self.save_path.get_path()

        if not os.access(path_prefix, os.W_OK):
            return info("对下载文件夹没有写权限,请重新选择")
        if self.downloader is not None:
            if not self.downloader.done:
                return info("请停止后再重新点击下载...")
        self.downloader = pixiv_run(
            url=url,
            username=username,
            password=password,
            proxy=proxy,
            path_prefix=path_prefix,
        ) 
开发者ID:winkidney,项目名称:PickTrue,代码行数:27,代码来源:downloader.py

示例3: get_cache_dir

# 需要导入模块: import os [as 别名]
# 或者: from os import access [as 别名]
def get_cache_dir(cachedir=None):
    """
    Return EXOSIMS cache directory.  Order of priority is:
    1. Input (typically taken from JSON spec script)
    2. EXOSIMS_CACHE_DIR environment variable
    3. Default in $HOME/.EXOSIMS/cache (for whatever $HOME is returned by get_home_dir)

    In each case, the directory is checked for read/write/access permissions.  If 
    any permissions are missing, will return default path.

    Returns:
        cache_dir (str):
            Path to EXOSIMS cache directory
    """

    cache_dir = get_exosims_dir('cache',cachedir)
    return cache_dir 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:19,代码来源:get_dirs.py

示例4: get_downloads_dir

# 需要导入模块: import os [as 别名]
# 或者: from os import access [as 别名]
def get_downloads_dir(downloadsdir=None):
    """
    Return EXOSIMS downloads directory.  Order of priority is:
    1. Input (typically taken from JSON spec script)
    2. EXOSIMS_CACHE_DIR environment variable
    3. Default in $HOME/.EXOSIMS/downloads (for whatever $HOME is returned by get_home_dir)

    In each case, the directory is checked for read/write/access permissions.  If 
    any permissions are missing, will return default path.


    Returns:
        downloads_dir (str):
            Path to EXOSIMS downloads directory
    """

    downloads_dir = get_exosims_dir('downloads',downloadsdir)

    return downloads_dir 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:21,代码来源:get_dirs.py

示例5: __init__

# 需要导入模块: import os [as 别名]
# 或者: from os import access [as 别名]
def __init__(self, n_pop=4, **specs):
        
        FortneyMarleyCahoyMix1.__init__(self, **specs)
        
        # number of category
        self.n_pop = int(n_pop)
        
        # read forecaster parameter file
        downloadsdir = get_downloads_dir()
        filename = 'fitting_parameters.h5'
        parampath = os.path.join(downloadsdir, filename)
        if not os.path.exists(parampath) and os.access(downloadsdir, os.W_OK|os.X_OK):
            fitting_url = 'https://raw.github.com/dsavransky/forecaster/master/fitting_parameters.h5'
            self.vprint("Fetching Forecaster fitting parameters from %s to %s" % (fitting_url, parampath))
            try:
                urlretrieve(fitting_url, parampath)
            except:
                self.vprint("Error: Remote fetch failed. Fetch manually or see install instructions.")

        assert os.path.exists(parampath), 'fitting_parameters.h5 must exist in /.EXOSIMS/downloads'

        h5 = h5py.File(parampath, 'r')
        self.all_hyper = h5['hyper_posterior'][:]
        h5.close() 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:26,代码来源:Forecaster.py

示例6: get_output_filename

# 需要导入模块: import os [as 别名]
# 或者: from os import access [as 别名]
def get_output_filename(self, user_outputname):
        '''
        check that we have permissions to write to output directory
        adds 'dscalar.nii' to end of outputname if not already present
        '''
        outputname = os.path.realpath(user_outputname)
        output_dir = os.path.dirname(outputname)
        if not os.access(output_dir, os.W_OK):
            logger.error('Cannot write to output file {}\n'\
                         'The folder does not exist, or you do not have permission to write there'\
                         ''.format(outputname))
            sys.exit(1)
        if not outputname.endswith('dscalar.nii'):
            if not outputname.endswith('dtseries.nii'):
                logger.info("Appending '.dscalar.nii' extension to outputname")
                outputname = '{}.dscalar.nii'.format(outputname)
        return outputname 
开发者ID:edickie,项目名称:ciftify,代码行数:19,代码来源:ciftify_vol_result.py

示例7: __init__

# 需要导入模块: import os [as 别名]
# 或者: from os import access [as 别名]
def __init__(self, prefLabel, arity, altLabels=[], closures=[], extension=set()):
        """
        :param prefLabel: the preferred label for the concept
        :type prefLabel: str
        :param arity: the arity of the concept
        :type arity: int
        @keyword altLabels: other (related) labels
        :type altLabels: list
        @keyword closures: closure properties of the extension \
            (list items can be ``symmetric``, ``reflexive``, ``transitive``)
        :type closures: list
        @keyword extension: the extensional value of the concept
        :type extension: set
        """
        self.prefLabel = prefLabel
        self.arity = arity
        self.altLabels = altLabels
        self.closures = closures
        #keep _extension internally as a set
        self._extension = extension
        #public access is via a list (for slicing)
        self.extension = sorted(list(extension)) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:24,代码来源:chat80.py

示例8: find_config

# 需要导入模块: import os [as 别名]
# 或者: from os import access [as 别名]
def find_config():
    w = None
    for f in search_config:
        f = os.path.expanduser(f)
        f = os.path.abspath(f)
        d = os.path.dirname(f)
        if os.path.exists(d):
            if os.access(d, os.W_OK):
                w = f
            if os.path.exists(f):
                if os.access(f, os.W_OK):
                    return f
        elif os.access(os.path.dirname(d), os.W_OK):
            os.makedirs(d)
            w = f
    if w is None:
        print ("Cannot find suitable config path to write, create one in %s" % ' or '.join(search_config))
        raise Exception("No config file")
    return w 
开发者ID:klattimer,项目名称:LGWebOSRemote,代码行数:21,代码来源:__init__.py

示例9: is_executable_available

# 需要导入模块: import os [as 别名]
# 或者: from os import access [as 别名]
def is_executable_available(program):
    def is_exe(fpath):
        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

    fpath = os.path.dirname(program)
    if fpath:
        if is_exe(program):
            return True
    else:
        for path in os.environ["PATH"].split(os.pathsep):
            path = path.strip('"')
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return True

    return False 
开发者ID:ethereum,项目名称:py-solc,代码行数:18,代码来源:install_solc.py

示例10: which

# 需要导入模块: import os [as 别名]
# 或者: from os import access [as 别名]
def which(program):
    """Locate `program` in PATH

    Arguments:
        program (str): Name of program, e.g. "python"

    """

    def is_exe(fpath):
        if os.path.isfile(fpath) and os.access(fpath, os.X_OK):
            return True
        return False

    for path in os.environ["PATH"].split(os.pathsep):
        for ext in os.getenv("PATHEXT", "").split(os.pathsep):
            fname = program + ext.lower()
            abspath = os.path.join(path.strip('"'), fname)

            if is_exe(abspath):
                return abspath

    return None 
开发者ID:getavalon,项目名称:core,代码行数:24,代码来源:lib.py

示例11: which

# 需要导入模块: import os [as 别名]
# 或者: from os import access [as 别名]
def which(program):
    import os

    def is_exe(fpath):
        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

    fpath, fname = os.path.split(program)
    if fpath:
        if is_exe(program):
            return program
    else:
        for path in os.environ["PATH"].split(os.pathsep):
            path = path.strip('"')
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return exe_file

    return None 
开发者ID:BD2KGenomics,项目名称:toil-scripts,代码行数:20,代码来源:rnaseq_unc_tcga_versions.py

示例12: which

# 需要导入模块: import os [as 别名]
# 或者: from os import access [as 别名]
def which(program):
    import os

    def is_exe(f):
        return os.path.isfile(f) and os.access(f, os.X_OK)

    fpath, fname = os.path.split(program)
    if fpath:
        if is_exe(program):
            return program
    else:
        for path in os.environ["PATH"].split(os.pathsep):
            path = path.strip('"')
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return exe_file

    return None 
开发者ID:BD2KGenomics,项目名称:toil-scripts,代码行数:20,代码来源:rnaseq_unc_pipeline.py

示例13: create_floppy_image

# 需要导入模块: import os [as 别名]
# 或者: from os import access [as 别名]
def create_floppy_image(vlock_filename, floppy_image):
    """ Creates the floppy image used to install the vlock file
    """

    # Delete any existing image to start clean
    if os.access(floppy_image, os.R_OK):
        os.unlink(floppy_image)

    subprocess.check_call("mkfs.vfat -C {} 1440".format(floppy_image),
                          shell=True)

    floppy_mnt = "/tmp/mnt-dashboard"
    os.mkdir(floppy_mnt)

    subprocess.check_call("mount -o loop {} {}".format(floppy_image,
                                                       floppy_mnt),
                          shell=True)

    shutil.copy(vlock_filename, os.path.join(floppy_mnt, "versionlock.list"))

    subprocess.check_call("umount {}".format(floppy_mnt), shell=True)
    os.rmdir(floppy_mnt) 
开发者ID:dsp-jetpack,项目名称:JetPack,代码行数:24,代码来源:deploy-dashboard-vm.py

示例14: extract_file_properties

# 需要导入模块: import os [as 别名]
# 或者: from os import access [as 别名]
def extract_file_properties(self):
        """Extracts file size, 
        nb of dirs and classes in smali dir"""
        if self.verbose:
            print("------------- Extracting file properties")
            
        self.properties.file_size = os.stat(self.absolute_filename).st_size

        if self.properties.file_size < 70000:
            self.properties.file_small = True
        
        smali_dir = os.path.join(self.outdir, "smali")

        if os.access(smali_dir, os.R_OK):
            self.properties.file_nb_dir, self.properties.file_nb_classes = droidutil.count_filedirs(smali_dir)

        if self.verbose:
            print( "Filesize: %d" % (self.properties.file_size))
            print( "Is Small: %d" % (self.properties.file_small))
            print( "Nb Class: %d" % (self.properties.file_nb_classes))
            print( "Nb Dir  : %d" % (self.properties.file_nb_dir)) 
开发者ID:cryptax,项目名称:droidlysis,代码行数:23,代码来源:droidsample.py

示例15: extract_kit_properties

# 需要导入模块: import os [as 别名]
# 或者: from os import access [as 别名]
def extract_kit_properties(self):
        """
        Detects which kits are present in the sample currently analyzed
        Returns something like: ['apperhand', 'jackson', 'applovin', 'leadbolt', 'airpush']
        """
        list = []
        if self.properties.filetype == droidutil.APK or self.properties.filetype == droidutil.DEX:
            smali_dir = os.path.join(self.outdir, "smali")
            if os.access(smali_dir, os.R_OK):
                for section in self.properties.kitsconfig.get_sections():
                    pattern_list = self.properties.kitsconfig.get_pattern(section).split('|')
                    for pattern in pattern_list:
                        if os.access(os.path.join(smali_dir, pattern), os.R_OK):
                            if self.verbose:
                                print("kits[%s] = True (detected pattern: %s)" % (section, pattern))
                            list.append(section)
                            self.properties.kits[ section ] = True
                            break # break one level
        return list 
开发者ID:cryptax,项目名称:droidlysis,代码行数:21,代码来源:droidsample.py


注:本文中的os.access方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。