当前位置: 首页>>代码示例>>Python>>正文


Python net.URLEncoder类代码示例

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


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

示例1: on_downloadBoundariesBtn_clicked

 def on_downloadBoundariesBtn_clicked(self, e):
     """Download puter ways of administrative boundaries from
        Overpass API
     """
     adminLevel = self.adminLevelTagTextField.getText()
     name = self.nameTagTextField.getText()
     optional = self.optionalTagTextField.getText()
     if (adminLevel, name, optional) == ("", "", ""):
         JOptionPane.showMessageDialog(self,
                                       self.app.strings.getString("enter_a_tag_msg"),
                                       self.app.strings.getString("Warning"),
                                       JOptionPane.WARNING_MESSAGE)
         return
     optTag = ""
     if optional.find("=") != -1:
         if len(optional.split("=")) == 2:
             key, value = optional.split("=")
             optTag = '["%s"="%s"]' % (URLEncoder.encode(key, "UTF-8"),
                                       URLEncoder.encode(value.replace(" ", "%20"), "UTF-8"))
     self.create_new_zone_editing_layer()
     overpassurl = 'http://127.0.0.1:8111/import?url='
     overpassurl += 'http://overpass-api.de/api/interpreter?data='
     overpassquery = 'relation["admin_level"="%s"]' % adminLevel
     overpassquery += '["name"="%s"]' % URLEncoder.encode(name, "UTF-8")
     overpassquery += '%s;(way(r:"outer");node(w););out meta;' % optTag
     overpassurl += overpassquery.replace(" ", "%20")
     print overpassurl
     self.app.send_to_josm(overpassurl)
开发者ID:alex85k,项目名称:qat_script,代码行数:28,代码来源:NewZoneDialog.py

示例2: get

def get(targetURL, params, username=None):

    paramStr = ""
    for aKey in params.keys():
        paramStr+=aKey+"="+URLEncoder.encode(params[aKey], "UTF-8")+"&"
    paramStr=paramStr[:-1]
    url = URL(targetURL+"?"+paramStr)
    print url
    connection = url.openConnection()

    if username!=None:    
        userpass = username
        basicAuth = "Basic " + base64.b64encode(userpass);
        #print basicAuth
        connection.setRequestProperty ("Authorization", basicAuth);
    
    connection.setRequestMethod("GET")    
    connection.setRequestProperty("Content-Language", "en-GB")
    connection.setUseCaches(0)
    connection.setDoOutput(2)
    
    inStream= connection.getInputStream()
    rd= BufferedReader(InputStreamReader(inStream))
    response = ""
    line = rd.readLine()
    while line != None:
        response +=line+"\r"
        line = rd.readLine()
    rd.close()
    return response
开发者ID:revolutionarysystems,项目名称:common-test,代码行数:30,代码来源:HttpCall.py

示例3: __init__

 def __init__(self, key, value, count):
     self.__name = value[value.rfind("/") + 1:]
     fq = '%s:"%s"' % (key, value)
     self.__facetQuery = URLEncoder.encode(fq, "UTF-8")
     self.__id = md5.new(fq).hexdigest()
     self.__count = count
     self.__subFacets = ArrayList()
开发者ID:kiranba,项目名称:the-fascinator,代码行数:7,代码来源:search-tree.py

示例4: post

def post(targetURL, params, contentType="text/xml", username=None):
    
    if(type(params) is dict):
        paramStr = ""
        for aKey in params.keys():
            paramStr+=aKey+"="+URLEncoder.encode(params[aKey], "UTF-8")+"&"
        paramStr=paramStr[:-1]
    else:
        paramStr = params
        
    url = URL(targetURL)
    print targetURL
    print paramStr
    print contentType
    connection = url.openConnection()
    if username!=None:    
        userpass = username
        basicAuth = "Basic " + base64.b64encode(userpass);
        connection.setRequestProperty ("Authorization", basicAuth);
    connection.setRequestMethod("POST")
    if contentType != None:
        connection.setRequestProperty("Content-Type", contentType)
    connection.setRequestProperty("Content-Length", str(len(paramStr)))
    connection.setRequestProperty("Content-Language", "en-GB")
    connection.setUseCaches(0)
    connection.setDoInput(1)
    connection.setDoOutput(2)
    
    wr= DataOutputStream(connection.getOutputStream())
    wr.writeBytes(paramStr)
    wr.flush()
    wr.close()
    return getResponse(connection);
