• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python urllib.quote_plus函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中urllib.quote_plus函数的典型用法代码示例。如果您正苦于以下问题:Python quote_plus函数的具体用法?Python quote_plus怎么用?Python quote_plus使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了quote_plus函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: encode_multipart_formdata

def encode_multipart_formdata(fields, files):
    """
    refer from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/572202

    fields is a sequence of (name, value) elements for regular form fields.
    files is a sequence of (name, filename, value) elements for data to be uploaded as files
    Return (content_type, body) ready for httplib.HTTP instance
    """
    BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$'
    CRLF = '\r\n'
    L = []
    for (key, value) in fields:
        L.append('--' + BOUNDARY)
        L.append('Content-Disposition: form-data; name="%s"' % key)
        L.append('')
        L.append(urllib.quote_plus(str(value)))
    for (key, filename, value) in files:
        L.append('--' + BOUNDARY)
        L.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, urllib.quote_plus(filename)))
        L.append('Content-Type: %s' % get_content_type(filename))
        L.append('')
        L.append(value)
    L.append('--' + BOUNDARY + '--')
    L.append('')
    body = CRLF.join(L)
    content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
    return content_type, body
开发者ID:perol,项目名称:xblog,代码行数:27,代码来源:browser_agent.py


示例2: addDir

def addDir(name,url,mode,iconimage):
        u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
        ok=True
        liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage)
        liz.setInfo( type="Video", infoLabels={ "Title": name } )
        ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
        return ok
开发者ID:ak0ng,项目名称:dk-xbmc-repaddon-rep,代码行数:7,代码来源:default.py


示例3: prepare_url

def prepare_url(values):
    vals = DEFAULT_VALUES.copy()
    vals.update(values)
    vals["query"] = quote_plus(vals["query"])
    vals["query2"] = quote_plus(vals["query2"])
    return (
        "http://vls2.icm.edu.pl/cgi-bin/search.pl?SearchTemplate=search_form.advanced"
        + "&search_field=%(query)s"
        + "&fields=%(query-fields)s"
        + "&AdvBooleanJoiner=%(query-join)s"
        + "&search_field2=%(query2)s"
        + "&fields2=%(query2-fields)s"
        + "&Database=elsevier_1990"
        + "&Database=springer_1990"
        + "&Category=all_categories"
        + "&ArticleType=All+Types..."
        + "&Language="
        + "&daterange=yearrange"
        + "&fromyear=%(from)d"
        + "&toyear=%(to)d"
        + "&Max=%(num)d"
        + "&Start=%(start)d"
        + "&Order="
        + "&GetSearchResults=Submit+Query"
    ) % vals
开发者ID:rzeszut,项目名称:article-downloader,代码行数:25,代码来源:url.py


示例4: addDir

