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

Python urllib.quote函数代码示例

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

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



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

示例1: application

def application(req):
    #doGzip = 0
    #try:
    #    if string.find(os.environ["HTTP_ACCEPT_ENCODING"], "gzip") != -1:
    #        doGzip = 1
    #except:
    #    pass

    treeid = req.params.get("treeid")
    module = req.params.get("module")
    branch = req.params.get("branch")
    mindate = req.params.get("mindate")
    maxdate = req.params.get("maxdate")
    xml_nofiles = req.params.get("xml_nofiles")

    if not treeid or not module or not branch or not mindate or not maxdate:
        raise exc.HTTPBadRequest("ERROR")

    url = bonsai + "?" + "branchtype=match&sortby=Date&date=explicit&cvsroot=%2Fcvsroot&xml=1"
    url += "&treeid=%s&module=%s&branch=%s&mindate=%s&maxdate=%s" % (quote(treeid), quote(module), quote(branch), quote(mindate), quote(maxdate))

    if xml_nofiles:
        url += "&xml_nofiles=1"

    urlstream = urllib.urlopen(url)
    resp = Response(content_type='text/xml')
    for s in urlstream:
        resp.write(s)
    urlstream.close()
    return resp
开发者ID:mnoorenberghe,项目名称:graphs,代码行数:30,代码来源:bonsaibouncer_cgi.py


示例2: tag_feed

def tag_feed(request, tag, full_text = False):
    # horrible special-case for the tag feed
    server = "http://%s"%(request.META['SERVER_NAME'] or 'localhost')
    feedclass = feed_engine( 'atom' )

    feed = feedclass(
      title = 'things tagged %s on jerakeen.org'%tag,
      link = "%s/tags/%s/"%(server, urllib.quote(tag.encode('utf-8'))),
      description = "",
      author_name = "Tom Insam",
      author_email = "[email protected]",
      author_link = "http://jerakeen.org/",
      feed_url = "%s/tags/%s/feed/"%(server,urllib.quote(tag.encode('utf-8'))),
    );

    tags = filter( lambda x: len(x), tag.split('+') )
    page_list = Page.pages_tagged(tags)[:15]

    for p in page_list:
        if full_text:
            data = p.body
        else:
            data = p.excerpt or p.body
        image = '<img src="%s" style="float:left" width="75" height="75">'%p.thumb_url()
        feed.add_item(
            p.title,
            p.really_absolute_url(),
            image + pagefilter( data ),
            pubdate = p.date )

    return HttpResponse(
        feed.writeString('utf-8'), mimetype = feed.mime_type )
开发者ID:tominsam,项目名称:cougar,代码行数:32,代码来源:views.py


示例3: handle_wowwiki

def handle_wowwiki(bot, ievent):
    """ wikipedia <what> .. search wikipedia for <what> """
    if not ievent.rest:
        ievent.missing('<what>')
        return
    what = ""
    lang = 'en'
    for i in ievent.rest.split():
        first = i[0].upper()
        rest = i[1:]
        if i.startswith('-'):
            if len(i) != 3:
                ievent.reply('invalid option')
                return
            lang = i[1:]
            continue
        what += "%s%s " % (first, rest)
    what = what.strip().replace(' ', '_')
    url = 'http://wowwiki.com/wiki/Special:Export/%s' % quote(what.encode('utf-8'))
    url2 = 'http://wowwiki.com/wiki/%s' % quote(what.encode('utf-8'))
    txt = getwikidata(url, ievent)
    if not txt:
        return
    if '#REDIRECT' in txt or '#redirect' in txt:
        redir = ' '.join(txt.split()[1:])
        url = 'http://wowwiki.com/wiki/Special:Export/%s' % quote(redir.encode('utf-8'))
        url2 = 'http://wowwiki.com/wiki/%s' % quote(redir.encode('utf-8'))
        txt = getwikidata(url, ievent)
    if not txt:
        return
    res = ['%s ===> ' % url2, ]
    res += splittxt(striphtml(txt).strip())
    ievent.reply(res)
