本文整理汇总了Python中logger.debug方法的典型用法代码示例。如果您正苦于以下问题:Python logger.debug方法的具体用法?Python logger.debug怎么用?Python logger.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logger
的用法示例。
在下文中一共展示了logger.debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getCachedFile
# 需要导入模块: import logger [as 别名]
# 或者: from logger import debug [as 别名]
def getCachedFile(siteCachePath,cacheId):
mascara = os.path.join(siteCachePath,cacheId[:2],cacheId[2:],"*.cache")
logger.debug("[scrapertools.py] mascara="+mascara)
import glob
ficheros = glob.glob( mascara )
logger.debug("[scrapertools.py] Hay %d ficheros con ese id" % len(ficheros))
cachedFile = ""
# Si hay más de uno, los borra (serán pruebas de programación) y descarga de nuevo
if len(ficheros)>1:
logger.debug("[scrapertools.py] Cache inválida")
for fichero in ficheros:
logger.debug("[scrapertools.py] Borrando "+fichero)
os.remove(fichero)
cachedFile = ""
# Hay uno: fichero cacheado
elif len(ficheros)==1:
cachedFile = ficheros[0]
return cachedFile
示例2: role
# 需要导入模块: import logger [as 别名]
# 或者: from logger import debug [as 别名]
def role():
new_role = False
try:
logger.info('finding role')
iam('get_role', RoleName='gimel')
except ClientError:
logger.info('role not found. creating')
iam('create_role', RoleName='gimel',
AssumeRolePolicyDocument=ASSUMED_ROLE_POLICY)
new_role = True
role_arn = iam('get_role', RoleName='gimel', query='Role.Arn')
logger.debug('role_arn={}'.format(role_arn))
logger.info('updating role policy')
iam('put_role_policy', RoleName='gimel', PolicyName='gimel',
PolicyDocument=POLICY)
if new_role:
from time import sleep
logger.info('waiting for role policy propagation')
sleep(5)
return role_arn
示例3: role
# 需要导入模块: import logger [as 别名]
# 或者: from logger import debug [as 别名]
def role():
new_role = False
try:
logger.info('finding role')
iam('get_role', RoleName='cronyo')
except ClientError:
logger.info('role not found. creating')
iam('create_role', RoleName='cronyo',
AssumeRolePolicyDocument=ASSUMED_ROLE_POLICY)
new_role = True
role_arn = iam('get_role', RoleName='cronyo', query='Role.Arn')
logger.debug('role_arn={}'.format(role_arn))
logger.info('updating role policy')
iam('put_role_policy', RoleName='cronyo', PolicyName='cronyo',
PolicyDocument=POLICY)
if new_role:
from time import sleep
logger.info('waiting for role policy propagation')
sleep(5)
return role_arn
示例4: find_group_by_wechattype
# 需要导入模块: import logger [as 别名]
# 或者: from logger import debug [as 别名]
def find_group_by_wechattype():
#查询wechat所属组
sql = "select DISTINCT(wechat_group) as wechat_group from biz_system_tree"
logger.debug("sql:%s", sql)
# conn = pymysql.connect(host="127.0.0.1",user="username",passwd="password",
# db="chatbot",
# charset="utf8")
conn = __connection_pool.connection()
cursor = conn.cursor()
cursor.execute(sql)
dutys = cursor.fetchall()
wechat_groups = []
for d in dutys:
wechat_groups.append(d['wechat_group'].decode('UTF-8'))
cursor.close()
conn.close()
return wechat_groups
示例5: send
# 需要导入模块: import logger [as 别名]
# 或者: from logger import debug [as 别名]
def send(apiUrl,data,method=None):
logger.debug("调用内部系统[%s],data[%r]",apiUrl,data)
try:
data_json = json.dumps(data)
headers = {'Content-Type': 'application/json'} # 设置数据为json格式,很重要
request = urllib2.Request(url=apiUrl, headers=headers, data=data_json)
if method is not None:
request.get_method = method
response = urllib2.urlopen(request)
result = {'code':response.getcode(),'content':response.read()}
logger.debug("调用[%s]返回结果:%r",apiUrl,result)
return result
except Exception as e:
#traceback.print_stack()
logger.exception(e,"调用内部系统[%s],data[%r],发生错误[%r]", apiUrl, data,e)
return None
示例6: setTakeSnapshotMessage
# 需要导入模块: import logger [as 别名]
# 或者: from logger import debug [as 别名]
def setTakeSnapshotMessage(self, type_id, message, timeout = -1):
data = str(type_id) + '\n' + message
try:
with open(self.config.takeSnapshotMessageFile(), 'wt') as f:
f.write(data)
except Exception as e:
logger.debug('Failed to set takeSnapshot message to %s: %s'
%(self.config.takeSnapshotMessageFile(), str(e)),
self)
if 1 == type_id:
self.snapshotLog.append('[E] ' + message, 1)
else:
self.snapshotLog.append('[I] ' + message, 3)
try:
profile_id =self.config.currentProfile()
profile_name = self.config.profileName(profile_id)
self.config.PLUGIN_MANAGER.message(profile_id, profile_name, type_id, message, timeout)
except Exception as e:
logger.debug('Failed to send message to plugins: %s'
%str(e),
self)
示例7: userName
# 需要导入模块: import logger [as 别名]
# 或者: from logger import debug [as 别名]
def userName(self, uid):
"""
Get the username for the given uid.
uid->name will be cached to speed up subsequent requests.
Args:
uid (int): User identifier (UID) to search for
Returns:
str: name of the user with UID uid or '-' if not found
"""
if uid in self.userCache:
return self.userCache[uid]
else:
name = '-'
try:
name = pwd.getpwuid(uid).pw_name
except Exception as e:
logger.debug('Failed to get user name for UID %s: %s'
%(uid, str(e)),
self)
self.userCache[uid] = name
return name
示例8: smartRemoveKeepAll
# 需要导入模块: import logger [as 别名]
# 或者: from logger import debug [as 别名]
def smartRemoveKeepAll(self,
snapshots,
min_date,
max_date):
"""
Return all snapshots between ``min_date`` and ``max_date``.
Args:
snapshots (list): full list of :py:class:`SID` objects
min_date (datetime.date): minimum date for snapshots to keep
max_date (datetime.date): maximum date for snapshots to keep
Returns:
set: set of snapshots that should be keept
"""
min_id = SID(min_date, self.config)
max_id = SID(max_date, self.config)
logger.debug("Keep all >= %s and < %s" %(min_id, max_id), self)
return set([sid for sid in snapshots if sid >= min_id and sid < max_id])
示例9: statFreeSpaceLocal
# 需要导入模块: import logger [as 别名]
# 或者: from logger import debug [as 别名]
def statFreeSpaceLocal(self, path):
"""
Get free space on filsystem containing ``path`` in MiB using
:py:func:`os.statvfs()`. Depending on remote SFTP server this might fail
on sshfs mounted shares.
Args:
path (str): full path
Returns:
int free space in MiB
"""
try:
info = os.statvfs(path)
if info.f_blocks != info.f_bavail:
return info.f_frsize * info.f_bavail // (1024 * 1024)
except Exception as e:
logger.debug('Failed to get free space for %s: %s'
%(path, str(e)),
self)
logger.warning('Failed to stat snapshot path', self)
示例10: flockExclusive
# 需要导入模块: import logger [as 别名]
# 或者: from logger import debug [as 别名]
def flockExclusive(self):
"""
Block :py:func:`backup` from other profiles or users
and run them serialized
"""
if self.config.globalFlock():
logger.debug('Set flock %s' %self.GLOBAL_FLOCK, self)
self.flock = open(self.GLOBAL_FLOCK, 'w')
fcntl.flock(self.flock, fcntl.LOCK_EX)
#make it rw by all if that's not already done.
perms = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | \
stat.S_IWGRP | stat.S_IROTH | stat.S_IWOTH
s = os.fstat(self.flock.fileno())
if not s.st_mode & perms == perms:
logger.debug('Set flock permissions %s' %self.GLOBAL_FLOCK, self)
os.fchmod(self.flock.fileno(), perms)
示例11: name
# 需要导入模块: import logger [as 别名]
# 或者: from logger import debug [as 别名]
def name(self):
"""
Name of this snapshot
Args:
name (str): new name of the snapshot
Returns:
str: name of this snapshot
"""
nameFile = self.path(self.NAME)
if not os.path.isfile(nameFile):
return ''
try:
with open(nameFile, 'rt') as f:
return f.read()
except Exception as e:
logger.debug('Failed to get snapshot {} name: {}'.format(
self.sid, str(e)),
self)
示例12: unInhibitSuspend
# 需要导入模块: import logger [as 别名]
# 或者: from logger import debug [as 别名]
def unInhibitSuspend(cookie, bus, dbus_props):
"""
Release inhibit.
"""
assert isinstance(cookie, int), 'cookie is not int type: %s' % cookie
assert isinstance(bus, dbus.bus.BusConnection), 'bus is not dbus.bus.BusConnection type: %s' % bus
assert isinstance(dbus_props, dict), 'dbus_props is not dict type: %s' % dbus_props
try:
interface = bus.get_object(dbus_props['service'], dbus_props['objectPath'])
proxy = interface.get_dbus_method(dbus_props['methodUnSet'], dbus_props['interface'])
proxy(cookie)
logger.debug('Release inhibit Suspend')
return None
except dbus.exceptions.DBusException:
logger.warning('Release inhibit Suspend failed.')
return (cookie, bus, dbus_props)
示例13: checkVersion
# 需要导入模块: import logger [as 别名]
# 或者: from logger import debug [as 别名]
def checkVersion(self):
"""
check encfs version.
1.7.2 had a bug with --reverse that will create corrupt files
"""
logger.debug('Check version', self)
if self.reverse:
proc = subprocess.Popen(['encfs', '--version'],
stdout = subprocess.PIPE,
stderr = subprocess.STDOUT,
universal_newlines = True)
output = proc.communicate()[0]
m = re.search(r'(\d\.\d\.\d)', output)
if m and StrictVersion(m.group(1)) <= StrictVersion('1.7.2'):
logger.debug('Wrong encfs version %s' %m.group(1), self)
raise MountException(_('encfs version 1.7.2 and before has a bug with option --reverse. Please update encfs'))
示例14: startProcess
# 需要导入模块: import logger [as 别名]
# 或者: from logger import debug [as 别名]
def startProcess(self):
"""
start 'encfsctl encode' process in pipe mode.
"""
thread = password_ipc.TempPasswordThread(self.password)
env = self.encfs.env()
env['ASKPASS_TEMP'] = thread.temp_file
with thread.starter():
logger.debug('start \'encfsctl encode\' process', self)
encfsctl = ['encfsctl', 'encode', '--extpass=backintime-askpass', '/']
logger.debug('Call command: %s'
%' '.join(encfsctl),
self)
self.p = subprocess.Popen(encfsctl, env = env, bufsize = 0,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
universal_newlines = True)
示例15: path
# 需要导入模块: import logger [as 别名]
# 或者: from logger import debug [as 别名]
def path(self, path):
"""
write plain path to encfsctl stdin and read encrypted path from stdout
"""
if not 'p' in vars(self):
self.startProcess()
if not self.p.returncode is None:
logger.warning('\'encfsctl encode\' process terminated. Restarting.', self)
del self.p
self.startProcess()
self.p.stdin.write(path + '\n')
ret = self.p.stdout.readline().strip('\n')
if not len(ret) and len(path):
logger.debug('Failed to encode %s. Got empty string'
%path, self)
raise EncodeValueError()
return ret