def addDir(name, url, mode, iconimage, description, isFolder=True, channelName=None, background=None, isTvGuide=False, channelID=None, categoryID=None):
	chName = channelName if channelName is not None else ""
	liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
	liz.setInfo( type="Video", infoLabels={ "Title": name, "Plot": description} )
	

	if mode==3 or mode==4 or mode==7 or mode==8 or mode==10 or mode==11 or mode==99:
		isFolder=False
	
	if mode==3 or mode==4 or mode==10 or mode==11:
		liz.setProperty("IsPlayable","true")
		items = []

		if mode == 3:
			items.append((localizedString(30205).encode('utf-8'), 'XBMC.Container.Update({0}?url={1}&mode=9&iconimage={2}&displayname={3}&categoryid={4})'.format(sys.argv[0], urllib.quote_plus(url), iconimage, channelName, categoryID)))
			items.append((localizedString(30206).encode('utf-8'), 'XBMC.RunPlugin({0}?url={1}&categoryid={2}&mode=17)'.format(sys.argv[0], channelID, categoryID)))
		elif mode == 4:
			items.append((localizedString(30205).encode('utf-8'), 'XBMC.Container.Update({0}?url={1}&mode=9&iconimage={2}&displayname={3}&categoryid={4})'.format(sys.argv[0], urllib.quote_plus(url), iconimage, channelName, categoryID)))
			items.append((localizedString(30207).encode('utf-8'), "XBMC.RunPlugin({0}?url={1}&mode=18)".format(sys.argv[0], channelID)))
			items.append((localizedString(30021).encode('utf-8'), 'XBMC.RunPlugin({0}?url={1}&mode=41&iconimage=-1)'.format(sys.argv[0], channelID)))
			items.append((localizedString(30022).encode('utf-8'), 'XBMC.RunPlugin({0}?url={1}&mode=41&iconimage=1)'.format(sys.argv[0], channelID)))
			items.append((localizedString(30023).encode('utf-8'), 'XBMC.RunPlugin({0}?url={1}&mode=41&iconimage=0)'.format(sys.argv[0], channelID)))
		elif mode == 10:
			if isTvGuide:
				items.append((localizedString(30205).encode('utf-8'), 'XBMC.Container.Update({0}?url={1}&mode=5&iconimage={2}&name={3}&categoryid={4})'.format(sys.argv[0], urllib.quote_plus(url), iconimage, channelName, categoryID)))
			items.append((localizedString(30206).encode('utf-8'), 'XBMC.RunPlugin({0}?url={1}&categoryid={2}&mode=17)'.format(sys.argv[0], channelID, categoryID)))
		elif mode == 11:
			if isTvGuide:
				items.append((localizedString(30205).encode('utf-8'), 'XBMC.Container.Update({0}?url={1}&mode=5&iconimage={2}&name={3}&categoryid={4})'.format(sys.argv[0], urllib.quote_plus(url), iconimage, channelName, categoryID)))
			items.append((localizedString(30207).encode('utf-8'), 'XBMC.RunPlugin({0}?url={1}&mode=18)'.format(sys.argv[0], channelID)))
			items.append((localizedString(30021).encode('utf-8'), 'XBMC.RunPlugin({0}?url={1}&mode=41&iconimage=-1)'.format(sys.argv[0], channelID)))
			items.append((localizedString(30022).encode('utf-8'), 'XBMC.RunPlugin({0}?url={1}&mode=41&iconimage=1)'.format(sys.argv[0], channelID)))
			items.append((localizedString(30023).encode('utf-8'), 'XBMC.RunPlugin({0}?url={1}&mode=41&iconimage=0)'.format(sys.argv[0], channelID)))

		liz.addContextMenuItems(items = items)
		
	elif mode == 2:
		liz.addContextMenuItems(items = 
			[(localizedString(30210).encode('utf-8'), 'XBMC.Container.Update({0}?mode=37&categoryid={1})'.format(sys.argv[0], urllib.quote_plus(channelName))),
			(localizedString(30212).encode('utf-8'), 'XBMC.Container.Update({0}?mode=38&categoryid={1})'.format(sys.argv[0], urllib.quote_plus(channelName))),
			(localizedString(30021).encode('utf-8'), 'XBMC.RunPlugin({0}?url={1}&mode=42&iconimage=-1)'.format(sys.argv[0], channelID)),
			(localizedString(30022).encode('utf-8'), 'XBMC.RunPlugin({0}?url={1}&mode=42&iconimage=1)'.format(sys.argv[0], channelID)),
			(localizedString(30023).encode('utf-8'), 'XBMC.RunPlugin({0}?url={1}&mode=42&iconimage=0)'.format(sys.argv[0], channelID))
			])
		
	elif mode == 16:
		liz.addContextMenuItems(items = 
			[(localizedString(30211).encode('utf-8'), 'XBMC.Container.Update({0}?mode=39)'.format(sys.argv[0])),
			(localizedString(30213).encode('utf-8'), 'XBMC.Container.Update({0}?mode=40)'.format(sys.argv[0]))])
	
	if background is not None:
		liz.setProperty("Fanart_Image", background)

	fullUrl = "{0}?url={1}&mode={2}&name={3}&iconimage={4}&description={5}".format(sys.argv[0], urllib.quote_plus(url), mode, urllib.quote_plus(name), urllib.quote_plus(iconimage), urllib.quote_plus(description))
	if channelName is not None:
		fullUrl = "{0}&displayname={1}".format(fullUrl, urllib.quote_plus(channelName))
	if categoryID is not None:
		fullUrl = "{0}&categoryid={1}".format(fullUrl, urllib.quote_plus(categoryID))
	ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=fullUrl, listitem=liz, isFolder=isFolder)
	return ok
