Python os.symlink() Examples

The following are 30 code examples of os.symlink(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module os , or try the search function .
Example #1
Source File: factory-package-news-web.py    From openSUSE-release-tools with GNU General Public License v2.0 6 votes vote down vote up
def current():
    _dir = get_dir(request.url_root)
    fn = os.path.join(_dir, 'current')
    if request.method == 'POST':
        if not 'version' in request.form:
            return "missing version", 400
        version = request.form['version']
        if not digits_re.match(version):
            return "malformed version", 400
        if not os.path.exists(os.path.join(_dir, version)):
            return "invalid version", 400
        tmpfn = os.path.join(_dir, '.' + version)
        app.logger.debug(tmpfn)
        if os.path.exists(tmpfn):
            os.unlink(tmpfn)
        os.symlink(version, tmpfn)
        os.rename(tmpfn, fn)
        return "ok"
    else:
        if not os.path.exists(fn):
            return "", 404
        return os.readlink(fn) 
Example #2
Source File: mtime_file_watcher_test.py    From browserscope with Apache License 2.0 6 votes vote down vote up
def test_symlink(self):
    sym_target = os.path.join(self._directory, 'test')
    os.mkdir(os.path.join(self._junk_directory, 'subdir'))
    self._watcher.start()
    self._watcher._has_changed_paths()

    # Check that an added symlinked directory is reported.
    os.symlink(self._junk_directory, sym_target)
    self.assertTrue(self._watcher._has_changed_paths())

    # Check that a file added to the symlinked directory is reported.
    with open(os.path.join(self._junk_directory, 'file1'), 'w'):
      pass
    self.assertTrue(self._watcher._has_changed_paths())

    # Check that a removed symlinked directory is reported.
    os.remove(sym_target)
    self.assertTrue(self._watcher._has_changed_paths())

    # Check that a file added to the removed symlinked directory is *not*
    # reported.
    with open(os.path.join(self._junk_directory, 'subdir', 'file2'), 'w'):
      pass
    self.assertFalse(self._watcher._has_changed_paths()) 
Example #3
Source File: structured3d_prepare_dataset.py    From HorizonNet with MIT License 6 votes vote down vote up
def prepare_dataset(scene_ids, out_dir):
    root_img = os.path.join(out_dir, 'img')
    root_cor = os.path.join(out_dir, 'label_cor')
    os.makedirs(root_img, exist_ok=True)
    os.makedirs(root_cor, exist_ok=True)
    for scene_id in tqdm(scene_ids):
        source_img_root = os.path.join(args.in_root, scene_id, 'rgb')
        source_cor_root = os.path.join(args.in_root, scene_id, 'layout')
        for fname in os.listdir(source_cor_root):
            room_id = fname.split('_')[0]
            source_img_path = os.path.join(args.in_root, scene_id, 'rgb', room_id + '_rgb_rawlight.png')
            source_cor_path = os.path.join(args.in_root, scene_id, 'layout', room_id + '_layout.txt')
            target_img_path = os.path.join(root_img, '%s_%s.png' % (scene_id, room_id))
            target_cor_path = os.path.join(root_cor, '%s_%s.txt' % (scene_id, room_id))
            assert os.path.isfile(source_img_path)
            assert os.path.isfile(source_cor_path)
            os.symlink(source_img_path, target_img_path)
            os.symlink(source_cor_path, target_cor_path) 
Example #4
Source File: test_interpreters.py    From tox with MIT License 6 votes vote down vote up
def test_find_alias_on_path(monkeypatch, tmp_path, mocker):
    reporter.update_default_reporter(Verbosity.DEFAULT, Verbosity.DEBUG)
    magic = tmp_path / "magic{}".format(os.path.splitext(sys.executable)[1])
    os.symlink(sys.executable, str(magic))
    monkeypatch.setenv(
        str("PATH"),
        os.pathsep.join([str(tmp_path)] + os.environ.get(str("PATH"), "").split(os.pathsep)),
    )

    class envconfig:
        basepython = "magic"
        envname = "pyxx"
        config = mocker.MagicMock()
        config.return_value.option.return_value.discover = []

    detected = py.path.local.sysfind("magic")
    assert detected

    t = tox_get_python_executable(envconfig).lower()
    assert t == str(magic).lower() 
Example #5
Source File: main.py    From pwnypack with MIT License 6 votes vote down vote up
def symlink(parser, cmd, args):
    """
    Set up symlinks for (a subset of) the pwny apps.
    """

    parser.add_argument(
        'apps',
        nargs=argparse.REMAINDER,
        help='Which apps to create symlinks for.'
    )
    args = parser.parse_args(args)

    base_dir, pwny_main = os.path.split(sys.argv[0])

    for app_name, config in MAIN_FUNCTIONS.items():
        if not config['symlink'] or (args.apps and app_name not in args.apps):
            continue
        dest = os.path.join(base_dir, app_name)
        if not os.path.exists(dest):
            print('Creating symlink %s' % dest)
            os.symlink(pwny_main, dest)
        else:
            print('Not creating symlink %s (file already exists)' % dest) 
Example #6
Source File: utils.py    From cycleGAN-PyTorch with MIT License 6 votes vote down vote up
def create_link(dataset_dir):
    dirs = {}
    dirs['trainA'] = os.path.join(dataset_dir, 'ltrainA')
    dirs['trainB'] = os.path.join(dataset_dir, 'ltrainB')
    dirs['testA'] = os.path.join(dataset_dir, 'ltestA')
    dirs['testB'] = os.path.join(dataset_dir, 'ltestB')
    mkdir(dirs.values())

    for key in dirs:
        try:
            os.remove(os.path.join(dirs[key], 'Link'))
        except:
            pass
        os.symlink(os.path.abspath(os.path.join(dataset_dir, key)),
                   os.path.join(dirs[key], 'Link'))

    return dirs 
Example #7
Source File: test_smbclient_shutil.py    From smbprotocol with MIT License 6 votes vote down vote up
def test_rmtree_symlink_as_dir(smb_share):
    src_dirname = "%s\\dir" % smb_share
    dst_dirname = "%s\\target" % smb_share
    mkdir(src_dirname)
    symlink("dir", dst_dirname)

    expected = "Cannot call rmtree on a symbolic link"
    with pytest.raises(OSError, match=re.escape(expected)):
        rmtree(dst_dirname)

    assert exists(src_dirname)
    assert exists(dst_dirname)

    rmtree(dst_dirname, ignore_errors=True)

    callback_args = []

    def callback(*args):
        callback_args.append(args)

    rmtree(dst_dirname, onerror=callback)
    assert len(callback_args) == 1
    assert callback_args[0][0].__name__ == 'islink'
    assert callback_args[0][1] == dst_dirname
    assert isinstance(callback_args[0][2][1], OSError) 
Example #8
Source File: test_smbclient_shutil.py    From smbprotocol with MIT License 6 votes vote down vote up
def test_rmtree(smb_share):
    mkdir("%s\\dir2" % smb_share)
    mkdir("%s\\dir2\\dir3" % smb_share)

    with open_file("%s\\dir2\\dir3\\file1" % smb_share, mode='w') as fd:
        fd.write(u"content")

    with open_file("%s\\dir2\\file2" % smb_share, mode='w') as fd:
        fd.write(u"content")

    if os.name == "nt" or os.environ.get('SMB_FORCE', False):
        # File symlink
        symlink("%s\\dir2\\file2" % smb_share, "%s\\dir2\\file3" % smb_share)
        symlink("missing", "%s\\dir2\\file3-broken" % smb_share)

        # Dir symlink
        symlink("%s\\dir2\\dir3" % smb_share, "%s\\dir2\\dir-link" % smb_share)
        symlink("missing", "%s\\dir2\\dir-link-broken" % smb_share, target_is_directory=True)

    assert exists("%s\\dir2" % smb_share) is True

    rmtree("%s\\dir2" % smb_share)

    assert exists("%s\\dir2" % smb_share) is False 
Example #9
Source File: solver.py    From 3D-R2N2 with MIT License 6 votes vote down vote up
def save(self, training_losses, save_dir, step):
        ''' Save the current network parameters to the save_dir and make a
        symlink to the latest param so that the training function can easily
        load the latest model'''
        save_path = os.path.join(save_dir, 'weights.%d' % (step))
        self.net.save(save_path)

        # Make a symlink for weights.npy
        symlink_path = os.path.join(save_dir, 'weights.npy')
        if os.path.lexists(symlink_path):
            os.remove(symlink_path)

        # Make a symlink to the latest network params
        os.symlink("%s.npy" % os.path.abspath(save_path), symlink_path)

        # Write the losses
        with open(os.path.join(save_dir, 'loss.%d.txt' % step), 'w') as f:
            f.write('\n'.join([str(l) for l in training_losses])) 
Example #10
Source File: test_smbclient_shutil.py    From smbprotocol with MIT License 6 votes vote down vote up
def test_copytree_with_broken_symlink_fail(smb_share):
    src_dirname = "%s\\source" % smb_share
    dst_dirname = "%s\\target" % smb_share

    mkdir(src_dirname)
    symlink("%s\\dir" % src_dirname, "%s\\link" % src_dirname, target_is_directory=True)
    symlink("%s\\file.txt" % src_dirname, "%s\\link.txt" % src_dirname)

    with pytest.raises(shutil.Error) as actual:
        copytree(src_dirname, dst_dirname)

    assert len(actual.value.args[0]) == 2
    err1 = actual.value.args[0][0]
    err2 = actual.value.args[0][1]

    assert err1[0] == "%s\\link" % src_dirname
    assert err1[1] == "%s\\link" % dst_dirname
    assert "No such file or directory" in err1[2]

    assert err2[0] == "%s\\link.txt" % src_dirname
    assert err2[1] == "%s\\link.txt" % dst_dirname
    assert "No such file or directory" in err2[2] 
Example #11
Source File: pagure_ticket_hook.py    From pagure with GNU General Public License v2.0 6 votes vote down vote up
def set_up(cls, project):
        """ Install the generic post-receive hook that allow us to call
        multiple post-receive hooks as set per plugin.
        """
        repopath = os.path.join(pagure_config["TICKETS_FOLDER"], project.path)
        if not os.path.exists(repopath):
            raise FileNotFoundException("No such file: %s" % repopath)

        hook_files = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), "files"
        )

        # Make sure the hooks folder exists
        hookfolder = os.path.join(repopath, "hooks")
        if not os.path.exists(hookfolder):
            os.makedirs(hookfolder)

        # Install the main post-receive file
        postreceive = os.path.join(hookfolder, "post-receive")
        hook_file = os.path.join(hook_files, "post-receive")
        if not os.path.exists(postreceive):
            os.symlink(hook_file, postreceive) 
