本文整理汇总了Python中urllib.unquote方法的典型用法代码示例。如果您正苦于以下问题:Python urllib.unquote方法的具体用法?Python urllib.unquote怎么用?Python urllib.unquote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urllib
的用法示例。
在下文中一共展示了urllib.unquote方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: installChute
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote [as 别名]
def installChute(host, port, config):
'''
Take a local config yaml file and launch chute of given host with pdfcd running on specified port.
'''
config_json = readChuteConfig(config)
if config_json is None:
return
print 'Installing chute...\n'
params = {'config': config_json}
r = requests.post('http://' + host + ':' + str(port) + '/v1/chute/create', data=json.dumps(params), stream=True)
for line in r.iter_lines():
if line:
try:
line = json.loads(line)
if line.get('success'):
print line.get('message')
else:
print 'ERROR: Failed to install chute.(' + urllib.unquote(str(line.get('message'))) + ')'
except Exception as e:
print line
示例2: updateChute
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote [as 别名]
def updateChute(host, port, config):
'''
Take a local config yaml file and launch chute of given host with pdfcd running on specified port.
'''
config_json = readChuteConfig(config)
if config_json is None:
return
print 'Updating chute...\n'
params = {'config': config_json}
r = requests.post('http://' + host + ':' + str(port) + '/v1/chute/update', data=json.dumps(params), stream=True)
for line in r.iter_lines():
if line:
try:
line = json.loads(line)
if line.get('success'):
print line.get('message')
else:
print 'ERROR: Failed to install chute.(' + urllib.unquote(str(line.get('message'))) + ')'
except Exception as e:
print line
示例3: deleteChute
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote [as 别名]
def deleteChute(host, port, name):
'''
Remove chute with given name from host with pdfcd running on specified port.
'''
print 'Removing chute...\n'
params = {'name': name}
r = requests.post('http://' + host + ':' + str(port) + '/v1/chute/delete', data=json.dumps(params), stream=True)
for line in r.iter_lines():
if line:
try:
line = json.loads(line)
if line.get('success'):
print line.get('message')
else:
print 'ERROR: Failed to delete chute.(' + urllib.unquote(str(line.get('message'))) + ')'
except Exception as e:
print line
示例4: stopChute
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote [as 别名]
def stopChute(host, port, name):
'''
Stop chute with given name from host with pdfcd running on specified port.
'''
print 'Stopping chute...\n'
params = {'name': name}
r = requests.post('http://' + host + ':' + str(port) + '/v1/chute/stop', data=json.dumps(params), stream=True)
for line in r.iter_lines():
if line:
try:
line = json.loads(line)
if line.get('success'):
print line.get('message')
else:
print 'ERROR: Failed to stop chute.(' + urllib.unquote(str(line.get('message'))) + ')'
except Exception as e:
print line
示例5: startChute
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote [as 别名]
def startChute(host, port, name):
'''
Start chute with given name from host with pdfcd running on specified port.
'''
print 'Starting chute...\n'
params = {'name': name}
r = requests.post('http://' + host + ':' + str(port) + '/v1/chute/start', data=json.dumps(params), stream=True)
for line in r.iter_lines():
if line:
try:
line = json.loads(line)
if line.get('success'):
print line.get('message')
else:
print 'ERROR: Failed to start chute.(' + urllib.unquote(str(line.get('message'))) + ')'
except Exception as e:
print line
示例6: play_url
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote [as 别名]
def play_url(params):
torr_link=params['file']
img=urllib.unquote_plus(params["img"])
#showMessage('heading', torr_link, 10000)
TSplayer=tsengine()
out=TSplayer.load_torrent(torr_link,'TORRENT',port=aceport)
if out=='Ok':
for k,v in TSplayer.files.iteritems():
li = xbmcgui.ListItem(urllib.unquote(k))
uri = construct_request({
'torr_url': torr_link,
'title': k,
'ind':v,
'img':img,
'mode': 'play_url2'
})
xbmcplugin.addDirectoryItem(handle, uri, li, False)
xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
xbmcplugin.endOfDirectory(handle)
TSplayer.end()
示例7: put
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote [as 别名]
def put(self, bucket, object_name):
object_name = urllib.unquote(object_name)
bucket_dir = os.path.abspath(os.path.join(
self.application.directory, bucket))
if not bucket_dir.startswith(self.application.directory) or \
not os.path.isdir(bucket_dir):
raise web.HTTPError(404)
path = self._object_path(bucket, object_name)
if not path.startswith(bucket_dir) or os.path.isdir(path):
raise web.HTTPError(403)
directory = os.path.dirname(path)
if not os.path.exists(directory):
os.makedirs(directory)
object_file = open(path, "w")
object_file.write(self.request.body)
object_file.close()
self.finish()
示例8: web_console
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote [as 别名]
def web_console():
g = proc.Group()
action=request.args.get('action')
allow_action=['UpdateFile','UploadDir','Upload']
if action not in allow_action:
return make_response('error')
if action in ['UploadDir','Upload']:
local=urllib.unquote(request.args.get('local'))
remote=urllib.unquote(request.args.get('remote'))
user=urllib.unquote(request.args.get('user'))
cmd=["python","-u",os.path.join(config_dir,'function.py'),action,local,remote,user]
elif action=='UpdateFile':
type_=request.args.get('type')
cmd=["python","-u",os.path.join(config_dir,'function.py'),'UpdateFile',type_]
else:
cmd=["python","-u",os.path.join(config_dir,'function.py'),action]
p = g.run(cmd)
def read_process():
while g.is_pending():
lines = g.readlines()
for proc, line in lines:
yield "data:" + line + "\n\n"
yield "data:end\n\n"
resp=Response(read_process(), mimetype= 'text/event-stream')
return resp
示例9: _parse_api_call
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote [as 别名]
def _parse_api_call(self, call_str):
call_re = r"#api:(\w+)(\[\d+\])?(/[^/]*)+$"
call_match = re.search(call_re, call_str)
name = call_match.group(1)
call = [name]
timestamp = call_match.group(2)
if timestamp is not None:
call.append(timestamp[1:-1])
else:
call.append(None)
args = re.sub(r"^#api:[^/]*/?", r"", call_match.group(0))
if len(args) > 0:
if args[-1] == "/":
args = args[:-1]
arglist = map(urllib.unquote, args.split("/"))
call += arglist[1:] # remove seq
return call
示例10: read
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote [as 别名]
def read(self, ifile):
""" Reads an input header from an input file.
The input header is read as a sequence of *<name>***:***<value>* pairs separated by a newline. The end of the
input header is signalled by an empty line or an end-of-file.
:param ifile: File-like object that supports iteration over lines.
"""
name, value = None, None
for line in ifile:
if line == '\n':
break
item = line.split(':', 1)
if len(item) == 2:
# start of a new item
if name is not None:
self[name] = value[:-1] # value sans trailing newline
name, value = item[0], unquote(item[1])
elif name is not None:
# continuation of the current item
value += unquote(line)
if name is not None: self[name] = value[:-1] if value[-1] == '\n' else value
示例11: _entity_path
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote [as 别名]
def _entity_path(self, state):
"""Calculate the path to an entity to be returned.
*state* should be the dictionary returned by
:func:`_parse_atom_entry`. :func:`_entity_path` extracts the
link to this entity from *state*, and strips all the namespace
prefixes from it to leave only the relative path of the entity
itself, sans namespace.
:rtype: ``string``
:return: an absolute path
"""
# This has been factored out so that it can be easily
# overloaded by Configurations, which has to switch its
# entities' endpoints from its own properties/ to configs/.
raw_path = urllib.unquote(state.links.alternate)
if 'servicesNS/' in raw_path:
return _trailing(raw_path, 'servicesNS/', '/', '/')
elif 'services/' in raw_path:
return _trailing(raw_path, 'services/')
else:
return raw_path
示例12: __init__
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote [as 别名]
def __init__(self, selectObj, secretStr, from_station, to_station, train_no, set_type,
passengerTicketStrList, oldPassengerStr, train_date, ticke_peoples):
self.session = selectObj
# self.secretStr = secretStr
try:
self.secretStr = urllib.unquote(secretStr)
except AttributeError:
self.secretStr = urllib.parse.unquote(secretStr)
self.from_station = from_station
self.to_station = to_station
self.to_station = to_station
self.train_no = train_no
self.set_type = set_type
self.passengerTicketStrList = passengerTicketStrList
self.oldPassengerStr = oldPassengerStr
self.train_date = train_date
self.ticke_peoples = ticke_peoples
示例13: __init__
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote [as 别名]
def __init__(self, selectObj,
secretStr,
train_date,
query_from_station_name,
query_to_station_name,
passengerTicketStr,
oldPassengerStr,
train_no,
stationTrainCode,
leftTicket,
set_type,):
self.set_type = set_type
try:
self.secretStr = urllib.unquote(secretStr)
except AttributeError:
self.secretStr = urllib.parse.unquote(secretStr)
self.train_date = train_date
self.query_from_station_name = query_from_station_name
self.query_to_station_name = query_to_station_name
self.passengerTicketStr = passengerTicketStr.rstrip("_{0}".format(self.set_type))
self.oldPassengerStr = oldPassengerStr
self.session = selectObj
self.train_no = train_no
self.stationTrainCode = stationTrainCode
self.leftTicket = leftTicket
示例14: __init__
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote [as 别名]
def __init__(self, url):
super(ElasticDB, self).__init__()
self.username = ''
self.password = ''
self.hosts = None
if '@' in url.netloc:
username, hostname = url.netloc.split('@', 1)
if ':' in username:
self.username, self.password = (unquote(val) for val in
username.split(':', 1))
else:
self.username = unquote(username)
if hostname:
self.hosts = [hostname]
elif url.netloc:
self.hosts = [url.netloc]
index_prefix = url.path.lstrip('/')
if index_prefix:
self.index_prefix = index_prefix + '-'
else:
self.index_prefix = 'ivre-'
self.params = dict(x.split('=', 1) if '=' in x else (x, None)
for x in url.query.split('&') if x)
示例15: create_cookies
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote [as 别名]
def create_cookies(self, cookie):
cookies = dict()
cookies_list = cookie[0:cookie.find(';')].split("=")
cookies[cookies_list[0]] = cookies_list[1]
cookies['netcraft_js_verification_response'] = hashlib.sha1(urllib.unquote(cookies_list[1])).hexdigest()
return cookies