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


Python Log.coutValue方法代码示例

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


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

示例1: _doExecute

# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import coutValue [as 别名]
    def _doExecute(self, action):
        if not self._ainstRoot.checkRoot():
            Log.cout(Log.ERROR, 'Check ainst root failed')
            return False
        scriptContent = self._getScriptContent(action)
        if scriptContent is None:
            Log.cout(Log.ERROR, 'Get %s script of pkg %s failed' % (action, self._pkg))
            return False
        
        if self._dryRun:
            Log.coutValue(Log.INFO, '%s: ' % action, scriptContent)
            return True

        settings = self._getSettings()
        if settings is None:
            Log.cout(Log.ERROR, 'Parse settings of pkg %s  failed' % self._pkg)
            return False

        settingsEnv = self._generateSettingsEnv(settings)
        ainstDirPath = self._ainstPkgDir + '/ainst/'
        ainstPathEnv = {self._ainstDirKey : ainstDirPath}
        self._exportToEnv(ainstPathEnv)
        self._exportToEnv(settingsEnv)
        ret = self._processScript(scriptContent)
        self._removeFromEnv(settingsEnv)
        self._removeFromEnv(ainstPathEnv)

        return ret
开发者ID:luckylecher,项目名称:cpp,代码行数:30,代码来源:root_action_executor.py

示例2: makeCache

# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import coutValue [as 别名]
 def makeCache(self):
     repoList = self.getEnabledRepo()
     for repo in repoList:
         if not repo.makeCache():
             Log.coutValue(Log.INFO, repo.id, 'failed')
         else:
             Log.coutValue(Log.INFO, repo.id, 'success')
     return True
开发者ID:luckylecher,项目名称:cpp,代码行数:10,代码来源:repo_storage.py

示例3: clearCache

# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import coutValue [as 别名]
 def clearCache(self):
     repoList = self.getEnabledRepo()
     for repo in repoList:
         if not repo.clearCache():
             Log.coutValue(Log.INFO, repo.id, 'failed')
             self._consoleLogger.error(log)
         else:
             Log.coutValue(Log.INFO, repo.id, 'success')
     return True
开发者ID:luckylecher,项目名称:cpp,代码行数:11,代码来源:repo_storage.py

示例4: remoteOperate

# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import coutValue [as 别名]
    def remoteOperate(self, param, command, installRoot=None, confirmYes=False):
        if param.remoteTimeout < 0 or param.retryInterval < 0:
            Log.cout(Log.ERROR, 'Remote param is invalid')
            return False

        if param.remoteBin:
            self._ainstBinPath = param.remoteBin

        hostSet = self._getHostSet(param.host, param.hostFile)
        if hostSet:
            hostSet = set([x for x in hostSet if x and x.strip()])
        if not hostSet:
            Log.cout(Log.ERROR, 'No valid ip or host')
            return False

        user = param.remoteUser
        if not user:
            user = getpass.getuser()
        cmd = self._generateRemoteCmd(command, confirmYes, installRoot,
                                      param.remoteConf)
        if param.remoteSudo:
            cmd = 'sudo %s' % cmd

        Log.coutLabel(Log.INFO, 'Process total %d remote host' % len(hostSet))
        parallel = self._getParallelCount(param.parallel)
        successList, failedList =\
            self._doParallelOperate(hostSet, cmd, parallel, param.remoteTimeout,
                                    param.retryTime, param.retryInterval,
                                    user, param.remoteSudo, param.errorContinue)

        Log.coutLabel(Log.INFO, 'Process remote host total(%d), success(%d), failed(%d)'\
                          % (len(hostSet), len(successList), len(failedList)))
        for success in successList:
            Log.coutValue(Log.INFO, success, 'success')
        for failed in failedList:
            Log.coutValue(Log.INFO, failed, 'failed')
        Log.coutLabel(Log.INFO, 'end')
        if len(failedList) > 0:
            return False
        return True
开发者ID:luckylecher,项目名称:cpp,代码行数:42,代码来源:remote_operator.py

示例5: remoteExecute

# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import coutValue [as 别名]
    def remoteExecute(self, host, executorPath, remoteCmd, remoteUser,
                      remoteTimeout=1200, retryTime=0, retryInterval=0,
                      remoteSudo=False):
        while True:
            begin = time.time()
            Log.cout(Log.INFO, remoteCmd)
            out, err, code = process.runRedirected(remoteCmd, remoteTimeout)
            end = time.time()
            Log.cout(Log.INFO, out)
            if code == 0:
                Log.coutValue(Log.INFO, 'Process Remote host %s' % host, 'success')
                return True
            Log.cout(Log.ERROR, err)
            if end - begin >= remoteTimeout:
                Log.coutValue(Log.ERROR, 'Process Remote host %s' % host, 'timeout')
                self._killRemoteCmd(host, executorPath, remoteCmd, remoteUser, remoteSudo)
            else:
                Log.coutValue(Log.ERROR, 'Process Remote host %s' % host, 'failed')
            retryTime -= 1
            if retryTime < 0:
                break
            time.sleep(retryInterval)

        return False
开发者ID:luckylecher,项目名称:cpp,代码行数:26,代码来源:remote_operator.py

示例6: execute

# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import coutValue [as 别名]
    def execute(self):
        if self._dryRun:
            if self._unsetKeySet:
                Log.cout(Log.INFO, 'Unset pkg %s settings...' % self._pkg.name)
                for key in self._unsetKeySet:
                    Log.coutValue(Log.INFO, 'unset', key)
            return True
        if self._executed:
            return False
        self._executed = True

        if not self._ainstRoot.checkRoot():
            Log.cout(Log.ERROR, 'Check ainst root failed')
            return False

        pkgDirName = PackageUtil.getPkgNameVersion(self._pkg)
        if not pkgDirName:
            Log.cout(Log.ERROR, 'Get pkg %s dir name failed' % self._pkg)
            return False

        #get active dir and package dir
        ainstActivePkg = self._ainstRoot.getRootVarAinstDir('active') + self._pkg.name
        if not self._isActive(ainstActivePkg, pkgDirName):
            Log.cout(Log.ERROR, 'Package %s is not active' % self._pkg)
            return False
        ainstPkgDir = self._ainstRoot.getRootVarAinstDir('packages') + pkgDirName
        getRet, aicfInfo = self._getAicfInfo(ainstPkgDir, self._pkg)
        if not getRet:
            Log.cout(Log.ERROR, 'Get aicfInfo of %s failed' % self._pkg)
            return False            

        if aicfInfo is None:
            Log.cout(Log.INFO, 'No aicf, will not do effective action')
            return True

        #get settings from setting file
        settingPath = self._ainstRoot.getRootVarAinstDir('settings') + self._pkg.name
        srcSettings = SettingStreamer().parse(settingPath)
        if srcSettings is None:
            srcSettings = {}
        newSettings = self._unsetSettings(srcSettings, self._unsetKeySet)

        settingsEnv = self._generateSettingsEnv(newSettings)
        ainstDirPath = ainstPkgDir + '/ainst/'
        ainstPathEnv = {self._ainstDirKey : ainstDirPath}
        self._exportToEnv(ainstPathEnv)
        self._exportToEnv(settingsEnv)
        settingMap = {}
        settingMap.update(newSettings)
        settingMap[self._ainstRoot.getInstallRootEnvKey()] = self._ainstRoot.getRoot()
        settingMap.update(ainstPathEnv)
        ret = self._generateConfigToRoot(ainstPkgDir, aicfInfo,
                                         settingMap, self._confBakDict)
        self._removeFromEnv(settingsEnv)
        self._removeFromEnv(ainstPathEnv)

        if not ret:
            Log.cout(Log.ERROR, 'Generate config of %s to root failed' % self._pkg.name)
            self.undo()
            return False

        if not SettingStreamer().dump(newSettings, settingPath):
            Log.cout(Log.ERROR, 'Dump settings of %s failed' % self._pkg.name)
            self.undo()
            return False
        self._bakSettings = srcSettings
        return True
开发者ID:luckylecher,项目名称:cpp,代码行数:69,代码来源:root_unset_executor.py


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