Example #12
Source File: test_ciftify_pint_vertices.py    From ciftify with MIT License 6 votes vote down vote up
def fake_ciftify_work_dir():
    '''link in files to mode a ciftify work dir so that qc pages can be generated'''
    with ciftify.utils.TempDir() as ciftify_wd:
        # create a temp outputdir
        subject = "sub-50005"
        surfs_dir = os.path.join(ciftify_wd, subject, 'MNINonLinear', 'fsaverage_LR32k')
        run(['mkdir', '-p', surfs_dir])
        os.symlink(left_surface, os.path.join(surfs_dir, 'sub-50005.L.midthickness.32k_fs_LR.surf.gii'))
        os.symlink(right_surface, os.path.join(surfs_dir, 'sub-50005.R.midthickness.32k_fs_LR.surf.gii'))
        for hemi in ['L', 'R']:
            old_path = os.path.join(ciftify.config.find_ciftify_global(),
                'HCP_S1200_GroupAvg_v1',
                'S1200.{}.very_inflated_MSMAll.32k_fs_LR.surf.gii'.format(hemi))
            new_path = os.path.join(surfs_dir,
            'sub-50005.{}.very_inflated.32k_fs_LR.surf.gii'.format(hemi))
            os.symlink(old_path, new_path)
        yield ciftify_wd 
