• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python fsutils.rmRf函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中yotta.lib.fsutils.rmRf函数的典型用法代码示例。如果您正苦于以下问题:Python rmRf函数的具体用法?Python rmRf怎么用?Python rmRf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_targetAppConfigMerge

    def test_targetAppConfigMerge(self):
        test_dir = self.writeTestFiles(Test_Target_Config_Merge_App, True)

        os.chdir(test_dir)
        c = validate.currentDirectoryModule()
        target, errors = c.satisfyTarget("bar,")
        merged_config = target.getMergedConfig()

        self.assertIn("foo", merged_config)
        self.assertIn("bar", merged_config)
        self.assertIn("new", merged_config)
        self.assertIn("a", merged_config["foo"])
        self.assertIn("b", merged_config["foo"])
        self.assertIn("c", merged_config["foo"])
        self.assertEqual(merged_config["foo"]["a"], 321)
        self.assertEqual(merged_config["foo"]["b"], 456)
        self.assertEqual(merged_config["foo"]["c"], 112233)
        self.assertIn("bar", merged_config)
        self.assertIn("d", merged_config["bar"])
        self.assertEqual(merged_config["bar"]["d"], "ghi")
        self.assertIn("new", merged_config)
        self.assertEqual(merged_config["new"], 123)

        os.chdir(self.restore_cwd)
        rmRf(test_dir)
开发者ID:ntoll,项目名称:yotta,代码行数:25,代码来源:config.py


示例2: execCommand

def execCommand(args, following_args):
    if args.link_target:
        c = validate.currentDirectoryModule()
        if not c:
            return 1
        err = validate.targetNameValidationError(args.link_target)
        if err:
            logging.error(err)
            return 1
        fsutils.mkDirP(os.path.join(os.getcwd(), 'yotta_targets'))
        src = os.path.join(folders.globalTargetInstallDirectory(), args.link_target)
        dst = os.path.join(os.getcwd(), 'yotta_targets', args.link_target)
        # if the target is already installed, rm it
        fsutils.rmRf(dst)
    else:
        t = validate.currentDirectoryTarget()
        if not t:
            return 1
        fsutils.mkDirP(folders.globalTargetInstallDirectory())
        src = os.getcwd()
        dst = os.path.join(folders.globalTargetInstallDirectory(), t.getName())

    if args.link_target:
        realsrc = fsutils.realpath(src)
        if src == realsrc:
            logging.warning(
              ('%s -> %s -> ' % (dst, src)) + colorama.Fore.RED + 'BROKEN' + colorama.Fore.RESET #pylint: disable=no-member
            )
        else:
            logging.info('%s -> %s -> %s' % (dst, src, realsrc))
    else:
        logging.info('%s -> %s' % (dst, src))
    fsutils.symlink(src, dst)
开发者ID:kushaldas,项目名称:yotta,代码行数:33,代码来源:link_target.py


示例3: satisfyVersionFromSearchPaths

def satisfyVersionFromSearchPaths(name, version_required, search_paths, update=False, type='module', inherit_shrinkwrap=None):
    ''' returns a Component/Target for the specified version, if found in the
        list of search paths. If `update' is True, then also check for newer
        versions of the found component, and update it in-place (unless it was
        installed via a symlink).
    '''
    # Pack, , base class for targets and components, internal
    from yotta.lib import pack

    v = None
    try:
        sv = sourceparse.parseSourceURL(version_required)
    except ValueError as e:
        logging.error(e)
        return None

    try:
        local_version = searchPathsFor(
            name,
            sv.semanticSpec(),
            search_paths,
            type,
            inherit_shrinkwrap = inherit_shrinkwrap
        )
    except pack.InvalidDescription as e:
        logger.error(e)
        return None

    logger.debug("%s %s locally" % (('found', 'not found')[not local_version], name))
    if local_version:
        if update and not local_version.installedLinked():
            #logger.debug('attempt to check latest version of %s @%s...' % (name, version_required))
            v = latestSuitableVersion(name, version_required, registry=_registryNamespaceForType(type))
            if local_version:
                local_version.setLatestAvailable(v)

        # if we don't need to update, then we're done
        if local_version.installedLinked() or not local_version.outdated():
            logger.debug("satisfy component from directory: %s" % local_version.path)
            # if a component exists (has a valid description file), and either is
            # not outdated, or we are not updating
            if name != local_version.getName():
                raise Exception('Component %s found in incorrectly named directory %s (%s)' % (
                    local_version.getName(), name, local_version.path
                ))
            return local_version

        # otherwise, we need to update the installed component
        logger.info('update outdated: %[email protected]%s -> %s' % (
            name,
            local_version.getVersion(),
            v
        ))
        # must rm the old component before continuing
        fsutils.rmRf(local_version.path)
        return _satisfyVersionByInstallingVersion(
            name, version_required, local_version.path, v, type=type, inherit_shrinkwrap=inherit_shrinkwrap
        )
    return None
