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


Python path.islink方法代码示例

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


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

示例1: _configure_dbus

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import islink [as 别名]
def _configure_dbus(rest_venv):
    # link dbus-python-1.1.1-9.el7.x86_64 to the venv for `cfy status`
    # (module in pypi is very old)
    site_packages = 'lib64/python2.7/site-packages'
    dbus_relative_path = join(site_packages, 'dbus')
    dbuslib = join('/usr', dbus_relative_path)
    dbus_glib_bindings = join('/usr', site_packages, '_dbus_glib_bindings.so')
    dbus_bindings = join('/usr', site_packages, '_dbus_bindings.so')
    if isdir(dbuslib):
        dbus_venv_path = join(rest_venv, dbus_relative_path)
        if not islink(dbus_venv_path):
            utils.ln(source=dbuslib, target=dbus_venv_path, params='-sf')
            utils.ln(source=dbus_bindings, target=dbus_venv_path, params='-sf')
        if not islink(join(rest_venv, site_packages)):
            utils.ln(source=dbus_glib_bindings, target=join(
                    rest_venv, site_packages), params='-sf')
    else:
        ctx.logger.warn(
                'Could not find dbus install, cfy status will not work') 
开发者ID:cloudify-cosmo,项目名称:cloudify-manager-blueprints,代码行数:21,代码来源:create.py

示例2: get_interfaces

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import islink [as 别名]
def get_interfaces(self):
        for dev in listdir(self._scn):
            dev_path = join(self._scn, dev)
            if not (islink(dev_path) or isdir(dev_path)):
                # Skip regular files
                continue
            if not self.included_types:
                # Send metrics for all devices
                self.netdev_stat[dev] = {}
                continue
            for i_type in self.included_types:
                checks = self.NET_TYPES[i_type]
                results = []
                for check, arg in zip(checks[::2], checks[1::2]):
                    results.append(check(self, dev, arg))
                if False not in results:
                    self.netdev_stat[dev] = {} 
开发者ID:innogames,项目名称:igcollect,代码行数:19,代码来源:linux_network.py

示例3: find_ext_volume_global_trash

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import islink [as 别名]
def find_ext_volume_global_trash(volume_root):
    # from [2] Trash directories (1) check for a .Trash dir with the right
    # permissions set.
    trash_dir = op.join(volume_root, TOPDIR_TRASH)
    if not op.exists(trash_dir):
        return None
    
    mode = os.lstat(trash_dir).st_mode
    # vol/.Trash must be a directory, cannot be a symlink, and must have the
    # sticky bit set.
    if not op.isdir(trash_dir) or op.islink(trash_dir) or not (mode & stat.S_ISVTX):
        return None

    trash_dir = op.join(trash_dir, str(uid))
    try:
        check_create(trash_dir)
    except OSError:
        return None
    return trash_dir 
开发者ID:liorbenhorin,项目名称:pipeline,代码行数:21,代码来源:plat_other.py

示例4: clean

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import islink [as 别名]
def clean():
    """
    Remove previous build outputs
    """
    try:
        rmtree(path('target'))
    except FileNotFoundError:
        return
    except OSError:
        # In a docker container, target/ may be mounted so we can't delete it.
        # Delete its contents instead:
        for f in listdir(path('target')):
            fpath = join(path('target'), f)
            if isdir(fpath):
                rmtree(fpath, ignore_errors=True)
            elif isfile(fpath):
                remove(fpath)
            elif islink(fpath):
                unlink(fpath) 
开发者ID:mherrmann,项目名称:fbs,代码行数:21,代码来源:__init__.py

示例5: __init__

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import islink [as 别名]
def __init__(self, dbname=None):
        self.ibs = None
        self.expt_results = {}
        if isdir(dbname) or islink(dbname):
            dpath = abspath(dbname)
        else:
            dpath = None

        self.dbname = dbname
        self.dname = None
        self.dpath = dpath
        self.species_nice = dbname_to_species_nice(dbname)

        if self.dpath is None and dbname is not None:
            self.dname = self.dbname

            link_dname = ut.get_argval('--link', default='link')
            self.dpath = join(self.base_dpath, link_dname, self.dname) 
开发者ID:Erotemic,项目名称:ibeis,代码行数:20,代码来源:_thesis_helpers.py