开发者ID:Ralbarker,项目名称:xbmc-israel,代码行数:60,代码来源:default.py


示例5: _edit

  def _edit(self, folder=None, file=None):
    # set some vars
    files = None
    success = None

    # check for folder
    if folder:
      # check for the homepage file
      if file:
        # update the site
        success = self._update(folder, file)

      # get files in the folder
      files = self._make_req('https://www.googleapis.com/drive/v2/files?q=' +
        urllib.quote_plus('"%s" in parents and mimeType = "application/vnd.google-apps.document"' % folder))['items']

    # get the root folders
    folders = self._make_req('https://www.googleapis.com/drive/v2/files?q=' +
      urllib.quote_plus('"root" in parents and mimeType = "application/vnd.google-apps.folder"'))['items']

    # load the view
    template = template_helper.load('admin', {
      'folders': folders,
      'files': files,
      'success': success,
      'self_url': self.request.uri
    })

    self.response.out.write(template)
开发者ID:ahmednuaman,项目名称:gdrive-cms-py-gae,代码行数:29,代码来源:admin_controller.py


示例6: instance_url

 def instance_url(self):
     self.id = util.utf8(self.id)
     self.charge = util.utf8(self.transfer)
     base = Transfer.class_url()
     cust_extn = urllib.quote_plus(self.transfer)
     extn = urllib.quote_plus(self.id)
     return "%s/%s/reversals/%s" % (base, cust_extn, extn)
开发者ID:brianmc,项目名称:stripe-python,代码行数:7,代码来源:resource.py


示例7: set_proxy

def set_proxy():
    proxy = os.getenv('PROXY', '')
    if proxy:
        interface_ip_list = get_all_interface_ip()
        predefine_no_proxy_list = ".xip.io,172.30.0.0/16,172.17.0.0/16,%s" % socket.gethostname()
        proxy_user = quote_plus(os.getenv('PROXY_USER',''))
        if proxy_user:
            proxy_password = quote_plus(os.getenv('PROXY_PASSWORD',''))
            http_proxy_url = "http://%s:%[email protected]%s" % (proxy_user, proxy_password, proxy)
            https_proxy_url = "https://%s:%[email protected]%s" % (proxy_user, proxy_password, proxy)
        else:
            http_proxy_url = "http://%s" % proxy
            https_proxy_url = "https://%s" % proxy
        # openshift proxy setup
        if system(('sed -i -e "/^#HTTP_PROXY=*/cHTTP_PROXY=%s"'
                   ' -e "/^#HTTPS_PROXY=*/cHTTPS_PROXY=%s"'
                   ' -e "/^#NO_PROXY=*/cNO_PROXY=%s%s"'
                ' %s') % (http_proxy_url, http_proxy_url, interface_ip_list,
                          predefine_no_proxy_list, OPENSHIFT_OPTION))[2]:
            return ("Permisison denined: %s" % OPENSHIFT_OPTION)
        # docker daemon proxy setup
        if not os.path.isdir('/etc/systemd/system/docker.service.d'):
            subprocess.call("mkdir /etc/systemd/system/docker.service.d", shell=True)
        env_file_content = ('[Service]\n'
                'Environment="HTTP_PROXY=%s" "NO_PROXY=localhost,127.0.0.1,::1,.xip.io"\n') \
                        % (http_proxy_url)
        try:
            with open('/etc/systemd/system/docker.service.d/http-proxy.conf', 'w') as fh:
                fh.write(env_file_content)
            subprocess.call('systemctl daemon-reload', shell=True)
            return subprocess.call('systemctl restart docker', shell=True)
        except IOError as err:
            return err