开发者ID:ARMmbed,项目名称:yotta,代码行数:59,代码来源:access.py


示例4: test_outdated

    def test_outdated(self):
        path = self.writeTestFiles(Test_Outdated, True)
        
        stdout, stderr, statuscode = cli.run(['-t', 'x86-linux-native', 'outdated'], cwd=path)
        self.assertNotEqual(statuscode, 0)
        self.assertIn('test-testing-dummy', stdout + stderr)

        rmRf(path)
开发者ID:ntoll,项目名称:yotta,代码行数:8,代码来源:outdated.py


示例5: tearDownClass

 def tearDownClass(cls):
     rmRf(cls.test_dir)
     cls.test_dir = None
     if cls.saved_settings_dir is not None:
         os.environ['YOTTA_USER_SETTINGS_DIR'] = cls.saved_settings_dir
         cls.saved_settings_dir = None
     else:
         del os.environ['YOTTA_USER_SETTINGS_DIR']
开发者ID:BlackstoneEngineering,项目名称:yotta,代码行数:8,代码来源:account.py


示例6: test_testOutputFilterNotFound

 def test_testOutputFilterNotFound(self):
     test_dir = self.writeTestFiles(Test_Fitler_NotFound, True)
     stdout, stderr, statuscode = cli.run(['--target', systemDefaultTarget(), 'test'], cwd=test_dir)
     if statuscode == 0:
         print(stdout)
         print(stderr)
     self.assertNotEqual(statuscode, 0)
     rmRf(test_dir)
开发者ID:BlackstoneEngineering,项目名称:yotta,代码行数:8,代码来源:test.py


示例7: test_updateExplicit

    def test_updateExplicit(self):
        path = self.writeTestFiles(Test_Outdated, True)

        stdout, stderr, statuscode = cli.run(['-t', 'x86-linux-native', 'update', 'test-testing-dummy'], cwd=path)
        self.assertEqual(statuscode, 0)
        self.assertIn('download test-testing-dummy', stdout + stderr)

        rmRf(path)
开发者ID:BlackstoneEngineering,项目名称:yotta,代码行数:8,代码来源:update.py


示例8: rmLinkOrDirectory

def rmLinkOrDirectory(path, nonexistent_warning):
    if not os.path.exists(path):
        logging.warning(nonexistent_warning)
        return 1
    if fsutils.isLink(path):
        fsutils.rmF(path)
    else:
        fsutils.rmRf(path)
    return 0
开发者ID:ARMmbed,项目名称:yotta,代码行数:9,代码来源:remove.py


示例9: test_buildTests

 def test_buildTests(self):
     test_dir = self.writeTestFiles(Test_Tests, True)
     stdout = self.runCheckCommand(['--target', systemDefaultTarget(), 'build'], test_dir)
     stdout = self.runCheckCommand(['--target', systemDefaultTarget(), 'test'], test_dir)
     self.assertIn('test-a', stdout)
     self.assertIn('test-c', stdout)
     self.assertIn('test-d', stdout)
     self.assertIn('test-e', stdout)
     self.assertIn('test-f', stdout)
     self.assertIn('test-g', stdout)
     rmRf(test_dir)
开发者ID:BlackstoneEngineering,项目名称:yotta,代码行数:11,代码来源:build.py


示例10: test_setTarget

 def test_setTarget(self):
     rmRf(os.path.join(self.test_dir, '.yotta.json'))
     stdout = self.runCheckCommand(['target', 'testtarget', '-g'])
     stdout = self.runCheckCommand(['target'])
     self.assertTrue(stdout.find('testtarget') != -1)
     stdout = self.runCheckCommand(['target', 'x86-linux-native', '-g'])
     if os.name == 'posix':
         # check that the settings file was created with the right permissions
         self.assertFalse(
             os.stat(os.path.join(os.path.expanduser('~'), '.yotta', 'config.json')).st_mode & Check_Not_Stat
         )
开发者ID:danros,项目名称:yotta,代码行数:11,代码来源:target.py