开发者ID:revolutionarysystems,项目名称:o-test,代码行数:33,代码来源:HttpCall.py

示例5: update

    def update(self):
        """Update information shown by the dialog with those of
           currently selected error
        """
        error = self.app.selectedError
        check = error.check
        view = check.view
        tool = view.tool
        text = "<html>"

        #user
        if error.user is not None:
            errorUserName = error.user.getName()
            text += "%s:" % self.app.strings.getString("Last_user")
            userUrl = "http://www.openstreetmap.org/user/%s/" % URLEncoder.encode(errorUserName, "UTF-8")
            userLink = "<a href='%s'>%s</a>" % (userUrl, errorUserName)
            msgUrl = "http://www.openstreetmap.org/message/new/%s" % URLEncoder.encode(errorUserName, "UTF-8")
            messageLink = "<a href='%s'>%s</a>" % (msgUrl, self.app.strings.getString("Send_a_message"))
            text += "<br>%s (%s)<br><br>" % (userLink, messageLink)

        #tool
        text += "%s:<br>%s" % (self.app.strings.getString("Error_reported_by_the_tool"), tool.title)
        if tool.uri != "":
            text += "<br>%s" % self.link(tool.uri)

        #error type
        if not tool.isLocal:
            text += "<br><br>%s:" % self.app.strings.getString("Type_of_error")
            text += "<br>%s --> %s" % (view.title,
                                       check.title)

        #error help, usually a link to a Wiki page describing this errror type
        #error link, e.g. a link to the error on the tool web page
        for propName, prop in ((self.app.strings.getString("Error_help"), check.helpUrl),
                               (self.app.strings.getString("Error_link"), tool.error_url(error))):
            if prop != "":
                text += "<br><br>%s:" % propName
                text += "<br>%s" % self.link(prop)

        #error description, usually some info contained in the error file
        if error.desc != "":
            text += "<br><br>%s:" % self.app.strings.getString("Description")
            text += "<br>%s" % error.desc

        text += "</html>"
        self.infoPanel.setText(text)
        self.show()
开发者ID:alex85k,项目名称:qat_script,代码行数:47,代码来源:ErrorInfoDialog.py

示例6: writeClientGetHTTP

 def writeClientGetHTTP(self, writeOutTo, headers, data):
     """ generated source for method writeClientGetHTTP """
     bw = BufferedWriter(OutputStreamWriter(writeOutTo.getOutputStream()))
     pw = PrintWriter(bw)
     pw.println("GET /" + URLEncoder.encode(data, "UTF-8") + " HTTP/1.0")
     if 0 > len(headers):
         pw.println(headers)
     pw.println("Content-length: 0")
     pw.println()
     pw.println()
     pw.flush()
开发者ID:hobson,项目名称:ggpy,代码行数:11,代码来源:Test_Http.py

示例7: writeAsClientGET

 def writeAsClientGET(cls, socket, hostField, data, playerName):
     """ generated source for method writeAsClientGET """
     pw = PrintWriter(socket.getOutputStream())
     pw.print_("GET /" + URLEncoder.encode(data, "UTF-8") + " HTTP/1.0\r\n")
     pw.print_("Accept: text/delim\r\n")
     pw.print_("Host: " + hostField + "\r\n")
     pw.print_("Sender: GAMESERVER\r\n")
     pw.print_("Receiver: " + playerName + "\r\n")
     pw.print_("\r\n")
     pw.print_("\r\n")
     pw.flush()
开发者ID:hobson,项目名称:ggpy,代码行数:11,代码来源:HttpWriter.py

示例8: sayBugFixed

    def sayBugFixed(self, error, check):
        """Tell tool server that the current error is fixed
        """
        url = "http://keepright.ipax.at/comment.php?"
        url += "st=ignore_t&"
        if len(error.other) != 0:
            #There is a comment on the error, copy it
            url += "co=%s&" % URLEncoder.encode(error.other[0], "UTF-8")
        url += "schema=%s&" % error.errorId.split(" ")[0]
        url += "id=%s" % error.errorId.split(" ")[1]

        self.reportToToolServer(url)
开发者ID:floscher,项目名称:qat_script,代码行数:12,代码来源:KeepRight.py

示例9: __escapeQuery

 def __escapeQuery(self, q):
     eq = q
     # escape all solr/lucene special chars
     # from http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Escaping%20Special%20Characters
     for c in "+-&|!(){}[]^\"~*?:\\":
         eq = eq.replace(c, "\\%s" % c)
     ## Escape UTF8
     try:
         return URLEncoder.encode(eq, "UTF-8")
     except UnsupportedEncodingException, e:
         print "Error during UTF8 escape! ", repr(eq)
         return eq