示例6: scan_single_app_dir

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import islink [as 别名]
def scan_single_app_dir(self, dirroot, app, dirobject, store_app):
        for f in listdir(dirroot):
            filepath = join(dirroot,f)
            if isdir(filepath): 
                subdirobject = dirobject.add_dir(f)
                self.scan_single_app_dir(filepath, app, subdirobject, store_app)
            elif islink(filepath):
                """Skip for now"""
                continue
            elif isfile(filepath):
                try:
                    dirobject.add_file(self.handle_file(f, dirroot, app))
                    store_app.totalfiles += 1
                except:
                    print("Error handling file %(fname)s" % {'fname': join(dirroot,f)})
        return 
开发者ID:georgenicolaou,项目名称:nfi,代码行数:18,代码来源:ApplicationParser.py

示例7: scan_single_app

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import islink [as 别名]
def scan_single_app(self, approot_path, app):
        #print "[APP]: " + app.get_packagename()
        if self.outqueue != None:
            self.outqueue.put("[APP]: " + app.get_packagename())
        store_app = self.exstore.create_application(
                                app.get_packagename(), app.get_canonicalname())
        rootdir = store_app.add_directory(approot_path)
        store_app.add_root_stats( os.stat(approot_path) )
        for f in listdir(approot_path):
            filepath = join(approot_path,f)
            if isdir(filepath):
                dirobject = rootdir.add_dir(f)
                self.scan_single_app_dir(filepath, app, dirobject, store_app)
            elif islink(filepath):
                if filepath.endswith("lib"):
                    store_app.set_library_path(self.read_link(filepath))
            elif isfile(filepath):
                store_app.totalfiles += 1
                rootdir.add_file(self.handle_file(f,approot_path,app))
        return 
开发者ID:georgenicolaou,项目名称:nfi,代码行数:22,代码来源:ApplicationParser.py

示例8: remove_dead_links

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import islink [as 别名]
def remove_dead_links(directory, verbose=0):
    """recursivly traverse directory and remove all dead links

    :type directory: str
    :param directory: directory to cleanup

    :type verbose: bool
    :param verbose:
      flag indicating wether information about deleted links should be
      printed to stderr, default to False
    """
    def _remove_dead_link(_, directory, fnames):
        """walk handler"""
        for filename in fnames:
            src = join(directory, filename)
            if islink(src) and not exists(src):
                if verbose:
                    print('remove dead link', src)
                remove(src)
    walk(directory, _remove_dead_link, None) 
开发者ID:jlachowski,项目名称:clonedigger,代码行数:22,代码来源:fileutils.py

示例9: is_git_dir

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import islink [as 别名]
def is_git_dir(self):
        '''
        判断是否为git目录

        @param path:
        @return:
        '''
        d = self.path + '/.git'
        if osp.isdir(d):
            if osp.isdir(osp.join(d, 'objects')) and osp.isdir(osp.join(d, 'refs')):
                headref = osp.join(d, 'HEAD')
                return osp.isfile(headref) or \
                       (osp.islink(headref) and
                        os.readlink(headref).startswith('refs'))
            elif (osp.isfile(osp.join(d, 'gitdir')) and
                  osp.isfile(osp.join(d, 'commondir')) and
                  osp.isfile(osp.join(d, 'gitfile'))):
                return False
        return False 
开发者ID:meolu,项目名称:walle-web,代码行数:21,代码来源:repo.py

示例10: find_ext_volume_global_trash

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import islink [as 别名]
def find_ext_volume_global_trash(volume_root):
    # from [2] Trash directories (1) check for a .Trash dir with the right
    # permissions set.
    trash_dir = op.join(volume_root, TOPDIR_TRASH)
    if not op.exists(trash_dir):
        return None

    mode = os.lstat(trash_dir).st_mode
    # vol/.Trash must be a directory, cannot be a symlink, and must have the
    # sticky bit set.
    if not op.isdir(trash_dir) or op.islink(trash_dir) or not (mode & stat.S_ISVTX):
        return None

    trash_dir = op.join(trash_dir, text_type(uid).encode('ascii'))
    try:
        check_create(trash_dir)
    except OSError:
        return None
    return trash_dir 
开发者ID:snuq,项目名称:Snu-Photo-Manager,代码行数:21,代码来源:plat_other.py

示例11: _link

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import islink [as 别名]
def _link(src, dst, linktype=LINK_HARD):
    if linktype == LINK_HARD:
        if on_win:
            win_hard_link(src, dst)
        else:
            os.link(src, dst)
    elif linktype == LINK_SOFT:
        if on_win:
            win_soft_link(src, dst)
        else:
            os.symlink(src, dst)
    elif linktype == LINK_COPY:
        # copy relative symlinks as symlinks
        if not on_win and islink(src) and not os.readlink(src).startswith('/'):
            os.symlink(os.readlink(src), dst)
        else:
            shutil.copy2(src, dst)
    else:
        raise Exception("Did not expect linktype=%r" % linktype) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:21,代码来源:install.py

