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


Python fsutils.rmRf函数代码示例

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


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


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