开发者ID:projectatomic,项目名称:adb-utils,代码行数:33,代码来源:sccli.py


示例8: build_rest_path

    def build_rest_path(self, bucket=None, key=None, params=None, prefix=None) :
        """
        Given a RiakClient, RiakBucket, Key, LinkSpec, and Params,
        construct and return a URL.
        """
        # Build 'http://hostname:port/prefix/bucket'
        path = ''
        path += '/' + (prefix or self._prefix)

        # Add '.../bucket'
        if bucket is not None:
            path += '/' + urllib.quote_plus(bucket._name)

        # Add '.../key'
        if key is not None:
            path += '/' + urllib.quote_plus(key)

        # Add query parameters.
        if params is not None:
            s = ''
            for key in params.keys():
                if s != '': s += '&'
                s += urllib.quote_plus(key) + '=' + urllib.quote_plus(str(params[key]))
            path += '?' + s

        # Return.
        return self._host, self._port, path
开发者ID:rvoicilas,项目名称:riak-python-client,代码行数:27,代码来源:http.py


示例9: query_lastfm

    def query_lastfm(self, artist, title):
        """Use track.getinfo to get track metadata. If it fails, fall back on
        track.search"""
        encoded_artist = quote_plus(artist.encode('utf-8'))
        encoded_title = quote_plus(title.encode('utf-8'))
        track_info = self.getinfo(encoded_artist, encoded_title)
        if not track_info:
            track_info = self.tracksearch(encoded_artist, encoded_title)
            if not track_info:
                return None
            fixed_artist = track_info['artist'][:256]
            fixed_title = track_info['name'][:256]
            mbid = track_info['mbid']
            toptags = self.get_tags(mbid)
        else:
            fixed_artist = track_info['artist']['name'][:256]
            fixed_title = track_info['name'][:256]
            mbid = track_info['mbid']
            toptags = track_info.get('toptags', [])
        if not mbid:
            if ';' in artist:
                # Try slicing into multiple artists and retry using the first one listed
                return self.query_lastfm(artist.split(';')[0], title)

            # Cannot continue without an MBID.
            return None
        mbid, fixed_artist, fixed_title = self.query_musicbrainz(
            mbid, fixed_artist, fixed_title)
        tags = self.extract_tags(toptags)
        return {'artist': fixed_artist, 'title': fixed_title, 'mbid': mbid,
                'tags': tags}
开发者ID:thoastbrot,项目名称:radiostats,代码行数:31,代码来源:normalize.py


示例10: addDirectoryItem

def addDirectoryItem(name, url, mode, label2='', infoType="Music", infoLabels = {}, isFolder=True):
    liz=xbmcgui.ListItem(name, label2)
    if not infoLabels:
        infoLabels = {"Title": name }
    liz.setInfo( infoType, infoLabels )
    
    v = "?name=%s&url=%s" % (urllib.quote_plus(name.encode('utf-8')), urllib.quote_plus(url.encode('utf-8')), )
    action1 = 'XBMC.RunPlugin(plugin://plugin.audio.listenliveeu/?add%s%s)' % (v, '\n')
    action2 = 'XBMC.RunPlugin(plugin://plugin.audio.listenliveeu/?remfav%s%s)' % (v, '\n')
    action3 = 'XBMC.RunPlugin(plugin://plugin.audio.listenliveeu/?removeall)'
    
    if mode==2:
        try:
            liz.addContextMenuItems([(__language__(30004), action1), (__language__(30006), action3)])
        except:
            errorOK("addDirectoryItem()")
        
    elif mode==3:
        try:
            liz.addContextMenuItems([(__language__(30005), action2), (__language__(30006), action3)])
        except:
            errorOK("addDirectoryItem()")

    u = "%s?url=%s&mode=%s&name=%s" % (sys.argv[0], urllib.quote_plus(url), mode, urllib.quote_plus(name.encode('utf-8')), )
    log("%s" % u)
    return xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=isFolder)
开发者ID:Xycl,项目名称:plugin.audio.listenliveeu,代码行数:26,代码来源:default.py


示例11: __call__

    def __call__(self, r):
        # modify and return the request
    
        parsed = urlparse.urlparse(r.url)
        url = parsed.geturl().split('?',1)[0]
        url_params= urlparse.parse_qs(parsed.query)
        
        #normalize the list value
        for param in url_params:
            url_params[param] = url_params[param][0]
        
        url_params['apikey'] = self.apikey
        
        keys = sorted(url_params.keys())

        sig_params = []
        for k in keys:
            sig_params.append(k + '=' + urllib.quote_plus(url_params[k]).replace("+", "%20"))
       
        query = '&'.join(sig_params)

        signature = base64.b64encode(hmac.new(
            self.secretkey,
            msg=query.lower(),
            digestmod=hashlib.sha1
        ).digest())

        
        query += '&signature=' + urllib.quote_plus(signature)

        r.url = url + '?' + query
        
        return r
开发者ID:halr9000,项目名称:SplunkModularInputsPythonFramework,代码行数:33,代码来源:authhandlers.py


示例12: addDir

def addDir(title, url, mode):
    sys_url = sys.argv[0] + '?title=' + urllib.quote_plus(title) + '&url=' + urllib.quote_plus(url) + '&mode=' + urllib.quote_plus(str(mode))

    item = xbmcgui.ListItem(title, iconImage='DefaultFolder.png', thumbnailImage='')
    item.setInfo( type='Video', infoLabels={'Title': title} )

    xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=sys_url, listitem=item, isFolder=True)
开发者ID:kantorv,项目名称:xbmc-kinodom,代码行数:7,代码来源:addon.py


示例13: connect

def connect():
    """
    Test the given login/password agains't the database
    If it's ok, save them encrypted in the session
    and return the state of the connection
    """
    try:
        values = {
            'engine':   request.form['server-engine'],
            'username': urllib.quote_plus(request.form['username']),
            'password': urllib.quote_plus(request.form['password']) if 'password' in request.form else '',
            'host':     urllib.quote_plus(request.form['server-hostname']),
            'port':     int(request.form['server-port'])
        }

        cnx = create_engine('%s://%s:%[email protected]%s:%d' % (
                                values['engine'],
                                values['username'],
                                values['password'],
                                values['host'],
                                values['port'],
                            ))
        cnx.connect()

        token = uuid.uuid4().hex
        g.session = session_store.create(request, token, values)
        
        return jsonify({
            'token': token,
            'expire': mktime(g.session.expire.timetuple())
        })
    except OperationalError as e:
        response = jsonify ({'code': e.orig[0], 'message': e.orig[1]})
        response.status_code = 400
        return response
开发者ID:skual,项目名称:backend-flask,代码行数:35,代码来源:authentication.py


示例14: __init__

    def __init__(self, q, start=1, count=100, wait=10, asynchronous=False, cached=True, 
                 sort=SORT_RELEVANCE, match=MATCH_ANY):

        try: q = q.encode("utf-8")
        except:
            pass

        if cached: 
            cache = "flickr"
        else:
            cache = None
        
        url  = "http://api.flickr.com/services/rest/?method="
        if q == "recent":
            url += "flickr.photos.getRecent"
        else:
            url += "flickr.photos.search"
        if isinstance(q, (list, tuple)):
            q = [quote_plus(q) for q in q]
            q = ",".join(q)
            url += "&tags=" + quote_plus(q)
            url += "&tag_mode=" + match
        else:
            url += "&text=" + quote_plus(q)
        url += "&page=" + str(start)
        url += "&per_page=" + str(count)
        url += "&sort=" + disambiguate_sort(sort)
        url += "&api_key=" + API_KEY
        
        URLAccumulator.__init__(self, url, wait, asynchronous, cache, ".xml", 1)