开发者ID:kiranba,项目名称:the-fascinator,代码行数:12,代码来源:atom.py

示例10: setParams

 def setParams(self, format='json', action='', lgname='', lgpassword='', lgtoken='', language='', search='',
                     id='', entity='', property='', new='', data='', meta='', type='', token='', summary=''):
     self.params=''
     if format: self.params+='&format=' + format
     if action: self.params+='&action=' + action
     if language: self.params+='&language=' + language
     if lgname: self.params+='&lgname=' + URLEncoder.encode(lgname, "UTF-8")
     if lgpassword: self.params+='&lgpassword=' + URLEncoder.encode(lgpassword, "UTF-8")
     if lgtoken: self.params+='&lgtoken=' + URLEncoder.encode(lgtoken, "UTF-8")
     if search: self.params+='&search=' + URLEncoder.encode(search, "UTF-8")
     if id: self.params+='&id=' + URLEncoder.encode(id, "UTF-8")
     if entity: self.params+='&entity=' + URLEncoder.encode(entity, "UTF-8")
     if property: self.params+='&property=' + property
     if meta: self.params+='&meta=' + meta
     if type: self.params+='&type=' + type
     if new: self.params+='&new=' + new
     if data: self.params+='&data=' + URLEncoder.encode(data, "UTF-8")
     if summary: self.params+='&summary=' + URLEncoder.encode(summary, "UTF-8")
     if token: self.params+='&token=' + URLEncoder.encode(token, "UTF-8")
开发者ID:PolyglotOpenstreetmap,项目名称:Python-scripts-to-automate-JOSM,代码行数:19,代码来源:CreateWikidataEntries.py

示例11: __activate__

    def __activate__(self, context):
        self.velocityContext = context
        self.services = context["Services"]
        self.request = context["request"]
        self.response = context["response"]
        self.contextPath = context["contextPath"]
        self.formData = context["formData"]
        self.page = context["page"]

        self.uaActivated = False
        useDownload = Boolean.parseBoolean(self.formData.get("download", "true"))
        self.__isPreview = Boolean.parseBoolean(self.formData.get("preview", "false"))
        self.__previewPid = None
        self.__hasPid = False

        uri = URLDecoder.decode(self.request.getAttribute("RequestURI"))
        matches = re.match("^(.*?)/(.*?)/(?:(.*?)/)?(.*)$", uri)
        if matches and matches.group(3):
            oid = matches.group(3)
            pid = matches.group(4)

            self.__metadata = JsonConfigHelper()
            self.__object = self.__getObject(oid)
            self.__oid = oid

            # If we have a PID
            if pid:
                self.__hasPid = True
                if useDownload:
                    # Download the payload to support relative links
                    download = DownloadData()
                    download.__activate__(context)
                else:
                    # Render the detail screen with the alternative preview
                    self.__readMetadata(oid)
                    self.__previewPid = pid
            # Otherwise, render the detail screen
            else:
                self.__readMetadata(oid)
                self.__previewPid = self.getPreview()

            if self.__previewPid:
                self.__previewPid = URLEncoder.encode(self.__previewPid, "UTF-8")
        else:
            # require trailing slash for relative paths
            q = ""
            if self.__isPreview:
                q = "?preview=true"
            self.response.sendRedirect("%s/%s/%s" % (self.contextPath, uri, q))
开发者ID:kiranba,项目名称:the-fascinator,代码行数:49,代码来源:detail.py

示例12: post

def post(targetURL, params, contentType="text/xml", username=None):

    #paramStr = params["data"]
    paramStr = ""
    for aKey in params.keys():
        paramStr+=aKey+"="+URLEncoder.encode(params[aKey], "UTF-8")+"&"
    paramStr=paramStr[:-1]
    url = URL(targetURL)
    print targetURL
    print paramStr
    print contentType
    url = URL(targetURL+"?"+paramStr)
    print url

    connection = url.openConnection()
    if username!=None:    
        userpass = username
        basicAuth = "Basic " + base64.b64encode(userpass);
        connection.setRequestProperty ("Authorization", basicAuth);
    connection.setRequestMethod("POST")
    if contentType != None:
        connection.setRequestProperty("Content-Type", contentType)
    connection.setRequestProperty("Content-Length", str(len(paramStr)))
    connection.setRequestProperty("Content-Language", "en-GB")
    connection.setUseCaches(0)
    connection.setDoInput(1)
    connection.setDoOutput(2)
    
    #wr= DataOutputStream(connection.getOutputStream())
    #wr.writeBytes(paramStr)
    #wr.flush()
    #wr.close()
    
    inStream= connection.getInputStream()
    rd= BufferedReader(InputStreamReader(inStream))
    response = ""
    line = rd.readLine()
    while line != None:
        response +=line+"\r"
        line = rd.readLine()
    rd.close()
    return response