开发者ID:RetroRodent,项目名称:my-gozerbot,代码行数:33,代码来源:wowwiki.py


示例4: _encode_multipart

def _encode_multipart(vars, content_type):
    """Encode a multipart request body into a string"""
    boundary_match = re.search(r'boundary=([^ ]+)', content_type, re.I)
    if not boundary_match:
        raise ValueError('Content-type: %r does not contain boundary' % content_type)
    boundary = boundary_match.group(1).strip('"')
    lines = []
    for name, value in vars.iteritems():
        lines.append('--%s' % boundary)
        ## FIXME: encode the name like this?
        assert name is not None, 'Value associated with no name: %r' % value
        disp = 'Content-Disposition: form-data; name="%s"' % urllib.quote(name)
        if getattr(value, 'filename', None):
            disp += '; filename="%s"' % urllib.quote(value.filename)
        lines.append(disp)
        ## FIXME: should handle value.disposition_options
        if getattr(value, 'type', None):
            ct = 'Content-type: %s' % value.type
            if value.type_options:
                ct += ''.join(['; %s="%s"' % (ct_name, urllib.quote(ct_value))
                               for ct_name, ct_value in sorted(value.type_options.items())])
            lines.append(ct)
        lines.append('')
        if hasattr(value, 'value'):
            lines.append(value.value)
        else:
            lines.append(value)
    lines.append('--%s--' % boundary)
    return '\r\n'.join(lines)
开发者ID:daevaorn,项目名称:scraperasaservice.appspot.com,代码行数:29,代码来源:request.py


示例5: urlencode

    def urlencode(self, safe=None):
        """
        Returns an encoded string of all query string arguments.

        :arg safe: Used to specify characters which do not require quoting, for
            example::

                >>> q = QueryDict('', mutable=True)
                >>> q['next'] = '/a&b/'
                >>> q.urlencode()
                'next=%2Fa%26b%2F'
                >>> q.urlencode(safe='/')
                'next=/a%26b/'

        """
        output = []
        if safe:
            encode = lambda k, v: '%s=%s' % ((quote(k, safe), quote(v, safe)))
        else:
            encode = lambda k, v: urlencode({k: v})
        for k, list_ in self.lists():
            k = smart_str(k, self.encoding)
            output.extend([encode(k, smart_str(v, self.encoding))
                           for v in list_])
        return '&'.join(output)
开发者ID:farstarinc,项目名称:django,代码行数:25,代码来源:__init__.py


示例6: test_default_quoting

 def test_default_quoting(self):
     # Make sure all characters that should be quoted are by default sans
     # space (separate test for that).
     should_quote = [chr(num) for num in range(32)]  # For 0x00 - 0x1F
     should_quote.append('<>#%"{}|\^[]`')
     should_quote.append(chr(127))  # For 0x7F
     should_quote = "".join(should_quote)
     for char in should_quote:
         result = urllib.quote(char)
         self.assertEqual(
             hexescape(char),
             result,
             "using quote(): %s should be escaped to %s, not %s" % (char, hexescape(char), result),
         )
         result = urllib.quote_plus(char)
         self.assertEqual(
             hexescape(char),
             result,
             "using quote_plus(): " "%s should be escapes to %s, not %s" % (char, hexescape(char), result),
         )
     del should_quote
     partial_quote = "ab[]cd"
     expected = "ab%5B%5Dcd"
     result = urllib.quote(partial_quote)
     self.assertEqual(expected, result, "using quote(): %s != %s" % (expected, result))
     result = urllib.quote_plus(partial_quote)
     self.assertEqual(expected, result, "using quote_plus(): %s != %s" % (expected, result))
     self.assertRaises(TypeError, urllib.quote, None)
开发者ID:plirof,项目名称:minibloq_v0.83,代码行数:28,代码来源:test_urllib.py