Example #13
Source File: test_smbclient_shutil.py    From smbprotocol with MIT License 6 votes vote down vote up
def test_copystat_local_to_local_symlink_dont_follow_fail(tmpdir):
    test_dir = tmpdir.mkdir('test')
    src_filename = "%s\\source.txt" % test_dir
    dst_filename = "%s\\target.txt" % test_dir

    with open(src_filename, mode='w') as fd:
        fd.write(u"content")
    os.chmod(src_filename, stat.S_IREAD)

    with open(dst_filename, mode='w') as fd:
        fd.write(u"content")

    src_link = "%s\\source-link.txt" % test_dir
    dst_link = "%s\\target-link.txt" % test_dir

    os.symlink(src_filename, src_link)
    os.symlink(dst_filename, dst_link)

    expected = "follow_symlinks unavailable on this platform"
    with pytest.raises(NotImplementedError, match=re.escape(expected)):
        copystat(src_link, dst_link, follow_symlinks=False) 
Example #14
Source File: postinstall_simnibs.py    From simnibs with GNU General Public License v3.0 6 votes vote down vote up
def links_setup(install_dir):
    if sys.platform == 'win32':
        _create_shortcut(
            os.path.join(install_dir, 'examples'),
            os.path.join(SIMNIBSDIR, 'examples')
        )
        _create_shortcut(
            os.path.join(install_dir, 'simnibs'),
            os.path.join(SIMNIBSDIR)
        )
    else:
        lnk = os.path.join(install_dir, 'examples')
        if os.path.islink(lnk):
            os.remove(lnk)
        os.symlink(os.path.join(SIMNIBSDIR, 'examples'), lnk)
        lnk = os.path.join(install_dir, 'simnibs')
        if os.path.islink(lnk):
            os.remove(lnk)
        os.symlink(SIMNIBSDIR, lnk) 
