本文整理汇总了Python中logging.error方法的典型用法代码示例。如果您正苦于以下问题:Python logging.error方法的具体用法?Python logging.error怎么用?Python logging.error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logging
的用法示例。
在下文中一共展示了logging.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_agent_from_json
# 需要导入模块: import logging [as 别名]
# 或者: from logging import error [as 别名]
def get_agent_from_json(agent_json):
new_agent = None
if agent_json["ntype"] == HeightAgent.__name__:
new_agent = HeightAgent(name=agent_json["name"],
height=agent_json["height"],
parent_height=agent_json["parent_height"])
elif agent_json["ntype"] in HeightAgentEng.__name__:
new_agent = HeightAgentEng(name=agent_json["name"],
height=agent_json["height"],
parent_height=agent_json["parent_height"])
else:
logging.error("agent found whose NTYPE is neither "
"{} nor {}, but rather {}".format(HeightAgent.__name__,
HeightAgentEng.__name__,
agent_json["ntype"]))
return new_agent
示例2: restore_agent
# 需要导入模块: import logging [as 别名]
# 或者: from logging import error [as 别名]
def restore_agent(self, agent_json):
"""
Restore agent.
"""
new_agent = None
if agent_json["ntype"] == Hipster.__name__:
new_agent = Hipster(name=agent_json["name"],
goal=agent_json["goal"],
max_move=agent_json["max_move"],
variability=agent_json["variability"])
elif agent_json["ntype"] == Follower.__name__:
new_agent = Follower(name=agent_json["name"],
goal=agent_json["goal"],
max_move=agent_json["max_move"],
variability=agent_json["variability"])
else:
logging.error("agent found whose NTYPE is neither "
"{} nor {}, but {}".format(Hipster.__name__,
Follower.__name__,
agent_json["ntype"]))
if new_agent:
self.add_agent_from_json(new_agent, agent_json)
示例3: checkRequirements
# 需要导入模块: import logging [as 别名]
# 或者: from logging import error [as 别名]
def checkRequirements(args):
if not remap.check_swalign():
print("ERROR: check that svviz is correctly installed -- the 'ssw' Smith-Waterman alignment module does not appear to be functional")
sys.exit(1)
if args.export:
exportFormat = export.getExportFormat(args)
converter = export.getExportConverter(args, exportFormat)
if converter is None and exportFormat != "svg":
if args.converter is not None:
logging.error("ERROR: unable to run SVG converter '{}'. Please check that it is "
"installed correctly".format(args.converter))
else:
logging.error("ERROR: unable to export to PDF/PNG because at least one of the following "
"programs must be correctly installed: webkitToPDF, librsvg or inkscape")
sys.exit(1)
示例4: index
# 需要导入模块: import logging [as 别名]
# 或者: from logging import error [as 别名]
def index():
if not "last_format" in session:
session["last_format"] = "svg"
session.permanent = True
try:
variantDescription = str(dataHub.variant).replace("::", " ").replace("-", "–")
return render_template('index.html',
samples=list(dataHub.samples.keys()),
annotations=dataHub.annotationSets,
results_table=dataHub.getCounts(),
insertSizeDistributions=[sample.name for sample in dataHub if sample.insertSizePlot],
dotplots=dataHub.dotplots,
variantDescription=variantDescription)
except Exception as e:
logging.error("ERROR:{}".format(e))
raise
示例5: parseVCFLine
# 需要导入模块: import logging [as 别名]
# 或者: from logging import error [as 别名]
def parseVCFLine(line, dataHub):
try:
fields = line.strip().split()
info = parseInfo(fields[7])
record = VCFRecord(fields, info)
if record.svtype == "INS":
return parseInsertion(record, dataHub)
elif record.svtype == "DEL":
return parseDeletion(record, dataHub)
elif record.svtype == "INV":
return parseInversion(record, dataHub)
elif record.svtype == "TRA":
return parseTranslocation(record, dataHub)
raise VCFParserError("Unsupported variant type:{}".format(record.svtype))
except Exception as e:
logging.error("\n== Failed to load variant: {} ==".format(e))
logging.error(str(line.strip()))
return None
示例6: getExportConverter
# 需要导入模块: import logging [as 别名]
# 或者: from logging import error [as 别名]
def getExportConverter(args, exportFormat):
if args.converter == "webkittopdf" and exportFormat=="png":
logging.error("webkitToPDF does not support export to PNG; use librsvg or inkscape instead, or "
"export to PDF")
sys.exit(1)
if exportFormat == "png" and args.converter is None:
return "librsvg"
if args.converter == "rsvg-convert":
return "librsvg"
if args.converter in [None, "webkittopdf"]:
if checkWebkitToPDF():
return "webkittopdf"
if args.converter in [None, "librsvg"]:
if checkRSVGConvert():
return "librsvg"
if args.converter in [None, "inkscape"]:
if checkInkscape():
return "inkscape"
return None
示例7: load_project
# 需要导入模块: import logging [as 别名]
# 或者: from logging import error [as 别名]
def load_project(project_name):
# load project and check that it looks okay
try:
importlib.import_module(project_name)
except ImportError as e:
try:
#TODO: relative module imports in a projects/Project will fail for some reason
importlib.import_module("projects.%s" % project_name)
except ImportError as e:
log.error("Failed to import project %s", project_name, exc_info=1)
sys.exit(1)
if len(_registered) != 1:
log.error("Project must register itself using alf.register(). "
"%d projects registered, expecting 1.", len(_registered))
sys.exit(1)
project_cls = _registered.pop()
if not issubclass(project_cls, Fuzzer):
raise TypeError("Expecting a Fuzzer, not '%s'" % type(project_cls))
return project_cls
示例8: read_config
# 需要导入模块: import logging [as 别名]
# 或者: from logging import error [as 别名]
def read_config(self):
"""Read the user's configuration file."""
logging.debug('[VT Plugin] Reading user config file: %s', self.vt_cfgfile)
config_file = configparser.RawConfigParser()
config_file.read(self.vt_cfgfile)
try:
if config_file.get('General', 'auto_upload') == 'True':
self.auto_upload = True
else:
self.auto_upload = False
return True
except:
logging.error('[VT Plugin] Error reading the user config file.')
return False
示例9: check_version
# 需要导入模块: import logging [as 别名]
# 或者: from logging import error [as 别名]
def check_version(self):
"""Return True if there's an update available."""
user_agent = 'IDA Pro VT Plugin checkversion - v' + VT_IDA_PLUGIN_VERSION
headers = {
'User-Agent': user_agent,
'Accept': 'application/json'
}
url = 'https://raw.githubusercontent.com/VirusTotal/vt-ida-plugin/master/VERSION'
try:
response = requests.get(url, headers=headers)
except:
logging.error('[VT Plugin] Unable to check for updates.')
return False
if response.status_code == 200:
version = response.text.rstrip('\n')
if self.__compare_versions(VT_IDA_PLUGIN_VERSION, version):
logging.debug('[VT Plugin] Version %s is available !', version)
return True
return False
示例10: make_directory_writable
# 需要导入模块: import logging [as 别名]
# 或者: from logging import error [as 别名]
def make_directory_writable(dirname):
"""Makes directory readable and writable by everybody.
Args:
dirname: name of the directory
Returns:
True if operation was successfull
If you run something inside Docker container and it writes files, then
these files will be written as root user with restricted permissions.
So to be able to read/modify these files outside of Docker you have to change
permissions to be world readable and writable.
"""
retval = shell_call(['docker', 'run', '-v',
'{0}:/output_dir'.format(dirname),
'busybox:1.27.2',
'chmod', '-R', 'a+rwx', '/output_dir'])
if not retval:
logging.error('Failed to change permissions on directory: %s', dirname)
return retval
示例11: _verify_docker_image_size
# 需要导入模块: import logging [as 别名]
# 或者: from logging import error [as 别名]
def _verify_docker_image_size(self, image_name):
"""Verifies size of Docker image.
Args:
image_name: name of the Docker image.
Returns:
True if image size is withing the limits, False otherwise.
"""
shell_call(['docker', 'pull', image_name])
try:
image_size = subprocess.check_output(
['docker', 'inspect', '--format={{.Size}}', image_name]).strip()
image_size = int(image_size) if PY3 else long(image_size)
except (ValueError, subprocess.CalledProcessError) as e:
logging.error('Failed to determine docker image size: %s', e)
return False
logging.info('Size of docker image %s is %d', image_name, image_size)
if image_size > MAX_DOCKER_IMAGE_SIZE:
logging.error('Image size exceeds limit %d', MAX_DOCKER_IMAGE_SIZE)
return image_size <= MAX_DOCKER_IMAGE_SIZE
示例12: copy_submission_to_destination
# 需要导入模块: import logging [as 别名]
# 或者: from logging import error [as 别名]
def copy_submission_to_destination(self, src_filename, dst_subdir,
submission_id):
"""Copies submission to target directory.
Args:
src_filename: source filename of the submission
dst_subdir: subdirectory of the target directory where submission should
be copied to
submission_id: ID of the submission, will be used as a new
submission filename (before extension)
"""
extension = [e for e in ALLOWED_EXTENSIONS if src_filename.endswith(e)]
if len(extension) != 1:
logging.error('Invalid submission extension: %s', src_filename)
return
dst_filename = os.path.join(self.target_dir, dst_subdir,
submission_id + extension[0])
cmd = ['gsutil', 'cp', src_filename, dst_filename]
if subprocess.call(cmd) != 0:
logging.error('Can\'t copy submission to destination')
else:
logging.info('Submission copied to: %s', dst_filename)
示例13: save_id_to_path_mapping
# 需要导入模块: import logging [as 别名]
# 或者: from logging import error [as 别名]
def save_id_to_path_mapping(self):
"""Saves mapping from submission IDs to original filenames.
This mapping is saved as CSV file into target directory.
"""
if not self.id_to_path_mapping:
return
with open(self.local_id_to_path_mapping_file, 'w') as f:
writer = csv.writer(f)
writer.writerow(['id', 'path'])
for k, v in sorted(iteritems(self.id_to_path_mapping)):
writer.writerow([k, v])
cmd = ['gsutil', 'cp', self.local_id_to_path_mapping_file,
os.path.join(self.target_dir, 'id_to_path_mapping.csv')]
if subprocess.call(cmd) != 0:
logging.error('Can\'t copy id_to_path_mapping.csv to target directory')
示例14: rollback
# 需要导入模块: import logging [as 别名]
# 或者: from logging import error [as 别名]
def rollback(self):
"""Rolls back pending mutations.
Keep in mind that NoTransactionBatch splits all mutations into smaller
batches and commit them as soon as mutation buffer reaches maximum length.
That's why rollback method will only roll back pending mutations from the
buffer, but won't be able to rollback already committed mutations.
"""
try:
if self._cur_batch:
self._cur_batch.rollback()
except ValueError:
# ignore "Batch must be in progress to rollback" error
pass
self._cur_batch = None
self._num_mutations = 0
示例15: log
# 需要导入模块: import logging [as 别名]
# 或者: from logging import error [as 别名]
def log(message, info=True, error=False, debug=False, _print=True):
"""
Dirty function to log messages to file and also print on screen.
:param message:
:param info:
:param error:
:param debug:
:return:
"""
if _print is True:
print(message)
# remove ANSI color codes from logs
# message_clean = re.compile(r'\x1b[^m]*m').sub('', message)
if info is True:
logging.info(message)
elif error is not False:
logging.error(message)
elif debug is not False:
logging.debug(message)