示例11: unpackInto

    def unpackInto(self, directory):
        logger.debug('unpack version %s from hg repo %s to %s' % (self.version, self.working_copy.directory, directory))
        if self.isTip():
            tag = None
        else:
            tag = self.tag
        fsutils.rmRf(directory)
        vcs.HG.cloneToDirectory(self.working_copy.directory, directory, tag)

        # remove temporary files created by the HGWorkingCopy clone
        self.working_copy.remove()
开发者ID:ARMmbed,项目名称:yotta,代码行数:11,代码来源:hg_access.py


示例12: test_tests

 def test_tests(self):
     test_dir = self.writeTestFiles(Test_Tests, True)
     output = self.runCheckCommand(['--target', systemDefaultTarget(), 'build'], test_dir)
     output = self.runCheckCommand(['--target', systemDefaultTarget(), 'test'], test_dir)
     self.assertIn('test-a passed', output)
     self.assertIn('test-c passed', output)
     self.assertIn('test-d passed', output)
     self.assertIn('test-e passed', output)
     self.assertIn('test-f passed', output)
     self.assertIn('test-g passed', output)
     rmRf(test_dir)
开发者ID:BlackstoneEngineering,项目名称:yotta,代码行数:11,代码来源:test.py


示例13: test_uninstallNonExistent

    def test_uninstallNonExistent(self):
        test_dir = tempfile.mkdtemp()
        with open(os.path.join(test_dir, 'module.json'), 'w') as f:
            f.write(Test_Module_JSON)
        stdout = self.runCheckCommand(['--target', Test_Target, 'install'], test_dir)
        self.assertTrue(os.path.exists(os.path.join(test_dir, 'yotta_modules', 'testing-dummy')))

        stdout, stderr, statuscode = cli.run(['uninstall', 'nonexistent'], cwd=test_dir)
        self.assertNotEqual(statuscode, 0)

        rmRf(test_dir)
开发者ID:BlackstoneEngineering,项目名称:yotta,代码行数:11,代码来源:install.py


示例14: unpackInto

    def unpackInto(self, directory):
        # vcs, , represent version controlled directories, internal
        from yotta.lib import vcs
        # fsutils, , misc filesystem utils, internal
        from yotta.lib import fsutils
        logger.debug('unpack version %s from git repo %s to %s' % (self.version, self.working_copy.directory, directory))
        tag = self.tag
        fsutils.rmRf(directory)
        vcs.Git.cloneToDirectory(self.working_copy.directory, directory, tag)

        # remove temporary files created by the GitWorkingCopy clone
        self.working_copy.remove()
开发者ID:DaMouse404,项目名称:yotta,代码行数:12,代码来源:git_access.py


示例15: test_moduleConfigIgnored

    def test_moduleConfigIgnored(self):
        test_dir = self.writeTestFiles(Test_Module_Config_Ignored, True)

        os.chdir(test_dir)
        c = validate.currentDirectoryModule()
        target, errors = c.satisfyTarget("bar,")
        merged_config = target.getMergedConfig()

        self.assertNotIn("new", merged_config)

        os.chdir(self.restore_cwd)
        rmRf(test_dir)
开发者ID:ntoll,项目名称:yotta,代码行数:12,代码来源:config.py


示例16: test_installAllTestDeps

    def test_installAllTestDeps(self):
        test_dir = tempfile.mkdtemp()
        with open(os.path.join(test_dir, 'module.json'), 'w') as f:
            f.write(Test_Module_JSON)
        stdout = self.runCheckCommand(['--target', Test_Target, 'install', '--test-dependencies', 'all'], test_dir)

        # also sanity-check listing:
        stdout = self.runCheckCommand(['--target', Test_Target, 'ls', '-a'], test_dir)
        self.assertIn('testmod', stdout)
        self.assertIn('other-testing-dummy', stdout)
        self.assertIn('test-testing-dummy', stdout)
        self.assertIn('test-target-dep', stdout)
        self.assertNotIn('missing', stdout)
        rmRf(test_dir)
开发者ID:BlackstoneEngineering,项目名称:yotta,代码行数:14,代码来源:install.py


示例17: test_uninstall

    def test_uninstall(self):
        test_dir = tempfile.mkdtemp()
        with open(os.path.join(test_dir, 'module.json'), 'w') as f:
            f.write(Test_Module_JSON)
        stdout = self.runCheckCommand(['--target', Test_Target, 'install'], test_dir)
        self.assertTrue(os.path.exists(os.path.join(test_dir, 'yotta_modules', 'testing-dummy')))

        self.runCheckCommand(['uninstall', 'testing-dummy'], test_dir)
        self.assertFalse(os.path.exists(os.path.join(test_dir, 'yotta_modules', 'testing-dummy')))

        stdout = self.runCheckCommand(['--target', Test_Target, 'ls', '-a'], test_dir)
        self.assertNotIn(' testing-dummy', stdout)

        rmRf(test_dir)