Example #15
Source File: materialize_emoji_images.py    From apple-emoji-linux with Apache License 2.0 6 votes vote down vote up
def _alias_omitted_flags(code_strings, dst):
  UNKNOWN_FLAG = 'fe82b'
  if UNKNOWN_FLAG not in code_strings:
    print('unknown flag missing', file=os.stderr)
    return
  dst_name = 'emoji_u%s.png' % UNKNOWN_FLAG
  dst_path = path.join(dst, dst_name)
  for ali in sorted(OMITTED_FLAGS):
    ali_str = _flag_str(ali)
    if ali_str in code_strings:
      print('omitted flag %s has image %s' % (ali, ali_str), file=os.stderr)
      continue
    ali_name = 'emoji_u%s.png' % ali_str
    print('creating symlink %s (%s) -> unknown_flag (%s)' % (
        ali_str, ali, dst_name))
    os.symlink(dst_path, path.join(dst, ali_name)) 
Example #16
Source File: test_smbclient_shutil.py    From smbprotocol with MIT License 6 votes vote down vote up
def test_copymode_local_to_local_symlink_dont_follow(tmpdir):
    test_dir = tmpdir.mkdir('test')
    src_filename = "%s\\source.txt" % test_dir
    dst_filename = "%s\\target.txt" % test_dir

    with open(src_filename, mode='w') as fd:
        fd.write(u"content")
    os.chmod(src_filename, stat.S_IREAD)

    with open(dst_filename, mode='w') as fd:
        fd.write(u"content")

    src_link = "%s\\source-link.txt" % test_dir
    dst_link = "%s\\target-link.txt" % test_dir

    os.symlink(src_filename, src_link)
    os.symlink(dst_filename, dst_link)

    expected = "chmod: follow_symlinks unavailable on this platform"
    with pytest.raises(NotImplementedError, match=re.escape(expected)):
        copymode(src_link, dst_link, follow_symlinks=False) 
Example #17
Source File: pi-timolo.py    From pi-timolo with MIT License 6 votes vote down vote up
def saveRecent(recentMax, recentDir, filename, prefix):
    """
    Create a symlink file in recent folder (timelapse or motion subfolder)
    Delete Oldest symlink file if recentMax exceeded.
    """
    src = os.path.abspath(filename)  # original file path
    dest = os.path.abspath(os.path.join(recentDir,
                                        os.path.basename(filename)))
    deleteOldFiles(recentMax, os.path.abspath(recentDir), prefix)
    try:    # Create symlink in recent folder
        logging.info('symlink %s', dest)
        os.symlink(src, dest)  # Create a symlink to actual file
    except OSError as err:
        logging.error('symlink %s to %s  err: %s', dest, src, err)

#------------------------------------------------------------------------------ 
Example #18
Source File: tarfile.py    From recruit with Apache License 2.0 6 votes vote down vote up
def _find_link_target(self, tarinfo):
        """Find the target member of a symlink or hardlink member in the
           archive.
        """
        if tarinfo.issym():
            # Always search the entire archive.
            linkname = os.path.dirname(tarinfo.name) + "/" + tarinfo.linkname
            limit = None
        else:
            # Search the archive before the link, because a hard link is
            # just a reference to an already archived file.
            linkname = tarinfo.linkname
            limit = tarinfo

        member = self._getmember(linkname, tarinfo=limit, normalize=True)
        if member is None:
            raise KeyError("linkname %r not found" % linkname)
        return member 