示例7: _gen_signed_data

    def _gen_signed_data(self, base_url, method="GET", sign_method='HMAC-SHA1', **params):
        args = {'oauth_consumer_key': self.consumer_key,
                'oauth_timestamp': self.__timestamp(),
                'oauth_nonce': self.__nonce(),
                'oauth_version': '1.0'}
                
        args.update(params)

        if sign_method == 'HMAC-SHA1':
            args['oauth_signature_method'] = 'HMAC-SHA1'

            key = self.consumer_secret + "&"

            if self.token is not None:
                args['oauth_token'] = self.token.oauth_token
                key += urllib.quote(self.token.oauth_token_secret, '')

            #would use urlencode, but it doesn't sort arguments
            #pargs = [sorted('%s=%s' % (k,v) for k,v in args.values())]
            message = '&'.join(
                    urllib.quote(i, '') for i in [method.upper(), base_url,
                                    urllib.urlencode(sorted(args.iteritems()))])

            args['oauth_signature'] = hmac.new(key, message, hashlib.sha1
                                                ).digest().encode('base64')[:-1]

        # Add other sign_methods here   
        else:
            raise self.UnknownSignatureException("Unknown signature method %s" % sign_method)

        return args
开发者ID:genova,项目名称:oauth-repoze,代码行数:31,代码来源:oauth.py


示例8: replace_or_add_query

def replace_or_add_query(url, query, exclusions=None):
    """
    Adds field/value pair to the provided url as a query string if the
    key isn't already in the url, or replaces it otherwise.

    Appends the proper pair separator (?&) based on the input url

    Inputs:
    :url: URL that query string should be appended to
    :query: Query string(s) to add to :url:
    :exclusions: List of keys that should not be copied; common keys
        include 'vs' and 'z'

    Outputs:
    :url: Input url with query string appended
    """
    if not exclusions:
        exclusions = []
    if len(query) > 1 and query[0] in ['?', '&']:
        query = query[1:]
        query = query.encode('utf-8')
        url = url.encode('utf-8')
        url = urlparse.urlparse(url)
        old_query = urlparse.parse_qsl(url.query, keep_blank_values=True)
        old_keys = [q[0] for q in old_query]
        # make a lower-case copy of old_keys so we can do some comparisons
        insensitive_keys = map(str.lower, old_keys)

        new_query = urlparse.parse_qsl(query, keep_blank_values=True)

        # For each source code that we are going to add
        for new_index in range(len(new_query)):
            # Make sure we are not adding a source code that should be excluded
            if new_query[new_index][0] not in exclusions:
                try:
                    # Case-insensitively determine if the new source code
                    # is already applied
                    old_index = insensitive_keys.index(
                        new_query[new_index][0].lower())
                except ValueError:
                    # The current source code is not applied; apply it
                    old_query.append(new_query[new_index])
                else:
                    # The current source code is already applied; replace its
                    # value, keeping the case of the old parameter
                    old_query[old_index] = (old_query[old_index][0],
                                            new_query[new_index][1])

        # parse_qsl unencodes the query that you pass it; Re-encode the query
        # parameters when reconstructing the string.
        old_query = '&'.join(['='.join([urllib.quote(k, safe=','),
                                        urllib.quote(v, safe=',')])
                             for k, v in old_query])
        url = url._replace(query=old_query)
        url = urlparse.urlunparse(url)
    else:
        parts = url.split('#')
        parts[0] += query
        url = '#'.join(parts)
    return url
开发者ID:vfulco,项目名称:MyJobs,代码行数:60,代码来源:helpers.py