开发者ID:BlackstoneEngineering,项目名称:yotta,代码行数:14,代码来源:install.py


示例18: test_testOutputFilterFailing

 def test_testOutputFilterFailing(self):
     test_dir = self.writeTestFiles(Test_Fitler_Fail, True)
     stdout, stderr, statuscode = cli.run(['--target', systemDefaultTarget(), 'test'], cwd=test_dir)
     if statuscode == 0:
         print(stdout)
         print(stderr)
     self.assertIn('test-a failed', '%s %s' % (stdout, stderr))
     self.assertIn('test-c failed', '%s %s' % (stdout, stderr))
     self.assertIn('test-d failed', '%s %s' % (stdout, stderr))
     self.assertIn('test-e failed', '%s %s' % (stdout, stderr))
     self.assertIn('test-f failed', '%s %s' % (stdout, stderr))
     self.assertIn('test-g failed', '%s %s' % (stdout, stderr))
     self.assertNotEqual(statuscode, 0)
     rmRf(test_dir)
开发者ID:BlackstoneEngineering,项目名称:yotta,代码行数:14,代码来源:test.py


示例19: test_default_ignores

    def test_default_ignores(self):
        default_test_dir = writeTestFiles(Default_Test_Files)
        c = component.Component(default_test_dir)
        self.assertTrue(c.ignores('.something.c.swp'))
        self.assertTrue(c.ignores('.something.c~'))
        self.assertTrue(c.ignores('path/to/.something.c.swm'))
        self.assertTrue(c.ignores('path/to/.something.c~'))
        self.assertTrue(c.ignores('.DS_Store'))
        self.assertTrue(c.ignores('.git'))
        self.assertTrue(c.ignores('.hg'))
        self.assertTrue(c.ignores('.svn'))
        self.assertTrue(c.ignores('yotta_modules'))
        self.assertTrue(c.ignores('yotta_targets'))
        self.assertTrue(c.ignores('build'))
        self.assertTrue(c.ignores('.yotta.json'))

        rmRf(default_test_dir)
开发者ID:BlackstoneEngineering,项目名称:yotta,代码行数:17,代码来源:ignores.py


示例20: unpackFrom

def unpackFrom(tar_file_path, to_directory):
    # first unpack into a sibling directory of the specified directory, and
    # then move it into place.

    # we expect our tarballs to contain a single top-level directory. We strip
    # off this name as we extract to minimise the path length

    into_parent_dir = os.path.dirname(to_directory)
    fsutils.mkDirP(into_parent_dir)
    temp_directory = tempfile.mkdtemp(dir=into_parent_dir)
    try:
        with tarfile.open(tar_file_path) as tf:
            strip_dirname = ''
            # get the extraction directory name from the first part of the
            # extraction paths: it should be the same for all members of
            # the archive
            for m in tf.getmembers():
                split_path = fsutils.fullySplitPath(m.name)
                logger.debug('process member: %s %s', m.name, split_path)
                if os.path.isabs(m.name) or '..' in split_path:
                    raise ValueError('archive uses invalid paths')
                if not strip_dirname:
                    if len(split_path) != 1 or not len(split_path[0]):
                        raise ValueError('archive does not appear to contain a single module')
                    strip_dirname = split_path[0]
                    continue
                else:
                    if split_path[0] != strip_dirname:
                        raise ValueError('archive does not appear to contain a single module')
                m.name = os.path.join(*split_path[1:])
                tf.extract(m, path=temp_directory)
        # make sure the destination directory doesn't exist:
        fsutils.rmRf(to_directory)
        shutil.move(temp_directory, to_directory)
        temp_directory = None
        logger.debug('extraction complete %s', to_directory)
    except IOError as e:
        if e.errno != errno.ENOENT:
            logger.error('failed to extract tarfile %s', e)
            fsutils.rmF(tar_file_path)
        raise
    finally:
        if temp_directory is not None:
            # if anything has failed, cleanup
            fsutils.rmRf(temp_directory)
开发者ID:kushaldas,项目名称:yotta,代码行数:45,代码来源:access_common.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cli.run函数代码示例发布时间:2022-05-26
下一篇:
Python tui.addInputAnswers函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap