本文整理汇总了Python中logger.error方法的典型用法代码示例。如果您正苦于以下问题:Python logger.error方法的具体用法?Python logger.error怎么用?Python logger.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logger
的用法示例。
在下文中一共展示了logger.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
# 需要导入模块: import logger [as 别名]
# 或者: from logger import error [as 别名]
def start():
app = QApplication(sys.argv)
# 将Qt事件循环写到asyncio事件循环里。
# QEventLoop不是Qt原生事件循环,
# 是被asyncio重写的事件循环。
eventLoop = QEventLoop(app)
asyncio.set_event_loop(eventLoop)
try:
main = Window()
main.show()
# 当前音乐的显示信息。
# 因为需要布局之后重新绘制的宽高。
# 这个宽高会在show之后才会改变。
# 需要获取宽,高并嵌入到父窗口里。
main.playWidgets.currentMusic.resize(main.navigation.width(), 64)
with eventLoop:
eventLoop.run_forever()
sys.exit(0)
except:
logger.error("got some error", exc_info=True)
示例2: get_template_content
# 需要导入模块: import logger [as 别名]
# 或者: from logger import error [as 别名]
def get_template_content(path):
"""Read either yml or json files and store them as dict"""
template_dict = {}
_filename, file_extension = os.path.splitext(path)
file_extension = file_extension.replace('.', '')
if file_extension in consts.TEMPLATING_EXTS:
try:
template_content = {}
abs_path = os.path.abspath(os.path.expandvars(path))
with open(abs_path, 'r') as stream:
if file_extension in consts.JSON_EXTS:
template_content = json.load(stream) #nosec
elif file_extension in consts.YMAL_EXTS:
template_content = yaml.safe_load(stream) #nosec
template_dict.update(template_content)
except Exception as e:
logger.errorout("Error reading templating file",
file=path, error=e.message)
else:
logger.errorout("No templating file found",
file=path)
return template_dict
示例3: get_config
# 需要导入模块: import logger [as 别名]
# 或者: from logger import error [as 别名]
def get_config(config_file):
"""Read and get a config object
Reads and checks an external configuration file
"""
config = ConfigParser.ConfigParser(allow_no_value=True)
config_fullpath = os.path.abspath(os.path.expandvars(config_file))
# set xform for config otherwise text will be normalized to lowercase
config.optionxform = str
if not os.path.isfile(config_fullpath):
logger.errorout("Commands config file does not exist",
path=config_file)
try:
if not config.read(config_fullpath):
logger.errorout("Problem reading command config file")
except Exception as e:
logger.errorout('Error reading command config',
path=config_file,
error=e.message)
return config
示例4: run
# 需要导入模块: import logger [as 别名]
# 或者: from logger import error [as 别名]
def run(cmd, working_dir=None, dry_run=False):
"""Runs local cmd command"""
cmd_split = shlex.split(cmd) if isinstance(cmd, basestring) else cmd
if dry_run:
return " ".join(cmd_split), 0
try:
p = Popen(cmd_split, shell=False, stderr=STDOUT, stdout=PIPE, cwd=working_dir)
communicate = p.communicate()
return communicate[0].strip(), p.returncode
except OSError as e:
logger.errorout("Run OSError", error=e.message)
except: # pylint: disable=bare-except
logger.errorout("Run Error")
return
示例5: get_commit_log
# 需要导入模块: import logger [as 别名]
# 或者: from logger import error [as 别名]
def get_commit_log(self):
"""Get the current commit log
"""
try:
log_object = {}
for key, value in COMMIT_KEYS.items():
stdout, _rc = helpers.run(['git', 'log', '-1', '--pretty=\'%s\'' % value],
self.paths['repo_path'],
self.dryrun)
output = "XXXXX" if self.dryrun else helpers.filter_content(stdout)
if key in consts.RENAME_COMMIT_LOG_KEYS:
key = consts.RENAME_COMMIT_LOG_KEYS[key]
log_object[key] = output
log_object['project'] = self.project
log_object['reponame'] = self.reponame
return log_object
except Exception as e:
logger.errorout("get_commit_log", error="Problem getting commit log",
error_msg=e.message, track=self.track)
示例6: preflight_checks
# 需要导入模块: import logger [as 别名]
# 或者: from logger import error [as 别名]
def preflight_checks():
logger.info('checking aws credentials and region')
if region() is None:
logger.error('Region is not set up. please run aws configure')
return False
try:
check_aws_credentials()
except AttributeError:
logger.error('AWS credentials not found. please run aws configure')
return False
logger.info('testing redis')
try:
_redis().ping()
except redis.exceptions.ConnectionError:
logger.error('Redis ping failed. Please run gimel configure')
return False
return True
示例7: get_broadcasts_info
# 需要导入模块: import logger [as 别名]
# 或者: from logger import error [as 别名]
def get_broadcasts_info():
try:
user_id = get_user_id()
if user_id:
broadcasts = pil.ig_api.user_story_feed(user_id)
pil.livestream_obj = broadcasts.get('broadcast')
pil.replays_obj = broadcasts.get('post_live_item', {}).get('broadcasts', [])
return True
else:
return False
except ClientThrottledError:
logger.error('Could not check because you are making too many requests at this time.')
return False
except Exception as e:
logger.error('Could not finish checking: {:s}'.format(str(e)))
if "timed out" in str(e):
logger.error('The connection timed out, check your internet connection.')
if "login_required" in str(e):
logger.error('Login cookie was loaded but user is not actually logged in. Delete the cookie file and try '
'again.')
return False
except KeyboardInterrupt:
logger.binfo('Aborted checking for livestreams and replays, exiting.')
return False
示例8: makeDirs
# 需要导入模块: import logger [as 别名]
# 或者: from logger import error [as 别名]
def makeDirs(self, path):
"""
Wrapper for :py:func:`tools.makeDirs()`. Create directories ``path``
recursive and return success. If not successful send error-message to
log.
Args:
path (str): fullpath to directories that should be created
Returns:
bool: ``True`` if successful
"""
if not tools.makeDirs(path):
logger.error("Can't create folder: %s" % path, self)
self.setTakeSnapshotMessage(1, _('Can\'t create folder: %s') % path)
time.sleep(2) #max 1 backup / second
return False
return True
示例9: displayName
# 需要导入模块: import logger [as 别名]
# 或者: from logger import error [as 别名]
def displayName(self):
"""
Combination of displayID, name and error indicator (if any)
Returns:
str: name
"""
ret = self.displayID
name = self.name
if name:
ret += ' - {}'.format(name)
if self.failed:
ret += ' ({})'.format(_('WITH ERRORS !'))
return ret
示例10: setLog
# 需要导入模块: import logger [as 别名]
# 或者: from logger import error [as 别名]
def setLog(self, log):
"""
Write log to "takesnapshot.log.bz2"
Args:
log: full snapshot log
"""
if isinstance(log, str):
log = log.encode('utf-8', 'replace')
logFile = self.path(self.LOG)
try:
with bz2.BZ2File(logFile, 'wb') as f:
f.write(log)
except Exception as e:
logger.error('Failed to write log into compressed file {}: {}'.format(
logFile, str(e)),
self)
示例11: lastSnapshot
# 需要导入模块: import logger [as 别名]
# 或者: from logger import error [as 别名]
def lastSnapshot(args):
"""
Command for printing the very last snapshot in current profile.
Args:
args (argparse.Namespace):
previously parsed arguments
Raises:
SystemExit: 0
"""
force_stdout = setQuiet(args)
cfg = getConfig(args)
_mount(cfg)
sid = snapshots.lastSnapshot(cfg)
if sid:
if args.quiet:
msg = '{}'
else:
msg = 'SnapshotID: {}'
print(msg.format(sid), file=force_stdout)
else:
logger.error("There are no snapshots in '%s'" % cfg.profileName())
_umount(cfg)
sys.exit(RETURN_OK)
示例12: benchmarkCipher
# 需要导入模块: import logger [as 别名]
# 或者: from logger import error [as 别名]
def benchmarkCipher(args):
"""
Command for transferring a file with scp to remote host with all
available ciphers and print its speed and time.
Args:
args (argparse.Namespace):
previously parsed arguments
Raises:
SystemExit: 0
"""
setQuiet(args)
printHeader()
cfg = getConfig(args)
if cfg.snapshotsMode() in ('ssh', 'ssh_encfs'):
ssh = sshtools.SSH(cfg)
ssh.benchmarkCipher(args.FILE_SIZE)
sys.exit(RETURN_OK)
else:
logger.error("SSH is not configured for profile '%s'!" % cfg.profileName())
sys.exit(RETURN_ERR)
示例13: __init__
# 需要导入模块: import logger [as 别名]
# 或者: from logger import error [as 别名]
def __init__(self, cfg = None, *args, **kwargs):
self.config = cfg
if self.config is None:
self.config = config.Config()
cachePath = self.config.passwordCacheFolder()
if not tools.mkdir(cachePath, 0o700):
msg = 'Failed to create secure Password_Cache folder'
logger.error(msg, self)
raise PermissionError(msg)
pid = self.config.passwordCachePid()
super(Password_Cache, self).__init__(pid, umask = 0o077, *args, **kwargs)
self.dbKeyring = {}
self.dbUsr = {}
self.fifo = password_ipc.FIFO(self.config.passwordCacheFifo())
self.keyringSupported = tools.keyringSupported()
示例14: isFifo
# 需要导入模块: import logger [as 别名]
# 或者: from logger import error [as 别名]
def isFifo(self):
"""
make sure file is still a FIFO and has correct permissions
"""
try:
s = os.stat(self.fifo)
except OSError:
return False
if not s.st_uid == os.getuid():
logger.error('%s is not owned by user' % self.fifo, self)
return False
mode = s.st_mode
if not stat.S_ISFIFO(mode):
logger.error('%s is not a FIFO' % self.fifo, self)
return False
forbidden_perm = stat.S_IXUSR + stat.S_IRWXG + stat.S_IRWXO
if mode & forbidden_perm > 0:
logger.error('%s has wrong permissions' % self.fifo, self)
return False
return True
示例15: makeDirs
# 需要导入模块: import logger [as 别名]
# 或者: from logger import error [as 别名]
def makeDirs(path):
"""
Create directories ``path`` recursive and return success.
Args:
path (str): fullpath to directories that should be created
Returns:
bool: ``True`` if successful
"""
path = path.rstrip(os.sep)
if not path:
return False
if os.path.isdir(path):
return True
else:
try:
os.makedirs(path)
except Exception as e:
logger.error("Failed to make dirs '%s': %s"
%(path, str(e)), traceDepth = 1)
return os.path.isdir(path)