示例9: handle_upload

 def handle_upload(self):
   results = []
   blob_keys = []
   for name, fieldStorage in self.request.POST.items():
       if type(fieldStorage) is unicode:
           continue
       result = {}
       result['name'] = re.sub(r'^.*\\','',fieldStorage.filename)
       result['type'] = fieldStorage.type
       result['size'] = self.get_file_size(fieldStorage.file)
       if self.validate(result):
           blob_key = str(self.write_blob(fieldStorage.value, result))
           blob_keys.append(blob_key)
           result['deleteType'] = 'DELETE'
           result['deleteUrl'] = self.request.host_url +\
               '/?key=' + urllib.quote(blob_key, '')
           if (IMAGE_TYPES.match(result['type'])):
               try:
                   result['url'] = images.get_serving_url(
                       blob_key,
                       secure_url=self.request.host_url.startswith(
                           'https'
                       )
                   )
                   result['thumbnailUrl'] = result['url'] +\
                       THUMBNAIL_MODIFICATOR
               except:  # Could not get an image serving url
                   pass
           if not 'url' in result:
               result['url'] = self.request.host_url +\
                   '/' + blob_key + '/' + urllib.quote(
                       result['name'].encode('utf-8'), '')
       results.append(result)
   deferred.defer(cleanup,blob_keys,_countdown=EXPIRATION_TIME)
   return results
开发者ID:tgarc,项目名称:apt-miniproject,代码行数:35,代码来源:services.py


示例10: execute_request

    def execute_request(self, method, *stuff) :

        enc_method = urllib.quote(method)
        url = self.host + self.endpoint + enc_method + ".json"

        if len(stuff) :

            enc_stuff = []
            
            for thing in stuff :
                if not thing :
                    continue
                
                enc_stuff.append(urllib.quote(thing))

            if len(enc_stuff) :
                url = "%s/%s" % (url, "/".join(enc_stuff))

        data = None
        
        headers = {
            'api_key' : self.api_key,
            }

        try :
            req = urllib2.Request(url, data, headers)
            res = urllib2.urlopen(req)
        except Exception, e :
            raise e
开发者ID:hayyhu,项目名称:wordnik-tools,代码行数:29,代码来源:wordnik.py


示例11: Configure

    def Configure(self, prefix="XBMC-Event", xbmcip="192.168.1.1", xbmchttpport=8080, zone="224.0.0.2", port=8278, selfXbmceventbroadcast=False, payDelim="<b></b>"):
        panel = eg.ConfigPanel(self)

        editCtrl = panel.TextCtrl(prefix)
        xbmcipCtrl = panel.TextCtrl(xbmcip)
        xbmchttpportCtrl = panel.SpinIntCtrl(xbmchttpport, min=1, max=65535)
        zoneCtrl = panel.TextCtrl(zone)
        portCtrl = panel.SpinIntCtrl(port, min=1, max=65535)
        selfXbmceventbroadcastCtrl=panel.CheckBox(selfXbmceventbroadcast)
        payDelimCtrl = panel.TextCtrl(payDelim)

        panel.AddLine(self.text.eventPrefix, editCtrl)
        panel.AddLine(self.text.xbmcip, xbmcipCtrl)
        panel.AddLine(self.text.xbmchttpport, xbmchttpportCtrl)
        panel.AddLine(self.text.zone, zoneCtrl)
        panel.AddLine(self.text.port, portCtrl)

        panel.AddLine(self.text.selfXbmceventbroadcast,selfXbmceventbroadcastCtrl)
        panel.AddLine("Payload Delimiter", payDelimCtrl)

        while panel.Affirmed():
            panel.SetResult(editCtrl.GetValue(),xbmcipCtrl.GetValue(),int(xbmchttpportCtrl.GetValue()),zoneCtrl.GetValue(),int(portCtrl.GetValue()),selfXbmceventbroadcastCtrl.GetValue(), payDelimCtrl.GetValue() )
            v_header = urllib.quote("This is the Header")

            v_message = urllib.quote("This is the Message")

	    host_xbmc = xbmcipCtrl.GetValue()
	    port_xbmc = int(xbmchttpportCtrl.GetValue())
	    udp_xbmc = int(portCtrl.GetValue())
	    url_xbmc = "http://" + str(host_xbmc) + ":" + str(port_xbmc) + "/xbmcCmds/xbmcHttp?command=SetBroadcast&parameter=2;" + str(udp_xbmc) + "(Notification(" + v_header + "," + v_message + "))"
            print "str(url_xbmc)"
	    try:
				urllib.urlopen(url_xbmc)
	    except IOError:
				print 'Connection error'
