本文整理汇总了Python中util.logger.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]
示例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
示例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
示例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"捕获到错误如下:")
示例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")
示例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()))
示例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)
示例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")
示例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)
示例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)
示例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))
示例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')
示例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))
示例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))
示例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")