本文整理汇总了Python中util.Log.critical方法的典型用法代码示例。如果您正苦于以下问题:Python Log.critical方法的具体用法?Python Log.critical怎么用?Python Log.critical使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Log
的用法示例。
在下文中一共展示了Log.critical方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upload_to_web
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import critical [as 别名]
def upload_to_web(self, url):
""" Upload the component to the given url
"""
Log.critical('upload_to_web() has been called. This function is deprecated')
Log.debug("Uploading component to url %s" % url)
import requests
manifest_file = self._component_file
files = {'manifest': open(manifest_file, "rb")}
r = requests.post(url, files=files)
if r.status_code != requests.codes.ok:
Log.critical("Error %s occured while upload" % r.status_code)
示例2: add
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import critical [as 别名]
def add(cls, component):
""" A given package will be added to the local database.
A package has to be in the ctlweb-format which can be found in our
docmuentation.
returns newly created object
"""
from os import path
Log.debug("add(package): adding package to local database")
# Create Database entry
data = Component._unpack(component)
comp = cls.create(data)
comp._component_file = component
try:
comp.save()
except NoSuchTable:
comp.create_table().save()
except ValueError as e:
Log.critical('%s' % e.args[0])
return
except MergedWarning as e:
Log.info('Merged components')
return comp
# Copy package to store
comp._component_file = None # reset the component to default.
try:
comp_log = ComponentLog.get_exactly(comp['c_exe_hash'])
comp_log.remove()
except (InstanceNotFoundError, NoSuchTable):
pass
import shutil
try:
target_name = comp._component_file
shutil.copy(component, target_name)
except IOError:
Log.critical("Unable to save component to Manifest store in %s"
% store)
exit(1)
return comp
示例3: _read_control
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import critical [as 别名]
def _read_control(control):
""" Reads for the backend required keys of the control file. See
Component.create() for more detail.
"""
Log.debug("_read_control(): parsing control file %s")
import configparser
parser = configparser.ConfigParser()
parser.read(control)
try:
name = parser['DEFAULT']['name']
except KeyError:
Log.critical("Found no component name")
raise
try:
exe = parser['DEFAULT']['exe']
exe_hash = parser['DEFAULT']['exe_hash']
except KeyError:
Log.critical("Found no corresponding exe in component")
raise
return {"c_id": name,
"c_exe": exe,
"c_exe_hash": exe_hash,
}
示例4: __init__
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import critical [as 别名]
def __init__(self, config_file=DEFAULT_CONFIG):
import configparser
reader = configparser.ConfigParser()
reader.read(config_file)
self.c_pk = -1
if not Database.config:
Database.config = config_file # share config file with others
if Database.store is None:
try:
Database.store = reader.get("Backend", "Manifest_store")
except configparser.Error:
Log.critical(
"""Your Config-File seems to be malformated! Check
your Config-File and try again!"""
)
sys.exit(1)
if Database.db_file is None:
try:
Database.db_file = reader.get("Backend", "Database")
import os
if os.path.isdir(Database.db_file):
Log.critical("Database(): Database is directory!")
sys.exit(1)
except configparser.Error:
Log.critical(
"""Your Config-File seems to be malformated! Check
your Config-File and try again!"""
)
sys.exit(1)
try: # Check if connection is active
Database.db_connection.execute(
"""SELECT name from sqlite_master
LIMIT 1"""
)
Database.db_connection.fetchone()
except (sqlite3.ProgrammingError, AttributeError):
Database.db_connection = sqlite3.connect(Database.db_file)