开发者ID:garbear,项目名称:EventGhost,代码行数:35,代码来源:__init__.py


示例12: get_authenticated_user

 def get_authenticated_user(self, server_ticket):
     """
     Requests the user's information from the CAS server using the given
     *server_ticket* and calls ``self._on_auth`` with the resulting user
     dict.
     """
     cas_version = self.settings.get('cas_version', 2)
     cas_server = self.settings.get('cas_server')
     ca_certs = self.settings.get('cas_ca_certs', None)
     if not cas_server.endswith('/'):
         cas_server += '/'
     service_url = "%sauth" % self.base_url
     #validate the ST
     validate_suffix = 'proxyValidate'
     if cas_version == 1:
         validate_suffix = 'validate'
     validate_url = (
         cas_server +
         validate_suffix +
         '?service=' +
         quote(service_url) +
         '&ticket=' +
         quote(server_ticket)
     )
     logging.debug("Fetching CAS URL: %s" % validate_url)
     validate_cert = False
     if ca_certs:
         validate_cert = True
     http_client = tornado.httpclient.AsyncHTTPClient()
     http_client.fetch(
         validate_url, validate_cert=validate_cert, callback=self._on_auth)
开发者ID:Lipvun,项目名称:GateOne,代码行数:31,代码来源:authentication.py


示例13: _get_all

 def _get_all(self, element_map, initial_query_string='',
              headers=None, **params):
     l = []
     for k,v in params.items():
         k = k.replace('_', '-')
         if  k == 'maxkeys':
             k = 'max-keys'
         if isinstance(v, unicode):
             v = v.encode('utf-8')
         if v is not None and v != '':
             l.append('%s=%s' % (urllib.quote(k), urllib.quote(str(v))))
     if len(l):
         s = initial_query_string + '&' + '&'.join(l)
     else:
         s = initial_query_string
     response = self.connection.make_request('GET', self.name,
             headers=headers, query_args=s)
     body = response.read()
     boto.log.debug(body)
     if response.status == 200:
         rs = ResultSet(element_map)
         h = handler.XmlHandler(rs, self)
         xml.sax.parseString(body, h)
         return rs
     else:
         raise self.connection.provider.storage_response_error(
             response.status, response.reason, body)
开发者ID:corymintz,项目名称:boto,代码行数:27,代码来源:bucket.py


示例14: find_books

 def find_books(self, search_text):
     if _NEW_TOOLBAR_SUPPORT:
         self.enable_button(False)
     else:
         self._books_toolbar.enable_button(False)
     self.clear_downloaded_bytes()
     textbuffer = self.textview.get_buffer()
     textbuffer.set_text(_('Performing lookup, please wait') + '...')
     self.book_selected = False
     self.ls.clear()
     search_tuple = search_text.lower().split()
     if len(search_tuple) == 0:
         self._alert(_('Error'), _('You must enter at least one search word.'))
         if _NEW_TOOLBAR_SUPPORT:
             self.search_entry.grab_focus()
         else:
             self._books_toolbar.search_entry.grab_focus()
         return
     FL = urllib.quote('fl[]')
     SORT = urllib.quote('sort[]')
     self.search_url = 'http://www.archive.org/advancedsearch.php?q=' +  \
         urllib.quote('(title:(' + search_text.lower() + ') OR creator:(' + search_text.lower() +')) AND format:(DJVU)')
     self.search_url += '&' + FL + '=creator&' + FL + '=description&' + FL + '=format&' + FL + '=identifier&'  \
         + FL + '=language'
     self.search_url += '&' + FL +  '=publisher&' + FL + '=subject&' + FL + '=title&' + FL + '=volume'
     self.search_url += '&' + SORT + '=title&' + SORT + '&' + SORT + '=&rows=500&save=yes&fmt=csv&xmlsearch=Search'
     GObject.idle_add(self.download_csv,  self.search_url)
