本文整理汇总了Python中util.logger.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_file_infos
def get_file_infos(self, link, secret=None):
shareinfo = ShareInfo()
js = None
try:
js = self._get_js(link, secret)
except IndexError:
# Retry with new cookies
js = self._get_js(link, secret)
# Fix #15
self.session.get(
'http://d.pcs.baidu.com/rest/2.0/pcs/file?method=plantcookie&type=ett')
self.pcsett = self.session.cookies.get('pcsett')
logger.debug(self.pcsett, extra={
'type': 'cookies', 'method': 'SetCookies'})
if not shareinfo.match(js):
pass
for fi in shareinfo.fileinfo:
if fi['isdir'] == 0:
self.all_files.append(fi)
else:
# recursively get files under the specific path
self.bd_get_files(shareinfo, fi['path'])
# get file details include dlink, path, filename ...
return [self.get_file_info(shareinfo, fsid=f['fs_id'], secret=secret) for f in self.all_files]
开发者ID:banbanchs,项目名称:pan-baidu-download,代码行数:28,代码来源:bddown_core.py
示例2: match
def match(self, js):
_filename = re.search(self.filename_pattern, js)
_fileinfo = re.search(self.fileinfo_pattern, js)
if _filename:
self.filename = _filename.group(1).decode('unicode_escape')
if _fileinfo:
self.fileinfo = json.loads(
_fileinfo.group(1).decode('unicode_escape'))
data = re.findall(self.pattern, js)
if not data:
return False
yun_data = dict([i.split(' = ', 1) for i in data])
logger.debug(yun_data, extra={'method': 'GET', 'type': 'javascript'})
# if 'single' not in yun_data.get('SHAREPAGETYPE') or '0' in yun_data.get('LOGINSTATUS'):
# return False
self.uk = yun_data.get('SHARE_UK').strip('"')
# self.bduss = yun_data.get('MYBDUSS').strip('"')
self.share_id = yun_data.get('SHARE_ID').strip('"')
self.fid_list = json.dumps([i['fs_id'] for i in self.fileinfo])
self.sign = yun_data.get('SIGN').strip('"')
if yun_data.get('MYBDSTOKEN'):
self.bdstoken = yun_data.get('MYBDSTOKEN').strip('"')
self.timestamp = yun_data.get('TIMESTAMP').strip('"')
self.sharepagetype = yun_data.get('SHAREPAGETYPE').strip('"')
if self.sharepagetype == DLTYPE_MULTIPLE:
self.filename = os.path.splitext(self.filename)[0] + '-batch.zip'
# if self.bdstoken:
# return True
return True
开发者ID:singhigh,项目名称:pan-baidu-download,代码行数:29,代码来源:bddown_core.py
示例3: get_dlink
def get_dlink(self, link, secret=None):
info = FileInfo()
js = self._get_js(link, secret)
if info.match(js):
extra_params = dict(bdstoken=info.bdstoken, sign=info.sign, timestamp=str(int(time())))
post_form = {
'encrypt': '0',
'product': 'share',
'uk': info.uk,
'primaryid': info.share_id,
'fid_list': '[{0}]'.format(info.fid_list)
}
url = BAIDUPAN_SERVER + 'sharedownload'
response = self._request('POST', url, extra_params=extra_params, post_data=post_form)
if response.ok:
_json = response.json()
errno = _json['errno']
while errno == -20:
verify_params = self._handle_captcha(info.bdstoken)
post_form.update(verify_params)
response = self._request('POST', url, extra_params=extra_params, post_data=post_form)
_json = response.json()
errno = _json['errno']
logger.debug(_json, extra={'type': 'json', 'method': 'POST'})
if errno == 0:
# FIXME: only support single file for now
dlink = _json['list'][0]['dlink']
setattr(info, 'dlink', dlink)
else:
raise UnknownError
return info
开发者ID:12019,项目名称:pan-baidu-download,代码行数:31,代码来源:bddown_core.py
示例4: __init__
def __init__(self, url, method="GET", parameters=None, cookie=None, headers={}):
try:
# 解析url
if type(url) == bytes:
self.__url = url.decode("utf-8")
if type(url) == str:
self.__url = url
logger.debug(self.__url)
scheme, rest = urllib.parse.splittype(self.__url)
# 拆分域名和路径
logger.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
self.__host_absolutely, self.__path = urllib.parse.splithost(rest)
host_list = self.__host_absolutely.split(":")
if len(host_list) == 1:
self.__host = host_list[0]
self.__port = 80
elif len(host_list) == 2:
self.__host = host_list[0]
self.__port = host_list[1]
# 对所传参数进行处理
self.__method = method
self.__data = parameters
self.__cookie = cookie
if parameters != None:
self.__parameters_urlencode_deal = urllib.parse.urlencode(parameters)
else:
self.__parameters_urlencode_deal = ""
self.__jdata = simplejson.dumps(parameters, ensure_ascii=False)
self.__headers = headers
except Exception as e:
logger.error(e)
logger.exception(u"捕获到错误如下:")
开发者ID:pyqf66,项目名称:CaseModeling,代码行数:32,代码来源:HttpUrlConnection.py
示例5: export_single
def export_single(filename, link):
jsonrpc_path = global_config.jsonrpc
jsonrpc_user = global_config.jsonrpc_user
jsonrpc_pass = global_config.jsonrpc_pass
if not jsonrpc_path:
print("请设置config.ini中的jsonrpc选项")
exit(1)
jsonreq = json.dumps(
[{
"jsonrpc": "2.0",
"method": "aria2.addUri",
"id": "qwer",
"params": [
[link],
{
"out": filename,
"header": "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0"
"\r\nReferer:http://pan.baidu.com/disk/home"
}]
}]
)
try:
if jsonrpc_user and jsonrpc_pass:
response = requests.post(url=jsonrpc_path, data=jsonreq, auth=(jsonrpc_user, jsonrpc_pass))
else:
response = requests.post(url=jsonrpc_path, data=jsonreq)
logger.debug(response.text, extra={"type": "jsonreq", "method": "POST"})
except requests.ConnectionError as urle:
print(urle)
raise JsonrpcError("jsonrpc无法连接,请检查jsonrpc地址是否有误!")
if response.ok:
print("已成功添加到jsonrpc\n")
开发者ID:banbanchs,项目名称:pan-baidu-download,代码行数:32,代码来源:export.py
示例6: start
def start(self):
while True:
try:
# 1. Capture images from all cameras
logger.debug("Capturing Images")
images = self.get_images()
# 2. Send them to the remote server
logger.debug("Submitting Images")
self.post_images(images)
except:
logger.warning("Unable to retrieve and send images")
# Wait
time.sleep(PERIOD)
def get_images(self):
images = []
for cam in self.cameras:
# Get Image from camera
img = cam.getImage()
images.append(img)
return images
def post_images(self, images):
#Todo: Saving the images to disk until webserver is up and running
for i in xrange(self.n_cameras):
img = images[i]
img.show()
img.save("images/{}-{}.jpg".format(i, time.time()))
开发者ID:marcdjulien,项目名称:mars_studio,代码行数:29,代码来源:camera_process.py
示例7: handle_part
def handle_part(data, match, client, channels):
"""
Someone is leaving a channel. Let's tell everyone about it and
remove them from the channel's user listing (and the channel from the client's).
'^PART (?P<channel>[^\s]+)( :(?P<message>.*))'
:type data: str
:type match: dict
:type client: Client
:type channels: list
"""
channame = match['channel']
logger.debug("{nick} leaves channel {channame}", nick=client.nick, channame=channame)
if not channame in channels:
logger.warn("no channel named {channame}", channame=channame)
return
channel = channels[channame]
client.channels.remove(channel)
channels[channame].clients.remove(client)
announce = Protocol.part(client, channel, match['message'] or 'leaving')
channel.send(announce)
开发者ID:yukaritan,项目名称:kawaiirc,代码行数:28,代码来源:hooks.py
示例8: verify_passwd
def verify_passwd(self, url, secret=None):
"""
Verify password if url is a private sharing.
:param url: link of private sharing. ('init' must in url)
:type url: str
:param secret: password of the private sharing
:type secret: str
:return: None
"""
if secret:
pwd = secret
else:
# FIXME: Improve translation
pwd = raw_input("Please input this sharing password\n")
data = {'pwd': pwd, 'vcode': ''}
url = "{0}&t={1}&".format(url.replace('init', 'verify'), int(time()))
logger.debug(url, extra={'type': 'url', 'method': 'POST'})
r = self.session.post(url=url, data=data, headers=self.headers)
mesg = r.json()
logger.debug(mesg, extra={'type': 'JSON', 'method': 'POST'})
errno = mesg.get('errno')
if errno == -63:
raise UnknownError
elif errno == -9:
raise VerificationError("提取密码错误\n")
开发者ID:singhigh,项目名称:pan-baidu-download,代码行数:25,代码来源:bddown_core.py
示例9: download
def download(args):
limit = global_config.limit
output_dir = global_config.dir
parser = argparse.ArgumentParser(description="download command arg parser")
parser.add_argument('-L', '--limit', action="store", dest='limit', help="Max download speed limit.")
parser.add_argument('-D', '--dir', action="store", dest='output_dir', help="Download task to dir.")
parser.add_argument('-S', '--secret', action="store", dest='secret', help="Retrieval password.", default="")
if not args:
parser.print_help()
exit(1)
namespace, links = parser.parse_known_args(args)
secret = namespace.secret
if namespace.limit:
limit = namespace.limit
if namespace.output_dir:
output_dir = namespace.output_dir
# if is wap
links = [link.replace("wap/link", "share/link") for link in links]
# add 'http://'
links = map(add_http, links)
for url in links:
res = parse_url(url)
# normal
if res.get('type') == 1:
pan = Pan()
info = pan.get_dlink(url, secret)
cookies = 'BDUSS={0}'.format(pan.bduss) if pan.bduss else ''
if cookies and pan.pcsett:
cookies += ';pcsett={0}'.format(pan.pcsett)
if cookies:
cookies += '"'
download_command(info.filename, info.dlink, cookies=cookies, limit=limit, output_dir=output_dir)
elif res.get('type') == 4:
pan = Pan()
fsid = res.get('fsid')
newUrl = res.get('url')
info = pan.get_dlink(newUrl, secret, fsid)
cookies = 'BDUSS={0}'.format(pan.bduss) if pan.bduss else ''
if cookies and pan.pcsett:
cookies += ';pcsett={0}'.format(pan.pcsett)
if cookies:
cookies += '"'
download_command(info.filename, info.dlink, cookies=cookies, limit=limit, output_dir=output_dir)
# album
elif res.get('type') == 2:
raise NotImplementedError('This function has not implemented.')
# home
elif res.get('type') == 3:
raise NotImplementedError('This function has not implemented.')
elif res.get('type') == 0:
logger.debug(url, extra={"type": "wrong link", "method": "None"})
continue
else:
continue
sys.exit(0)
开发者ID:ezioruan,项目名称:pan-baidu-download,代码行数:59,代码来源:download.py
示例10: _native_equals
def _native_equals(a, b):
try:
if a.raw == b.raw:
return a # or b
return create_failed(False)
except Exception as e:
logger.debug(e) # TODO narrow down exceptions
return create_failed(e)
开发者ID:pietype,项目名称:whisper-python,代码行数:8,代码来源:runtime.py
示例11: attribute
def attribute(object, scope):
value = object.raw
if value in scope.items:
output = _new_with_self(_expression_with_scope(scope.items[value], lambda: _item_resolution_scope(scope))(), scope)
logger.debug('attribute {} in {}, returned {}'.format(object.raw, scope._id, output._id))
return output
return create_failed(WRException('Attribute error: `%s`' % value))
开发者ID:pietype,项目名称:whisper-python,代码行数:8,代码来源:runtime.py
示例12: _check_verify_code
def _check_verify_code(self):
"""Check if login need to input verify code."""
r = self.session.get(self._check_url)
s = r.text
data = json.loads(s[s.index('{'):-1])
log_message = {'type': 'check loging verify code', 'method': 'GET'}
logger.debug(data, extra=log_message)
if data.get('codestring'):
self.codestring = data.get('codestring')
开发者ID:banbanchs,项目名称:pan-baidu-download,代码行数:9,代码来源:login.py
示例13: addhook
def addhook(regex, func):
"""
Associates a function with a regex.
:type regex: str
:type func: function
:rtype: None
"""
logger.debug("Adding hook for '{regex}'", regex=regex)
MessageHandler.HOOKS.append((re.compile(regex), func))
开发者ID:yukaritan,项目名称:kawaiirc,代码行数:10,代码来源:messagehandler.py
示例14: _resolve
def _resolve(ident, scope):
logger.debug("resolve {} (in {})".format(ident, scope._id))
d = _get_scope_dict(scope)
if ident in d:
return d[ident]()
if scope.parent:
return _resolve(ident, scope.parent)
return create_failed(WRException('Key error: `%s`' % ident))
开发者ID:pietype,项目名称:whisper-python,代码行数:11,代码来源:runtime.py
示例15: _get_token
def _get_token(self):
"""Get bdstoken."""
r = self.session.get(self._token_url)
s = r.text
try:
self.token = re.search("login_token='(\w+)';", s).group(1)
# FIXME: if couldn't get the token, we can not get the log message.
log_message = {'type': 'bdstoken', 'method': 'GET'}
logger.debug(self.token, extra=log_message)
except:
raise GetTokenError("Can't get the token")
开发者ID:banbanchs,项目名称:pan-baidu-download,代码行数:11,代码来源:login.py
示例16: _native_add
def _native_add(a, b):
try:
native = a.raw + b.raw
return {
int: create_number,
list: create_list,
str: create_string,
}[type(native)](native)
except Exception as e:
logger.debug(e) # TODO narrow down exception list
return create_failed(WRException('Cannot add types: %s, %s' % (type(a.raw), type(b.raw))))
开发者ID:pietype,项目名称:whisper-python,代码行数:11,代码来源:runtime.py
示例17: start
def start(self):
# Start the thread for each sensor
logger.debug("Starting all DataPoster threads")
for thread in self.threads:
thread.start()
# Wait fo rall threads to finish
# In theory this should run forever
for thread in self.threads:
thread.join()
logger.debug("All DataPoster Threads joined");
开发者ID:marcdjulien,项目名称:mars_studio,代码行数:12,代码来源:server_communicator.py
示例18: repost_replies
def repost_replies(account_name):
bf = open('.blacklist_%s'%account_name,'a+')
blacklist = bf.read().splitlines()
bf.close()
rp = open('.reposted_%s'%account_name,'a+')
reposted = rp.read().splitlines()
account = settings.ACCOUNTS.get(account_name)
try:
logging.info('[%s] Getting last mentions offset'%account_name)
bot = TwitterBot(settings.CONSUMER_KEY,settings.CONSUMER_SECRET,
account['key'],account['secret'])
mentions = []
try:
mentions = bot.api.mentions()
logging.info('[%s] Got %d mentions'%(account_name,len(mentions)))
except Exception,e:
logging.error('[%s] Failed to get mentions. %s'%(account_name,e))
for mess in reversed(mentions):
try:
author = mess.author.screen_name
if str(author) in blacklist:
logging.debug('[%s] Author %s blacklisted. Skipping.'%(account_name,str(author)))
continue
if str(mess.id) in reposted:
logging.debug('[%s] Message #%s already reposted. Skipping.'%(account_name,str(mess.id)))
continue
message = mess.text.split(' ')
if message[0] != '@%s'%account_name:
continue #not a "@reply"
trigger = message[1]
triggers = dict(account['triggers'])
if trigger not in triggers:
logging.warning('[%s] Bad message format, sending DM to author'%account_name)
bot.dm(author,account['not_triggered'])
else:
len_params = {'message':'','user':author}
mess_len = len(triggers[trigger]%len_params)
params = {'message':bot.trim_message(' '.join(message[2:]),mess_len),'user':author}
message = triggers[trigger]%params
logging.info('[%s] Tweeting message %s'%(account_name,message))
bot.tweet(message)
rp.write('%s\n'%mess.id)
except Exception,e:
logging.error('%s'%e)
continue
开发者ID:starenka,项目名称:ara,代码行数:51,代码来源:ara.py
示例19: handle_mode
def handle_mode(data, match, client, channels):
"""
Someone is setting their mode. I don't know enough about this to talk about it yet.
'^MODE (?P<nick>[^\s]+) (?P<mode>.*)'
:type data: str
:type match: dict
:type client: Client
:type channels: list
"""
logger.debug("setting {nick}'s mode to {mode}, as per their request", **match)
client.mode = match['mode'].replace('+', '')
开发者ID:yukaritan,项目名称:kawaiirc,代码行数:14,代码来源:hooks.py
示例20: lineReceived
def lineReceived(self, data):
"""
:type data: bytes
"""
data = data.decode()
logger.debug('Recieved "{data}" from {nick}',
nick=self._client.nick,
data=data)
response = MessageHandler.handleline(data, self._client, self.factory.channels)
if response:
for data in response:
self.send(data)
开发者ID:yukaritan,项目名称:kawaiirc,代码行数:14,代码来源:clientconnection.py
注:本文中的util.logger.debug函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论