示例12: run

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import islink [as 别名]
def run(self):
        testpath = 'src/test'
        buildlink = 'build/lib/test'

        if isdir(dirname(buildlink)):
            if islink(buildlink):
                os.unlink(buildlink)

            os.symlink(relpath(testpath, dirname(buildlink)), buildlink)
            testpath = buildlink

        try:
            os.environ['EPYTHON'] = 'python{}.{}'.format(sys.version_info.major, sys.version_info.minor)
            subprocess.check_call(['py.test', '-v', testpath, '-s',
                        '--cov-report=html', '--cov-report=term-missing'] +
                       (['-k', self.match] if self.match else []) +
                       ['--cov={}'.format(p) for p in find_packages(dirname(testpath), exclude=['test'])])

        finally:
            if islink(buildlink):
                os.unlink(buildlink) 
开发者ID:rqlite,项目名称:pyrqlite,代码行数:23,代码来源:setup.py

示例13: get_fuzz_outdirs

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import islink [as 别名]
def get_fuzz_outdirs(macke_directory):
    fuzzdir = path.join(macke_directory, "fuzzer")
    if not path.isdir(path.join(macke_directory, "fuzzer")):
        return []

    result = []
    prefix = "fuzz_out_"

    for f in listdir(fuzzdir):
        if not f.startswith(prefix):
            continue
        fpath = path.join(fuzzdir, f)
        function = f[len(prefix):]
        if path.islink(fpath) or not path.isdir(fpath):
            continue
        result.append((function, fpath))

    return result 
开发者ID:tum-i22,项目名称:macke,代码行数:20,代码来源:helper.py

示例14: is_git_dir

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import islink [as 别名]
def is_git_dir(d):
    """ This is taken from the git setup.c:is_git_directory
    function.

    @throws WorkTreeRepositoryUnsupported if it sees a worktree directory. It's quite hacky to do that here,
            but at least clearly indicates that we don't support it.
            There is the unlikely danger to throw if we see directories which just look like a worktree dir,
            but are none."""
    if osp.isdir(d):
        if osp.isdir(osp.join(d, 'objects')) and osp.isdir(osp.join(d, 'refs')):
            headref = osp.join(d, 'HEAD')
            return osp.isfile(headref) or \
                (osp.islink(headref) and
                 os.readlink(headref).startswith('refs'))
        elif (osp.isfile(osp.join(d, 'gitdir')) and
              osp.isfile(osp.join(d, 'commondir')) and
              osp.isfile(osp.join(d, 'gitfile'))):
            raise WorkTreeRepositoryUnsupported(d)
    return False 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:21,代码来源:fun.py

示例15: decideClean

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import islink [as 别名]
def decideClean(workDir, architecture, aggressiveCleanup):
  """ Decides what to delete, without actually doing it:
      - Find all the symlinks in "BUILD"
      - Find all the directories in "BUILD"
      - Schedule a directory for deletion if it does not have a symlink
  """
  symlinksBuild = [os.readlink(x) for x in glob.glob("%s/BUILD/*-latest*" % workDir)]
  # $WORK_DIR/TMP should always be cleaned up. This does not happen only
  # in the case we run out of space while unpacking.
  # $WORK_DIR/<architecture>/store can be cleaned up as well, because
  # we do not need the actual tarballs after they have been built.
  toDelete = ["%s/TMP" % workDir]
  if aggressiveCleanup:
    toDelete += ["%s/TARS/%s/store" % (workDir, architecture),
                 "%s/SOURCES" % (workDir)]
  allBuildStuff = glob.glob("%s/BUILD/*" % workDir)
  toDelete += [x for x in allBuildStuff
               if not path.islink(x) and not basename(x) in symlinksBuild]
  installGlob ="%s/%s/*/" % (workDir, architecture)
  installedPackages = set([dirname(x) for x in glob.glob(installGlob)])
  symlinksInstall = []
  for x in installedPackages:
    symlinksInstall += [path.realpath(y) for y in glob.glob(x + "/latest*")]
  toDelete += [x for x in glob.glob(installGlob+ "*")
               if not path.islink(x) and not path.realpath(x) in symlinksInstall]
  toDelete = [x for x in toDelete if path.exists(x)]
  return toDelete 
开发者ID:alisw,项目名称:alibuild,代码行数:29,代码来源:clean.py


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