Example #19
Source File: test_smbclient_shutil.py    From smbprotocol with MIT License 6 votes vote down vote up
def test_copyfile_symlink_dont_follow(smb_share):
    src_filename = "%s\\source.txt" % smb_share
    src_link = "%s\\source-link.txt" % smb_share
    dst_filename = "%s\\target.txt" % smb_share

    with open_file(src_filename, mode='w') as fd:
        fd.write(u"content")

    symlink(src_filename, src_link)
    actual = copyfile(src_link, dst_filename, follow_symlinks=False)
    assert actual == dst_filename

    with open_file(dst_filename, mode='r') as fd:
        assert fd.read() == u"content"

    assert islink(dst_filename)
    assert readlink(dst_filename) == ntpath.normpath(src_filename) 
Example #20
Source File: test_smbclient_shutil.py    From smbprotocol with MIT License 6 votes vote down vote up
def test_copyfile_symlink_follow(smb_share):
    src_filename = "%s\\source.txt" % smb_share
    src_link = "%s\\source-link.txt" % smb_share
    dst_filename = "%s\\target.txt" % smb_share

    with open_file(src_filename, mode='w') as fd:
        fd.write(u"content")

    symlink(src_filename, src_link)
    actual = copyfile(src_link, dst_filename)
    assert actual == dst_filename

    with open_file(dst_filename, mode='r') as fd:
        assert fd.read() == u"content"

    assert not islink(dst_filename) 
Example #21
Source File: test_wheelies.py    From delocate with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def test_fix_rpath():
    # Test wheels which have an @rpath dependency
    # Also verifies the delocated libraries signature
    with InTemporaryDirectory():
        # The module was set to expect its dependency in the libs/ directory
        os.symlink(DATA_PATH, 'libs')

        stray_lib = realpath('libs/libextfunc_rpath.dylib')
        with InWheel(RPATH_WHEEL):
            # dep_mod can vary depending the Python version used to build
            # the test wheel
            dep_mod = 'fakepkg/subpkg/module2.so'
        dep_path = '@rpath/libextfunc_rpath.dylib'

        assert_equal(
            delocate_wheel(RPATH_WHEEL, 'tmp.whl'),
            {stray_lib: {dep_mod: dep_path}},
        )
        with InWheel('tmp.whl'):
            check_call(['codesign', '--verify',
                        'fakepkg/.dylibs/libextfunc_rpath.dylib']) 
Example #22
Source File: mgcluster.py    From CAMISIM with Apache License 2.0 6 votes vote down vote up
def _get_symbolic_link_path(self, original_file_path):
		"""
		Get path to local symbolic link since mothur might act odd else.

		@param original_file_path:
		@type original_file_path: str | unicode

		@return: Local path
		@rtype: str | unicode
		"""
		assert isinstance(original_file_path, basestring)
		basename = os.path.basename(original_file_path)
		new_path = os.path.join(self._tmp_dir, basename)
		os.symlink(original_file_path, new_path)
		# return new_path
		return basename 
Example #23
Source File: link_pyqt.py    From qutebrowser with GNU General Public License v3.0 5 votes vote down vote up
def copy_or_link(source, dest):
    """Copy or symlink source to dest."""
    if os.name == 'nt':
        if os.path.isdir(source):
            print('{} -> {}'.format(source, dest))
            shutil.copytree(source, dest, ignore=get_ignored_files,
                            copy_function=verbose_copy)
        else:
            print('{} -> {}'.format(source, dest))
            shutil.copy(source, dest)
    else:
        print('{} -> {}'.format(source, dest))
        os.symlink(source, dest) 
Example #24
Source File: test_local.py    From py with MIT License 5 votes vote down vote up
def test_make_numbered_dir_NotImplemented_Error(self, tmpdir, monkeypatch):
        def notimpl(x, y):
            raise NotImplementedError(42)
        monkeypatch.setattr(os, 'symlink', notimpl)
        x = tmpdir.make_numbered_dir(rootdir=tmpdir, lock_timeout=0)
        assert x.relto(tmpdir)
        assert x.check() 
