本文整理汇总了Python中logger.Log.coutLabel方法的典型用法代码示例。如果您正苦于以下问题:Python Log.coutLabel方法的具体用法?Python Log.coutLabel怎么用?Python Log.coutLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logger.Log
的用法示例。
在下文中一共展示了Log.coutLabel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _doParallelOperate
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import coutLabel [as 别名]
def _doParallelOperate(self, hostSet, cmd, parallel, remoteTimeout, retryTime,
retryInterval, user, remoteSudo, errorContinue):
successList = []
failedList = []
if not hostSet:
return successList, failedList
count = 0
hostLen = len(hostSet)
threaderList = []
for host in hostSet:
Log.coutLabel(Log.INFO, 'Process Remote host:%s' % host)
remoteCmd = 'ssh %[email protected]%s %s' % (user, host, cmd)
threader = RemoteOperatorThread(host, self._ainstBinPath, remoteCmd,
remoteTimeout, retryTime,
retryInterval, user, remoteSudo)
threader.setDaemon(True)
threaderList.append(threader)
threader.start()
count += 1
if count % parallel != 0 and count < hostLen:
continue
for threader in threaderList:
threader.join()
for threader in threaderList:
if not threader.returnValue:
failedList.append(threader.host)
else:
successList.append(threader.host)
if not errorContinue and len(failedList) > 0:
break
threaderList = []
return successList, failedList
示例2: remoteOperate
# 需要导入模块: from logger import Log [as 别名]
# 或者: from logger.Log import coutLabel [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