當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。