本文整理汇总了Python中logger.logger.error方法的典型用法代码示例。如果您正苦于以下问题:Python logger.error方法的具体用法?Python logger.error怎么用?Python logger.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logger.logger
的用法示例。
在下文中一共展示了logger.error方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from logger import logger [as 别名]
# 或者: from logger.logger import error [as 别名]
def run(self):
# ???????
_results = []
results = []
for i in range(self._test_case_info["test_case_number"]):
_results.append(self._pool.apply_async(_run, (self, i + 1)))
self._pool.close()
self._pool.join()
for item in _results:
# ????????????get()????????
# http://stackoverflow.com/questions/22094852/how-to-catch-exceptions-in-workers-in-multiprocessing
try:
results.append(item.get())
except Exception as e:
logger.error("system error")
logger.error(e)
results.append({"result": result["system_error"]})
return results
示例2: load
# 需要导入模块: from logger import logger [as 别名]
# 或者: from logger.logger import error [as 别名]
def load(path):
try:
with open(path, 'r') as reader:
logger.info("Loading text from file %s" % path)
return reader.read()
except IOError as ex:
logger.error("Could not load text from file %s - %s" % (path, ex))
return ''
示例3: run
# 需要导入模块: from logger import logger [as 别名]
# 或者: from logger.logger import error [as 别名]
def run(self, proxies):
# ??gevent????
if not self.ip:
logger.error('Validating fail, self ip is empty')
return []
avaliable_proxies = filter(lambda x: x, self.pool.map(self.validate, proxies))
logger.info('Get %s avaliable proxies' % len(avaliable_proxies))
return avaliable_proxies
示例4: __init__
# 需要导入模块: from logger import logger [as 别名]
# 或者: from logger.logger import error [as 别名]
def __init__(self, request, client_address, server):
try:
self.sqlite = DatabaseObject(DB_CONFIG['SQLITE'])
self.table_name = 'proxy'
except Exception, e:
self.sqlite = ''
logger.error('SQLite error: %s', e)
BaseHTTPRequestHandler.__init__(self, request, client_address, server)
示例5: _load_test_case_info
# 需要导入模块: from logger import logger [as 别名]
# 或者: from logger.logger import error [as 别名]
def _load_test_case_info(self):
# ???????? ???dict
try:
f = open(os.path.join(self._test_case_dir, "info"))
return json.loads(f.read())
except IOError:
raise JudgeClientError("Test case config file not found")
except ValueError:
raise JudgeClientError("Test case config file format error")
示例6: compile_
# 需要导入模块: from logger import logger [as 别名]
# 或者: from logger.logger import error [as 别名]
def compile_(language_item, src_path, exe_path, judge_base_path, compile_spj=False):
command_item = "spj_compile_command" if compile_spj else "compile_command"
compile_command = language_item[command_item].format(src_path=src_path, exe_path=exe_path).split(" ")
compiler = compile_command[0]
compile_args = compile_command[1:]
compiler_output_file = os.path.join(judge_base_path, "compiler.out")
compile_result = judger.run(path=compiler,
in_file="/dev/null",
out_file=compiler_output_file,
max_cpu_time=language_item["compile_max_cpu_time"],
max_memory=language_item["compile_max_memory"],
args=compile_args,
env=["PATH=" + os.environ["PATH"]],
use_sandbox=False,
use_nobody=True)
compile_output_handler = open(compiler_output_file)
compile_output = compile_output_handler.read().strip()
compile_output_handler.close()
if compile_result["flag"] != 0:
logger.error("Compiler error")
logger.error(compile_output)
logger.error(str(compile_result))
if compile_output:
raise CompileError(compile_output)
else:
raise CompileError("Compile error, info: " + str(compile_result))
else:
if "error" in compile_output:
raise CompileError(compile_output)
return exe_path
示例7: checkCommand
# 需要导入模块: from logger import logger [as 别名]
# 或者: from logger.logger import error [as 别名]
def checkCommand():
for name in Commands:
logger.info('checking requirement: %s' % name)
if name in os.popen('which ' + name.strip()).read():
logger.info('success!')
else:
logger.error('failed! please install with "apt-get/yum" manually: %s ' % name)
# TODO
示例8: convert_bootcamp_data
# 需要导入模块: from logger import logger [as 别名]
# 或者: from logger.logger import error [as 别名]
def convert_bootcamp_data(slug):
"""Convert a bootcamp's folder from the old format to the new."""
success = True
# Rename existing folder as `slug`-legacy
legacy_folder = '{}/{}-legacy'.format(BOOTCAMPS_FOLDER_LOCAL, slug)
shutil.move(
'{}/{}/'.format(BOOTCAMPS_FOLDER_LOCAL, slug),
legacy_folder)
# Create new empty `slug` folder
os.mkdir('{}/{}'.format(BOOTCAMPS_FOLDER_LOCAL, slug))
# Copy logo over to new folder
shutil.copy(
'{}/logo.png'.format(legacy_folder),
'{}/{}/logo.png'.format(BOOTCAMPS_FOLDER_LOCAL, slug))
# Compile bootcamp's and its programs' data.yml and description.md files
# into one and write back to single data.yml file in new folder
with open('{}/data.yml'.format(legacy_folder), 'r') as f:
data = yaml.load(f.read())
with open(
'{}/description.md'.format(legacy_folder), 'r') as f:
description = f.read()
data.update({'description': u'{}'.format(description.decode('utf-8'))})
data.update({'programs': {}})
data.pop('slug', None)
all_programs = os.listdir('{}/programs'.format(legacy_folder))
for program in all_programs:
try:
program_slug, program_dict = convert_program_data(slug, program)
data['programs'][program_slug] = program_dict
except AssertionError as exc:
success = False
logger.error(
'[convert_bootcamp_data] Error in program {} for {}: '
'{}'.format(slug, program, exc))
with open('{}/{}/data.yml'.format(BOOTCAMPS_FOLDER_LOCAL, slug), 'w') as f:
yaml.dump(data, f, default_flow_style=False)
# Remove legacy folder if successful
if success:
shutil.rmtree(legacy_folder)
return success
示例9: _judge_one
# 需要导入模块: from logger import logger [as 别名]
# 或者: from logger.logger import error [as 别名]
def _judge_one(self, test_case_id):
in_file = os.path.join(self._test_case_dir, str(test_case_id) + ".in")
out_file = os.path.join(self._judge_base_path, str(test_case_id) + ".out")
run_result = judger.run(path=self.execute_command[0],
max_cpu_time=self._max_cpu_time,
max_memory=self._max_memory,
in_file=in_file,
out_file=out_file,
args=self.execute_command[1:],
env=["PATH=" + os.environ["PATH"]],
use_sandbox=self._language["use_sandbox"],
use_nobody=True)
run_result["test_case"] = test_case_id
# ?Java?????, ??__init__?????
if self._language["name"] == "java" and run_result["memory"] > self._real_max_memory * 1.5:
run_result["flag"] = 3
# ?judger?????????????????
if run_result["flag"] == 0:
if self._spj_path is None:
output_md5, r = self._compare_output(test_case_id)
if r:
run_result["result"] = result["accepted"]
else:
run_result["result"] = result["wrong_answer"]
run_result["output_md5"] = output_md5
else:
spj_result = spj_client.spj(path=self._spj_path,
max_cpu_time=3 * self._max_cpu_time,
max_memory=3 * self._real_max_memory,
in_path=in_file,
user_out_path=out_file)
if spj_result["spj_result"] == spj_client.AC:
run_result["result"] = result["accepted"]
elif spj_result["spj_result"] == spj_client.WA:
run_result["result"] = result["wrong_answer"]
else:
run_result["result"] = result["system_error"]
run_result["error"] = "SPJ Crashed, return: %d, signal: %d" % \
(spj_result["spj_result"], spj_result["signal"])
elif run_result["flag"] in [1, 2]:
run_result["result"] = result["time_limit_exceeded"]
elif run_result["flag"] == 3:
run_result["result"] = result["memory_limit_exceeded"]
elif run_result["flag"] == 4:
run_result["result"] = result["runtime_error"]
elif run_result["flag"] == 5:
run_result["result"] = result["system_error"]
return run_result