本文整理匯總了Python中logger.logger.Logger.warn方法的典型用法代碼示例。如果您正苦於以下問題:Python Logger.warn方法的具體用法?Python Logger.warn怎麽用?Python Logger.warn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類logger.logger.Logger
的用法示例。
在下文中一共展示了Logger.warn方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from logger.logger import Logger [as 別名]
# 或者: from logger.logger.Logger import warn [as 別名]
#.........這裏部分代碼省略.........
delay = float(file.readlines()[0].strip())
compare = self.compare_values[ii]
delta = delay - compare[1]
delta_abs = abs(delta)
delta_rel = round((delta_abs * 100 / compare[1]), 2)
self.log.debug("Delay for Temperatur %s: \texpected: %s \tcomputed: %s" % (compare[0], compare[1], delay))
self.log.debug("Delta: %s \tabs: %s \trelative: %s%%" % (delta, delta_abs, delta_rel))
self.results.append([delay, compare[1]])
def _restart(self, p, max_tries):
"""
Restarts process if number of max_tries has not been passed.
"""
if p[5] >= max_tries:
self.log.error("kiva in '%s' failed on the %s. try." % (p[1], p[5]))
p[2] = False
p[3].close() # close log file
p[4].close() # close error file
return False
else:
# clean up runXX dir
for node in os.listdir(p[1]):
if node not in self.kiva_parameter_files:
os.unlink(os.path.join(p[1], node))
# increment ties
p[5] = p[5] + 1
# print message to log
msg = "\n%s. Try -------------------------------------------\n" % p[5]
p[3].write(msg)
p[4].write(msg)
# restart p
kiva = os.path.abspath(os.path.join(self.kiva_path, self.kiva_name))
p[0] = subprocess.Popen(kiva, cwd=p[1], stdout=p[3], stderr=p[4])
self.log.warn("kiva in '%s' restarted for it's %s. try." % (p[1], p[5]))
return True
def run(self, time_out=120, max_tries=5):
"""
Executes kiva with current parameter set.
Once for every compare_value.
"""
if not self._setupWorkingDir():
return False
# Start one kiva process for every folder
processes = []
# devnull = open('/dev/null', 'w')
kiva = os.path.abspath(os.path.join(self.kiva_path, self.kiva_name))
for ii in range(0, len(self.compare_values)):
log = os.path.join(self.working_dir, 'run' + str(ii) + '.log')
log_file = open(log, 'w')
error = os.path.join(self.working_dir, 'run' + str(ii) + '.error')
error_file = open(error, 'w')
d = os.path.join(self.working_dir, 'run' + str(ii))
p = subprocess.Popen(kiva, cwd=d, stdout=log_file, stderr=error_file)
# process, path, running, log_file, error_file, tries
processes.append([p, d, True, log_file, error_file, 1])
self.log.debug("kiva in '%s' spawned." % d)
# Check for all kiva processes to terminate
all_finished = False
start_time = time.time()
while not all_finished:
all_finished = True
for p in processes:
if p[2]:
if p[0].poll() == 0:
self.log.debug("kiva in '%s' terminated." % p[1])