开发者ID:leonardcj,项目名称:getiabooks,代码行数:27,代码来源:GetIABooksActivity.py


示例15: get_current_url

def get_current_url(environ, root_only=False, strip_querystring=False,
                    host_only=False):
    """A handy helper function that recreates the full URL for the current
    request or parts of it.  Here an example:

    >>> from werkzeug import create_environ
    >>> env = create_environ("/?param=foo", "http://localhost/script")
    >>> get_current_url(env)
    'http://localhost/script/?param=foo'
    >>> get_current_url(env, root_only=True)
    'http://localhost/script/'
    >>> get_current_url(env, host_only=True)
    'http://localhost/'
    >>> get_current_url(env, strip_querystring=True)
    'http://localhost/script/'

    :param environ: the WSGI environment to get the current URL from.
    :param root_only: set `True` if you only want the root URL.
    :param strip_querystring: set to `True` if you don't want the querystring.
    :param host_only: set to `True` if the host URL should be returned.
    """
    tmp = [environ['wsgi.url_scheme'], '://', get_host(environ)]
    cat = tmp.append
    if host_only:
        return ''.join(tmp) + '/'
    cat(urllib.quote(environ.get('SCRIPT_NAME', '').rstrip('/')))
    if root_only:
        cat('/')
    else:
        cat(urllib.quote('/' + environ.get('PATH_INFO', '').lstrip('/')))
        if not strip_querystring:
            qs = environ.get('QUERY_STRING')
            if qs:
                cat('?' + qs)
    return ''.join(tmp)
开发者ID:s0undt3ch,项目名称:werkzeug,代码行数:35,代码来源:wsgi.py


示例16: request

    def request(self, type, data, update=True):
        query = []

        # if user has defined their own _t, then include necessary _d
        if "_t" in data:
            data["_d"] = 1
        else:
            data["_t"] = self.now().strftime("%s")

        # add customer key to data sent
        data["_k"] = self._key

        if update:
            data["_p"] = self._id

        for key, val in data.items():
            query.append(urllib.quote(str(key)) + "=" + urllib.quote(str(val)))

        try:
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            host, port = self._host.split(":")
            sock.connect((host, int(port)))
            sock.setblocking(0)  # 0 is non-blocking

            get = "GET /" + type + "?" + "&".join(query) + " HTTP/1.1\r\n"
            out = get
            out += "Host: " + host + "\r\n"
            out += "Connection: Close\r\n\r\n"
            sock.send(out)
            sock.close()
        except:
            self.logm("Could not transmit to " + self._host)
开发者ID:gamechanger,项目名称:KISSmetrics-python,代码行数:32,代码来源:__init__.py


示例17: __init__

    def __init__(self, environ, start_response, charset='utf-8'):
        self.charset = charset
        self.start_response = start_response
        self.environ = environ
        self.environ['REQUEST_URI'] = get_full_url(self.environ)

        # copy a reference to the request object
        # into the environ so wsgi middlewares
        # can communicate with it.
        environ['colubrid.request'] = self

        # get absolute path to script
        root = self.environ.get('SCRIPT_NAME', '/')
        if not root or not root.startswith('/'):
            root = '/' + root
        self.environ['SCRIPT_ROOT'] = root

        # get the full application request
        url = ''.join([
            quote(self.environ['SCRIPT_NAME']),
            quote(self.environ.get('PATH_INFO', ''))
        ])
        if not url.startswith('/'):
            url = '/' + url
        self.environ['APPLICATION_REQUEST'] = url
开发者ID:w495,项目名称:colubrid,代码行数:25,代码来源:request.py