开发者ID:aoloe,项目名称:shoebot,代码行数:30,代码来源:flickr.py


示例15: add

 def add(self, service, name, category, title, iconimage, url, desc, page, folder=True, isPlayable=True):
     u = (
         sys.argv[0]
         + "?service="
         + service
         + "&name="
         + name
         + "&category="
         + category
         + "&title="
         + title
         + "&url="
         + urllib.quote_plus(url)
         + "&icon="
         + urllib.quote_plus(iconimage)
         + "&page="
         + urllib.quote_plus(page)
     )
     # log.info(str(u))
     if name == "main-menu" or name == "categories-menu":
         title = category
     if iconimage == "":
         iconimage = "DefaultVideo.png"
     liz = xbmcgui.ListItem(title, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
     liz.setProperty("fanart_image", iconimage)
     if isPlayable:
         liz.setProperty("IsPlayable", "true")
     liz.setInfo(
         type="Video", infoLabels={"Title": title, "Plot": desc, "Episode": "AAA", "Year": "2000", "Genre": "bbb"}
     )
     xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=folder)
开发者ID:gosiaiunia1,项目名称:KODI_PRIV,代码行数:31,代码来源:wykop.py


示例16: addDir

def addDir(name,url,mode,iconimage	,showContext=False, showLiveContext=False,isItFolder=True):
#	print name
#	name=name.decode('utf-8','replace')
	h = HTMLParser.HTMLParser()
	name= h.unescape(name.decode("utf8")).encode("ascii","ignore")
	#print  name
	#print url
	#print iconimage
	u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
	ok=True
#	print iconimage
	liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
	liz.setInfo( type="Video", infoLabels={ "Title": name } )

	if showContext==True:
		cmd1 = "XBMC.RunPlugin(%s&linkType=%s)" % (u, "DM")
		cmd2 = "XBMC.RunPlugin(%s&linkType=%s)" % (u, "LINK")
		cmd3 = "XBMC.RunPlugin(%s&linkType=%s)" % (u, "Youtube")
		liz.addContextMenuItems([('Play Youtube video',cmd3),('Play DailyMotion video',cmd1),('Play Tune.pk video',cmd2)])
	
	if showLiveContext==True:
		cmd1 = "XBMC.RunPlugin(%s&linkType=%s)" % (u, "RTMP")
		cmd2 = "XBMC.RunPlugin(%s&linkType=%s)" % (u, "HTTP")
		liz.addContextMenuItems([('Play RTMP Steam (flash)',cmd1),('Play Http Stream (ios)',cmd2)])
	
	ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=isItFolder)
	return ok
开发者ID:BERNAG,项目名称:ShaniXBMCWork,代码行数:27,代码来源:default.py


示例17: instance_url

 def instance_url(self):
     token = util.utf8(self.id)
     transfer = util.utf8(self.transfer)
     base = Transfer.class_url()
     cust_extn = urllib.quote_plus(transfer)
     extn = urllib.quote_plus(token)
     return "%s/%s/reversals/%s" % (base, cust_extn, extn)
开发者ID:VladStm,项目名称:try,代码行数:7,代码来源:resource.py


示例18: sign_s3