开发者ID:revolutionarysystems,项目名称:common-test,代码行数:42,代码来源:HttpCall.py

示例13: performPOST

 def performPOST(cls, theURL, theAuth, theData):
     """ generated source for method performPOST """
     message = URLEncoder.encode(theData, "UTF-8")
     try:
         connection.setDoOutput(True)
         connection.setRequestMethod("POST")
         writer.write("AUTH=" + theAuth + "&DATA=" + message)
         writer.close()
         if connection.getResponseCode() == HttpURLConnection.HTTP_OK:
             return BufferedReader(InputStreamReader(connection.getInputStream())).readLine()
         else:
             try:
                 errorDescription = BufferedReader(InputStreamReader(connection.getInputStream())).readLine()
             except Exception as q:
                 pass
             raise IOException(connection.getResponseCode() + ": " + errorDescription)
     except MalformedURLException as e:
         raise IOException(e)
     except IOException as e:
         raise e
开发者ID:hobson,项目名称:ggpy,代码行数:20,代码来源:MatchPublisher.py

示例14: __init__

 def __init__(self):
     sessionDuration = grinder.properties.getInt("player.sessionDurationInSeconds", 0)
     self.password = grinder.properties.getProperty("player.password")
     players_url = grinder.properties.getProperty("player.source-url")
     passwordHash = URLEncoder.encode(grinder.properties.getProperty("player.passwordHash"), "UTF-8")
     workers = grinder.properties.getInt("grinder.processes", 0)
     threads = grinder.properties.getInt("grinder.threads", 0)
     workerIndex = grinder.processNumber - grinder.firstProcessNumber
     threadsPerAgent = workers * threads
     agentIndex = grinder.agentNumber
     start = agentIndex * threadsPerAgent + workerIndex * threads
     if isLogEnabled:
         log("Worker will handle %s players starting from %d" % (threads, start))
     playerRange = (start, threads)
     self.workerPlayers = []
     params = "passwordHash=%s&minimumBalance=%s&startRow=%s&limit=%s" % (
         passwordHash,
         str(sessionDuration / 5),
         str(playerRange[0]),
         str(threads),
     )
     urlStr = players_url + "?" + params
     try:
         data = StringBuffer()
         url = URL(urlStr)
         conn = url.openConnection()
         rd = BufferedReader(InputStreamReader(conn.getInputStream()))
         line = rd.readLine()
         while line is not None:
             data.append(line)
             line = rd.readLine()
         rd.close()
         if isLogEnabled:
             log(data.toString())
         message = JSONValue.parse(str(String(data.toString(), "UTF-8")))
         for entry in message:
             self.workerPlayers.append((entry.get(0), entry.get(1)))
     except Exception:
         raise Exception("Couldn't fetch players from %s: %s" % (urlStr, traceback.format_exc()))
     if isLogEnabled:
         log(str(self.workerPlayers))
开发者ID:ShahakBH,项目名称:jazzino-master,代码行数:41,代码来源:yazino.py

示例15: get

def get(targetURL, params, username=None):

    paramStr = ""
    for aKey in params.keys():
        paramStr+=aKey+"="+URLEncoder.encode(params[aKey], "UTF-8")+"&"
    paramStr=paramStr[:-1]
    url = URL(targetURL+"?"+paramStr)
    print url
    connection = url.openConnection()

    if username!=None:    
        userpass = username
        basicAuth = "Basic " + base64.b64encode(userpass);
        print basicAuth
        connection.setRequestProperty ("Authorization", basicAuth);
    
    connection.setRequestMethod("GET")    
    connection.setRequestProperty("Content-Language", "en-GB")
    connection.setUseCaches(0)
    connection.setDoOutput(2)
    
    return getResponse(connection);
开发者ID:revolutionarysystems,项目名称:o-test,代码行数:22,代码来源:HttpCall.py


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