Example #25
Source File: build_release.py    From qutebrowser with GNU General Public License v3.0 5 votes vote down vote up
def patch_mac_app():
    """Patch .app to use our Info.plist and save some space."""
    app_path = os.path.join('dist', 'qutebrowser.app')

    # Patch Info.plist - pyinstaller's options are too limiting
    plist_path = os.path.join(app_path, 'Contents', 'Info.plist')
    with open(plist_path, "rb") as f:
        plist_data = plistlib.load(f)
    plist_data.update(INFO_PLIST_UPDATES)
    with open(plist_path, "wb") as f:
        plistlib.dump(plist_data, f)

    # Replace some duplicate files by symlinks
    framework_path = os.path.join(app_path, 'Contents', 'MacOS', 'PyQt5',
                                  'Qt', 'lib', 'QtWebEngineCore.framework')

    core_lib = os.path.join(framework_path, 'Versions', '5', 'QtWebEngineCore')
    os.remove(core_lib)
    core_target = os.path.join(*[os.pardir] * 7, 'MacOS', 'QtWebEngineCore')
    os.symlink(core_target, core_lib)

    framework_resource_path = os.path.join(framework_path, 'Resources')
    for name in os.listdir(framework_resource_path):
        file_path = os.path.join(framework_resource_path, name)
        target = os.path.join(*[os.pardir] * 5, name)
        if os.path.isdir(file_path):
            shutil.rmtree(file_path)
        else:
            os.remove(file_path)
        os.symlink(target, file_path) 
Example #26
Source File: symlinklockfile.py    From recruit with Apache License 2.0 5 votes vote down vote up
def acquire(self, timeout=None):
        # Hopefully unnecessary for symlink.
        # try:
        #     open(self.unique_name, "wb").close()
        # except IOError:
        #     raise LockFailed("failed to create %s" % self.unique_name)
        timeout = timeout if timeout is not None else self.timeout
        end_time = time.time()
        if timeout is not None and timeout > 0:
            end_time += timeout

        while True:
            # Try and create a symbolic link to it.
            try:
                os.symlink(self.unique_name, self.lock_file)
            except OSError:
                # Link creation failed.  Maybe we've double-locked?
                if self.i_am_locking():
                    # Linked to out unique name. Proceed.
                    return
                else:
                    # Otherwise the lock creation failed.
                    if timeout is not None and time.time() > end_time:
                        if timeout > 0:
                            raise LockTimeout("Timeout waiting to acquire"
                                              " lock for %s" %
                                              self.path)
                        else:
                            raise AlreadyLocked("%s is already locked" %
                                                self.path)
                    time.sleep(timeout / 10 if timeout is not None else 0.1)
            else:
                # Link creation succeeded.  We're good to go.
                return 
Example #27
Source File: support.py    From verge3d-blender-addon with GNU General Public License v3.0 5 votes vote down vote up
def skip_unless_symlink(test):
    """Skip decorator for tests that require functional symlink"""
    ok = can_symlink()
    msg = "Requires functional symlink implementation"
    return test if ok else unittest.skip(msg)(test) 
Example #28
Source File: test_local.py    From py with MIT License 5 votes vote down vote up
def test_samefile_symlink(tmpdir):
    p1 = tmpdir.ensure("foo.txt")
    p2 = tmpdir.join("linked.txt")
    try:
        os.symlink(str(p1), str(p2))
    except OSError as e:
        # on Windows this might fail if the user doesn't have special symlink permissions
        pytest.skip(str(e.args[0]))

    assert p1.samefile(p2) 
Example #29
Source File: test_builder.py    From conda-build-all with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_follow_symlink(self):
        link_dir = self.tmp_dir(prefix='recipes_through_links')
        os.symlink(os.path.join(self.recipes_root_dir, 'd1'),
                os.path.join(link_dir, 'd1'))
        os.symlink(os.path.join(self.recipes_root_dir, 'm1'),
                os.path.join(link_dir, 'm1'))
        metas = list_metas(link_dir)
        names = [meta.name() for meta in metas]
        self.assertEqual(sorted(names), ['m1', 'm3']) 
Example #30
Source File: local.py    From py with MIT License 5 votes vote down vote up
def mksymlinkto(self, value, absolute=1):
        """ create a symbolic link with the given value (pointing to another name). """
        if absolute:
            py.error.checked_call(os.symlink, str(value), self.strpath)
        else:
            base = self.common(value)
            # with posix local paths '/' is always a common base
            relsource = self.__class__(value).relto(base)
            reldest = self.relto(base)
            n = reldest.count(self.sep)
            target = self.sep.join(('..', )*n + (relsource, ))
            py.error.checked_call(os.symlink, target, self.strpath)