def sign_s3():
    # Load necessary information into the application:
    AWS_ACCESS_KEY = os.environ.get('AWS_ACCESS_KEY_ID')
    AWS_SECRET_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY')
    S3_BUCKET = os.environ.get('S3_BUCKET')

    # Collect information on the file from the GET parameters of the request:
    object_name = urllib.quote_plus(request.args.get('file_name'))
    mime_type = request.args.get('file_type')

    # Set the expiry time of the signature (in seconds) and declare the permissions of the file to be uploaded
    expires = int(time.time()+60*60*24)
    amz_headers = "x-amz-acl:public-read"
 
    # Generate the StringToSign:
    string_to_sign = "PUT\n\n%s\n%d\n%s\n/%s/%s" % (mime_type, expires, amz_headers, S3_BUCKET, object_name)

    # Generate the signature with which the StringToSign can be signed:
    signature = base64.encodestring(hmac.new(AWS_SECRET_KEY, string_to_sign.encode('utf8'), sha1).digest())
    # Remove surrounding whitespace and quote special characters:
    signature = urllib.quote_plus(signature.strip())

    # Build the URL of the file in anticipation of its imminent upload:
    url = 'https://%s.s3.amazonaws.com/%s' % (S3_BUCKET, object_name)

    
    content = json.dumps({
        'signed_request': '%s?AWSAccessKeyId=%s&Expires=%s&Signature=%s' % (url, AWS_ACCESS_KEY, expires, signature),
        'url': url,
    })
   
    return content
开发者ID:di445,项目名称:FlaskDirectUploader,代码行数:32,代码来源:application.py


示例19: addVideoDirR

def addVideoDirR(name, url, mode, iconimage, videoType="", desc="", duration="", year="", mpaa="", director="", genre="", rating=""):
    filename = (''.join(c for c in unicode(url, 'utf-8') if c not in '/\\:?"*|<>')).strip()+".jpg"
    coverFile = os.path.join(cacheFolderCoversTMDB, filename)
    fanartFile = os.path.join(cacheFolderFanartTMDB, filename)
    if os.path.exists(coverFile):
        iconimage = coverFile
    u = sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&thumb="+urllib.quote_plus(iconimage)
    ok = True
    liz = xbmcgui.ListItem(name, iconImage="DefaultTVShows.png", thumbnailImage=iconimage)
    liz.setInfo(type="video", infoLabels={"title": name, "plot": desc, "duration": duration, "year": year, "mpaa": mpaa, "director": director, "genre": genre, "rating": rating})
    if os.path.exists(fanartFile):
        liz.setProperty("fanart_image", fanartFile)
    elif os.path.exists(coverFile):
        liz.setProperty("fanart_image", coverFile)
    entries = []
    entries.append((translation(30134), 'RunPlugin(plugin://plugin.video.netflixbmc/?mode=playTrailer&url='+urllib.quote_plus(name)+')',))
    entries.append((translation(30115), 'RunPlugin(plugin://plugin.video.netflixbmc/?mode=removeFromQueue&url='+urllib.quote_plus(url)+')',))
    if videoType == "tvshow":
        entries.append((translation(30122), 'RunPlugin(plugin://plugin.video.netflixbmc/?mode=addSeriesToLibrary&url=&name='+str(name.strip())+'&seriesID='+str(url)+')',))
        if browseTvShows:
            entries.append((translation(30121), 'Container.Update(plugin://plugin.video.netflixbmc/?mode=playVideo&url='+urllib.quote_plus(url)+'&thumb='+urllib.quote_plus(iconimage)+')',))
        else:
            entries.append((translation(30118), 'Container.Update(plugin://plugin.video.netflixbmc/?mode=listSeasons&url='+urllib.quote_plus(url)+'&thumb='+urllib.quote_plus(iconimage)+')',))
    elif videoType == "movie":
        entries.append((translation(30122), 'RunPlugin(plugin://plugin.video.netflixbmc/?mode=addMovieToLibrary&url='+urllib.quote_plus(url)+'&name='+str(name.strip()+' ('+year+')')+')',))
    liz.addContextMenuItems(entries)
    ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=True)
    return ok
开发者ID:jomuji,项目名称:plugin.video.netflixbmc,代码行数:28,代码来源:default.py


示例20: addDir

def addDir(name,url,mode,iconimage):
        u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
        ok=True
        liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
        liz.setProperty('fanart_image', fanart)
        ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
        return ok
开发者ID:azumimuo,项目名称:family-xbmc-addon,代码行数:7,代码来源:freeview.py



注:本文中的urllib.quote_plus函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python urllib.request函数代码示例发布时间:2022-05-27
下一篇:
Python urllib.quote函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap