本文整理汇总了Python中logger.Log.cout方法的典型用法代码示例。如果您正苦于以下问题:Python Log.cout方法的具体用法?Python Log.cout怎么用?Python Log.cout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logger.Log
的用法示例。
在下文中一共展示了Log.cout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _queue
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import cout [as 别名]
def _queue(self, pkgQueue, context, depth):
if len(pkgQueue) == 0:
return error.ERROR_NONE
Log.cout(Log.DEBUG, self._outputTrace(depth, "queue"))
ret = error.ERROR_NONE
while True:
tmpQueue, hasSuccess = list(), False
while len(pkgQueue) > 0:
item = pkgQueue.pop(0)
if item[0] == INSTALL:
ret = self._handleInstallItem(pkgQueue, item, context, depth)
elif item[0] == REMOVE:
ret = self._handleRemoveItem(pkgQueue,item, context, depth)
if ret == error.ERROR_NONE:
hasSuccess = True
elif ret == error.ERROR_EXCLUSIVE_DEPS:
tmpQueue.append(item)
else:
opt = 'Handle'
if item[0] == INSTALL:
opt = 'Install'
elif item[0] == REMOVE:
opt = 'Remove'
content = self._outputTrace(depth, '%s pkg %s failed' % (opt, item[1]))
Log.cout(Log.ERROR, content)
return ret
if len(tmpQueue) == 0:
return error.ERROR_NONE
if not hasSuccess:
return error.ERROR_EXCLUSIVE_DEPS
pkgQueue.extend(tmpQueue)
return ret
示例2: _doFetch
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import cout [as 别名]
def _doFetch(self, url):
socket.setdefaulttimeout(self.timeout)
try:
request = urllib2.Request(url)
response = urllib2.urlopen(request)
chunked = self._isChunked(response)
content = ''
if not chunked:
length = int(response.info().getheader('Content-Length'))
if length > self.maxFileLength:
return FetchError.FETCH_TOO_LARGE, None
content = response.read()
else:
length = 0
while True:
line = response.readline(self.lineLength)
if not line:
break
content += line
length += len(line)
if length > self.maxFileLength:
return FetchError.FETCH_TOO_LARGE, None
response.close()
return FetchError.FETCH_SUCCESS, content
except Exception, e:
Log.cout(Log.ERROR, 'Fetch failed: %s' % e)
if hasattr(e, 'reason'):
if str(e.reason) == 'timed out':
return FetchError.FETCH_TIMEOUT, None
return FetchError.FETCH_OTHER_ERROR, None
示例3: _doHandleSameProvidePkg
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import cout [as 别名]
def _doHandleSameProvidePkg(self, pkg, context, pkgQueue, depth):
"""
If installed package with same name and can not coexist,
we need to remove old package.
"""
ts, excludes = context.ts, context.excludes
for provide in pkg.provides:
providers = self._getByProvide(Provide(name=provide.name), context)
installedPkgs = []
for package in providers:
if package is pkg:
continue
if not ts.installed(package):
excludes.exclude(package)
else:
installedPkgs.append(package)
for package in installedPkgs:
coexists, notSatisfiedPkgs = self.coexists(pkg, provide, package, context)
if coexists:
continue
if not self._checkSamePkgWithOption(pkg, package, context, depth):
return error.ERROR_INSTALL, None
ret = self._remove(package, context, pkgQueue, depth + 1)
if ret != error.ERROR_NONE:
logInfo = self._outputTrace(depth, 'Handle same provide between %s and %s failed' % (pkg, package))
Log.cout(Log.ERROR, logInfo)
return ret, notSatisfiedPkgs
self._addDependency(pkg, package, context, 'remove')
return error.ERROR_NONE, None
示例4: _check
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import cout [as 别名]
def _check(self, pkg, context, pkgQueue, depth):
Log.cout(Log.DEBUG, self._outputTrace(depth, 'check(%s)' % pkg))
ts, excludes = context.ts, context.excludes
ret = error.ERROR_NONE
context.checkedPkgs.add(pkg)
requireDict = ResolverHelper.getAndMergeRequires(pkg)
#May be need sort this require.
items = self._sortRequireByName(requireDict)
for name, requires in items:
prvpkgs = self._getByProvides(requires, context)
if pkg in prvpkgs:
continue
prvpkgs = ResolverHelper.filterPkgByRequires(prvpkgs, requireDict)
prvpkg = self._getBestInstalledProvide(pkg, prvpkgs, context)
if prvpkg is not None:
ret = self._doCheck(prvpkg, context, pkgQueue, depth)
if ret != error.ERROR_NONE:
return ret
if self._needUpgradeLocalProvide(pkg, name, prvpkg, context):
self._upgradeLocalProvide(pkg, requires, prvpkgs, context, pkgQueue)
continue
if context.initOperation == CHECK:
return error.ERROR_CHECK
prvpkgs = self._filterAndSortPackages(prvpkgs, pkg)
pkgQueue.append((INSTALL, pkg, requires, prvpkgs))
return error.ERROR_NONE
示例5: iterate
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import cout [as 别名]
def iterate(self):
outdegrees, depDict = dict(), dict()
for package in self.preDict:
prerequisites = self.preDict[package]
if package not in outdegrees:
outdegrees[package] = 0
for prerequisite in prerequisites:
if prerequisite is not None:
outdegrees[package] += 1
if prerequisite not in outdegrees:
outdegrees[prerequisite] = 0
depDict.setdefault(prerequisite, set()).add(package)
stack = [x for x in outdegrees if outdegrees[x] == 0]
count = 0
while len(stack) > 0:
package = stack.pop(0)
count = count + 1
yield package
for dependent in depDict.get(package, []):
outdegrees[dependent] -= 1
if outdegrees[dependent] <= 0:
stack.append(dependent)
if count != len(outdegrees):
printDegreees = dict()
for pkg in outdegrees:
if outdegrees[pkg] != 0:
printDegreees[pkg] = outdegrees[pkg]
Log.cout(Log.DEBUG, printDegreees)
raise DependencyGraph.CycleDependencyException, "cycle dependent"
示例6: _checkInstall
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import cout [as 别名]
def _checkInstall(self, pkg, context, pkgQueue, depth):
Log.cout(Log.DEBUG, self._outputTrace(depth, "checkInstall(%s)" % pkg))
if depth > self.MAX_DEPTH:
return error.ERROR_INSTALL
context.ts.setOperation(pkg, INSTALL)
context.excludes.exclude(pkg)
if not pkg.installed():
ret = self._checkConflictAndProvide(pkg, context, pkgQueue, depth)
if ret != error.ERROR_NONE:
return ret
requireDict = ResolverHelper.getAndMergeRequires(pkg)
for name, requires in requireDict.items():
prvpkgs = self._getByProvides(requires, context)
prvpkg = self._getBestInstalledProvide(pkg, prvpkgs, context)
if not prvpkg:
return error.ERROR_NONE
if prvpkg is pkg:
continue
if context.excludes.excluded(prvpkg):
self._addDependency(pkg, prvpkg, context, 'install')
continue
if self.getInstallDir(prvpkg) == self.installRoot:
ret = self._checkInstall(prvpkg, context, pkgQueue, depth + 1)
if ret != error.ERROR_NONE:
Log.cout(Log.ERROR, 'Check install package %s failed' % prvpkg)
return ret
self._addDependency(pkg, prvpkg, context, 'install')
return error.ERROR_NONE
示例7: writeToFp
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import cout [as 别名]
def writeToFp(fp, content):
try:
fp.write(content)
fp.flush()
except Exception, e:
Log.cout(Log.DEBUG, 'Write to fp failed: %s' % e)
return False
示例8: readLink
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import cout [as 别名]
def readLink(path):
try:
if isLink(path):
return os.readlink(path)
except Exception, e:
Log.cout(Log.DEBUG, 'readlink %s failed: %s' % (path, e))
return None
示例9: _generateConfigToRoot
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import cout [as 别名]
def _generateConfigToRoot(self, ainstPkgDir, aicfInfo, settingMap, confDict):
if aicfInfo:
for path, configInfo in aicfInfo.configs.iteritems():
srcConfigPath = ainstPkgDir + '/' + path
destConfigPath = self._ainstRoot.getRoot() + '/' + path
if not file_util.isFile(srcConfigPath):
Log.cout(Log.ERROR, 'Config file %s is not exists' % srcConfigPath)
return False
if not file_util.exists(destConfigPath):
Log.cout(Log.ERROR, 'Dest config file %s is not exists' % destConfigPath)
return False
tmpDirName = self._ainstRoot.getRootVarAinstDir('tmp')
tmpPath = tmpDirName + '/' + os.path.basename(destConfigPath) + '.tmp.set'
if not file_util.move(destConfigPath, tmpPath):
Log.cout(Log.ERROR, 'Backup config file %s failed' % destConfigPath)
return False
confDict[path] = (tmpPath, destConfigPath)
configGenerator = ConfigGenerator()
if not configGenerator.generateConfig(srcConfigPath,
destConfigPath,
configInfo.mode,
configInfo.noReplace,
settingMap):
Log.cout(Log.ERROR, 'Generate Config file %s failed' % path)
return False
else:
Log.cout(Log.DEBUG, 'No aicf file, so no config will be changed')
return True
示例10: _getMetaFile
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import cout [as 别名]
def _getMetaFile(self, repoMdObj, metaName, fileName):
if not repoMdObj.repoMdDatas.has_key(metaName):
return False
metaObj = repoMdObj.repoMdDatas[metaName]
destTmpFile = self._getRepoDataDir() + '/' + \
metaObj.locationHref.split('/')[-1]
metaUrl = self.repoConfig.baseurl + '/' + metaObj.locationHref
# uncompressTmpFile = '.'.join(destTmpFile.split('.')[:-1]) + '.tmp'
uncompressTmpFile = self._getRepoDataDir() + '/' + \
fileName + '.tmp'
if not file_util.remove(destTmpFile) or\
not file_util.remove(uncompressTmpFile):
return False
if not self.fileFetcher.fetch(metaUrl, destTmpFile) or\
not file_util.chmod(destTmpFile, 0666):
return False
try:
if destTmpFile.split('.')[-1] == 'bz2':
f = bz2.BZ2File(destTmpFile)
else:
f = gzip.open(destTmpFile)
if not file_util.writeToFile(uncompressTmpFile, f.read()) or\
not file_util.chmod(uncompressTmpFile, 0666):
f.close()
return False
f.close()
except Exception:
Log.cout(Log.ERROR, 'decompress %s failed' % destTmpFile)
return False
return self._checkSumValid(metaObj, uncompressTmpFile)
示例11: _killRemoteCmd
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import cout [as 别名]
def _killRemoteCmd(self, host, executorPath, cmdStr, remoteUser, remoteSudo):
pathIndex = cmdStr.find(executorPath)
if pathIndex == -1:
return False
rawCmd = cmdStr[pathIndex:]
rawCmd = ' '.join(rawCmd.split())
Log.cout(Log.INFO, 'kill ainst2 process on the remote host %s ...' % host)
cmd = 'ssh %[email protected]%s ps -efw | grep \'%s\' | grep -v \'ssh %[email protected]%s\' | grep -v grep'\
% (remoteUser, host, rawCmd, remoteUser, host)
out, err, code = process.runRedirected(cmd, self._killTimeout)
if code != 0:
Log.cout(Log.ERROR, 'get remote pid failed')
return False
pidList = []
contentList = out.split('\n')
for content in contentList:
if not content or not content.strip():
continue
items = content.split()
pidList.append(items[1])
if not pidList:
return True
pidSet = set(pidList)
index = 0
while index < len(pidList):
subPidList = self._getSubPidList(remoteUser, host, pidList[index])
for subPid in subPidList:
if subPid not in pidSet:
pidList.append(subPid)
pidSet.add(subPid)
index += 1
return self._killRemotePid(pidList, remoteUser, host, remoteSudo)
示例12: _generateConfigByExpand
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import cout [as 别名]
def _generateConfigByExpand(self, srcPath, destPath, noReplace, settings):
content = file_util.readFromFile(srcPath)
if content is None:
Log.cout(Log.ERROR, 'Read config file %s failed' % srcPath)
return False
replacer = KeyValueReplacer(settings)
content = replacer.replace(content)
return file_util.writeToFile(destPath, content)
示例13: getDirNameByIndex
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import cout [as 别名]
def getDirNameByIndex(self, index):
if not self._header:
Log.cout(Log.ERROR, 'Get dir name failed')
return None
dirListLength = len(self._getDirs())
if index > dirListLength:
Log.cout(Log.ERROR, 'Get dir name failed')
return None
return self._getDirs()[index]
示例14: _selectInstallPkgs
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import cout [as 别名]
def _selectInstallPkgs(self, context, pkgs):
installPkgs = []
for pkg in pkgs:
installPkg = self._selectPkg(context, pkg)
if installPkg == None:
Log.cout(Log.ERROR, 'No packages %s available. Abort Installation.' % pkg)
return None
installPkgs.append(installPkg)
return installPkgs
示例15: rpm2dir
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import cout [as 别名]
def rpm2dir(rpmPath, destDir, timeout=600):
currentWorkdir = os.getcwd()
if not file_util.isDir(destDir) and not file_util.makeDir(destDir):
Log.cout(Log.ERROR, 'Make rpm dir %s failed' % destDir)
return False
try:
os.chdir(destDir)
except OSError, e:
return False