示例18: _listing_pages_iter

 def _listing_pages_iter(self, lcontainer, lprefix, env):
     lpartition, lnodes = self.app.container_ring.get_nodes(
         self.account_name, lcontainer)
     marker = ''
     while True:
         lreq = Request.blank('i will be overridden by env', environ=env)
         # Don't quote PATH_INFO, by WSGI spec
         lreq.environ['PATH_INFO'] = \
             '/%s/%s' % (self.account_name, lcontainer)
         lreq.environ['REQUEST_METHOD'] = 'GET'
         lreq.environ['QUERY_STRING'] = \
             'format=json&prefix=%s&marker=%s' % (quote(lprefix),
                                                  quote(marker))
         lnodes = self.app.sort_nodes(lnodes)
         lresp = self.GETorHEAD_base(
             lreq, _('Container'), lpartition, lnodes, lreq.path_info,
             len(lnodes))
         if 'swift.authorize' in env:
             lreq.acl = lresp.headers.get('x-container-read')
             aresp = env['swift.authorize'](lreq)
             if aresp:
                 raise ListingIterNotAuthorized(aresp)
         if lresp.status_int == HTTP_NOT_FOUND:
             raise ListingIterNotFound()
         elif not is_success(lresp.status_int):
             raise ListingIterError()
         if not lresp.body:
             break
         sublisting = json.loads(lresp.body)
         if not sublisting:
             break
         marker = sublisting[-1]['name'].encode('utf-8')
         yield sublisting
开发者ID:saebyuk,项目名称:swift,代码行数:33,代码来源:obj.py


示例19: write_installed_packages_list

def write_installed_packages_list():
    """
    Saves the installed package list and
    their location (file over-writen depends
    on run as root or as a normal user)
    """
    global installed_packages_list
    try:
        tmp=open(os.path.join(dataset_conf_path,"installed.lst.2"),"w")
    except IOError:
        raise RuntimeError("[cf] fatal: cannot create temp file")
    else:
        # ok, probably worked?
        for package in installed_packages_list.values():
            # adds only packages that are readable for
            # this user (maybe some site-installed datasets
            # are out of his reach)
            #
            if package.where!=None and \
                    file_access_rights(os.path.join(package.where,package.name),
                                      os.F_OK | os.R_OK):
                print(
                    " ".join(map(str,[ package.name,
                                       package.timestamp,
                                       package.readable_size,
                                       urllib.quote(package.source,"/:~"),
                                       urllib.quote(package.where,"/:~") ] )),
                    file=tmp)

        # replace the installed.lst in
        # a safe way
        atomic_replace(os.path.join(dataset_conf_path,"installed.lst.2"),
                       os.path.join(dataset_conf_path,"installed.lst"))
开发者ID:123fengye741,项目名称:pylearn2,代码行数:33,代码来源:dataset-get.py


示例20: GenStepBox

 def GenStepBox(stepstatus):
   """Generates a box for one step."""
   class_ = build_get_class(stepstatus)
   style = ''
   if class_ and class_ in styles:
     style = styles[class_]
   stepname = stepstatus.getName()
   text = stepstatus.getText() or []
   text = text[:]
   base_url = '%sbuilders/%s/builds/%d/steps' % (
       waterfall_url,
       urllib.quote(stepstatus.getBuild().getBuilder().getName(), safe=''),
       stepstatus.getBuild().getNumber())
   for steplog in stepstatus.getLogs():
     name = steplog.getName()
     log.msg('name = %s' % name)
     url = '%s/%s/logs/%s' % (
         base_url,
         urllib.quote(stepname, safe=''),
         urllib.quote(name))
     text.append('<a href="%s">%s</a>' % (url, html.escape(name)))
   for name, target in stepstatus.getURLs().iteritems():
     text.append('<a href="%s">%s</a>' % (target, html.escape(name)))
   fmt = '<tr><td style="%s">%s</td></tr>'
   return fmt % (style, '<br/>'.join(text))
开发者ID:leiferikb,项目名称:bitpop,代码行数:25,代码来源:build_utils.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python urllib.quote_plus函数代码示例发布时间:2022-05-27
下一篇:
Python urllib.proxy_bypass函数代码示例发布时间: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