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


Python QtNetwork.QNetworkRequest类代码示例

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


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

示例1: send

 def send(params):
     url = self.formatUrl(endpoint, params)
     request = QNetworkRequest(url)
     headers['User-Agent'] = 'Divi QGIS Plugin/%s' % PLUGIN_VERSION
     QgsMessageLog.logMessage(str(headers), 'DIVI')
     for key, value in headers.items():
         request.setRawHeader(key.encode('utf-8'), value.encode('utf-8'))
     if method == 'delete':
         reply = manager.sendCustomRequest(request, 'DELETE'.encode('utf-8'), data)
     else:
         if not data:
             reply = getattr(manager, method)(request)
         elif isinstance(data, QHttpMultiPart) == True:
             reply = getattr(manager, method)(request, data)
         elif isinstance(data, str) == True:
             reply = getattr(manager, method)(request, data.encode('utf-8'))
     loop = QEventLoop()
     reply.uploadProgress.connect(self.uploadProgress)
     reply.downloadProgress.connect(self.downloadProgress)
     reply.metaDataChanged.connect(self.metaDataChanged)
     #reply.error.connect(self._error)
     reply.finished.connect(loop.exit)
     self.abort_sig.connect( reply.abort )
     loop.exec_()
     self.abort_sig.disconnect( reply.abort )
     return reply
开发者ID:gis-support,项目名称:DIVI-QGIS-Plugin,代码行数:26,代码来源:connector.py

示例2: _wrap_request

 def _wrap_request(self, request):
     req = QNetworkRequest(request)
     req_id = next(self._request_ids)
     req.setAttribute(self._REQUEST_ID, req_id)
     if hasattr(request, 'timeout'):
         req.timeout = request.timeout
     return req, req_id
开发者ID:Cloverseer,项目名称:splash,代码行数:7,代码来源:network_manager.py

示例3: checkPluginUpdatesAvailable

 def checkPluginUpdatesAvailable(self):
     """
     Public method to check the availability of updates of plug-ins.
     """
     period = Preferences.getPluginManager("UpdatesCheckInterval")
     if period == 0:
         return
     elif period in [1, 2, 3]:
         lastModified = QFileInfo(self.pluginRepositoryFile).lastModified()
         if lastModified.isValid() and lastModified.date().isValid():
             lastModifiedDate = lastModified.date()
             now = QDate.currentDate()
             if period == 1 and lastModifiedDate.day() == now.day():
                 # daily
                 return
             elif period == 2 and lastModifiedDate.daysTo(now) < 7:
                 # weekly
                 return
             elif period == 3 and \
                 (lastModifiedDate.daysTo(now) <
                  lastModifiedDate.daysInMonth()):
                 # monthly
                 return
     
     self.__updateAvailable = False
     
     request = QNetworkRequest(
         QUrl(Preferences.getUI("PluginRepositoryUrl6")))
     request.setAttribute(QNetworkRequest.CacheLoadControlAttribute,
                          QNetworkRequest.AlwaysNetwork)
     reply = self.__networkManager.get(request)
     reply.finished.connect(self.__downloadRepositoryFileDone)
     self.__replies.append(reply)
开发者ID:Darriall,项目名称:eric,代码行数:33,代码来源:PluginManager.py

示例4: _makeRequestByType

 def _makeRequestByType(self, request_type: str) -> None:
     Logger.log("i", "Requesting %s metadata from server.", request_type)
     request = QNetworkRequest(self._request_urls[request_type])
     for header_name, header_value in self._request_headers:
         request.setRawHeader(header_name, header_value)
     if self._network_manager:
         self._network_manager.get(request)
开发者ID:rwreynolds,项目名称:Cura,代码行数:7,代码来源:Toolbox.py

示例5: on_searchPushButton_clicked

 def on_searchPushButton_clicked(self, checked):
     if self.categoryID != '' and self.categoryID != '-1':
         merchandising = Merchandising(warnings = False)
         response = merchandising.execute(
             'getMostWatchedItems',
             {
                 'categoryId': self.categoryID,
                 'maxResults': self.ui.spinBox.value()
             }
         )
         reply = response.reply
         itemRecommendations = reply.itemRecommendations.item
         row = self.ui.tableWidget.rowCount()
         for item in itemRecommendations:
             self.ui.tableWidget.insertRow(row)
             imageUrl = 'http://thumbs3.ebaystatic.com/pict/%s4040.jpg' % item.itemId
             request = QNetworkRequest(QUrl(imageUrl))
             request.setAttribute(QNetworkRequest.CacheLoadControlAttribute, QNetworkRequest.PreferCache)
             reply = self.manager.get(request)
             self.replyMap[reply] = row
             viewItemURL = QLabel()
             viewItemURL.setOpenExternalLinks(True)
             #viewItemURL.setTextInteractionFlags(Qt.TextBrowserInteraction)
             title = '<a href="%s">%s</a>' % (item.viewItemURL, item.title)
             viewItemURL.setText(title)
             self.ui.tableWidget.setCellWidget(row, 1, viewItemURL)
             self.ui.tableWidget.setItem(row, 2, QTableWidgetItem(item.primaryCategoryName))
             self.ui.tableWidget.setItem(row, 3, QTableWidgetItem(item.buyItNowPrice.value))
             self.ui.tableWidget.setItem(row, 4, QTableWidgetItem(item.watchCount))
             row += 1
开发者ID:xlongfeng,项目名称:oceanix,代码行数:30,代码来源:mostwatcheditems.py

示例6: _createEmptyRequest

 def _createEmptyRequest(self, target: str, content_type: Optional[str] = "application/json") -> QNetworkRequest:
     url = QUrl("http://" + self._address + self._api_prefix + target)
     request = QNetworkRequest(url)
     if content_type is not None:
         request.setHeader(QNetworkRequest.ContentTypeHeader, content_type)
     request.setHeader(QNetworkRequest.UserAgentHeader, self._user_agent)
     return request
开发者ID:Ultimaker,项目名称:Cura,代码行数:7,代码来源:NetworkedPrinterOutputDevice.py

示例7: __downloadFile

 def __downloadFile(self, url, filename, doneMethod=None):
     """
     Private slot to download the given file.
     
     @param url URL for the download (string)
     @param filename local name of the file (string)
     @param doneMethod method to be called when done
     """
     self.__updateButton.setEnabled(False)
     self.__downloadButton.setEnabled(False)
     self.__downloadInstallButton.setEnabled(False)
     self.__downloadCancelButton.setEnabled(True)
     
     self.statusLabel.setText(url)
     
     self.__doneMethod = doneMethod
     self.__downloadURL = url
     self.__downloadFileName = filename
     self.__downloadIODevice = QFile(self.__downloadFileName + ".tmp")
     self.__downloadCancelled = False
     
     request = QNetworkRequest(QUrl(url))
     request.setAttribute(QNetworkRequest.CacheLoadControlAttribute,
                          QNetworkRequest.AlwaysNetwork)
     reply = self.__networkManager.get(request)
     reply.finished.connect(self.__downloadFileDone)
     reply.downloadProgress.connect(self.__downloadProgress)
     self.__replies.append(reply)
开发者ID:testmana2,项目名称:test,代码行数:28,代码来源:PluginRepositoryDialog.py

示例8: _createRequest

 def _createRequest(self, url: str, basic_auth_username: str = "", basic_auth_password: str = "") -> QNetworkRequest:
     request = QNetworkRequest(url)
     request.setRawHeader("User-Agent".encode(), self._user_agent)
     if basic_auth_username and basic_auth_password:
         data = base64.b64encode(("%s:%s" % (basic_auth_username, basic_auth_password)).encode()).decode("utf-8")
         request.setRawHeader("Authorization".encode(), ("Basic %s" % data).encode())
     return request
开发者ID:fieldOfView,项目名称:OctoPrintPlugin,代码行数:7,代码来源:DiscoverOctoPrintAction.py

示例9: _wrap_request

 def _wrap_request(self, request):
     req = QNetworkRequest(request)
     req_id = next(self._request_ids)
     req.setAttribute(self._REQUEST_ID, req_id)
     for attr in ['timeout', 'track_response_body']:
         if hasattr(request, attr):
             setattr(req, attr, getattr(request, attr))
     return req, req_id
开发者ID:xiaotianlis,项目名称:splash,代码行数:8,代码来源:network_manager.py

示例10: _createEmptyRequest

 def _createEmptyRequest(self, path: str, content_type: Optional[str] = "application/json") -> QNetworkRequest:
     request = QNetworkRequest(QUrl(path))
     if content_type:
         request.setHeader(QNetworkRequest.ContentTypeHeader, content_type)
     access_token = self._account.accessToken
     if access_token:
         request.setRawHeader(b"Authorization", "Bearer {}".format(access_token).encode())
     return request
开发者ID:TinkerGnome,项目名称:Cura,代码行数:8,代码来源:CloudApiClient.py

示例11: _update

    def _update(self):
        ## Request 'general' printer data
        url = QUrl("http://" + self._address + self._api_prefix + "printer")
        self._printer_request = QNetworkRequest(url)
        self._printer_request.setRawHeader(self._api_header.encode(), self._api_key.encode())
        self._printer_reply = self._manager.get(self._printer_request)

        ## Request print_job data
        url = QUrl("http://" + self._address + self._api_prefix + "job")
        self._job_request = QNetworkRequest(url)
        self._job_request.setRawHeader(self._api_header.encode(), self._api_key.encode())
        self._job_reply = self._manager.get(self._job_request)
开发者ID:SHINOTECH,项目名称:OctoPrintPlugin,代码行数:12,代码来源:OctoPrintOutputDevice.py

示例12: perform_put

    def perform_put(self, endpoint, data, url):
        """
        Perform an HTTP PUT request.

        :param endpoint: the name of the Tribler endpoint.
        :param data: the data/body to send with the request.
        :param url: the url to send the request to.
        """
        request = QNetworkRequest(QUrl(url))
        request.setHeader(QNetworkRequest.ContentTypeHeader, "application/x-www-form-urlencoded")
        reply = self.put(request, data)
        return reply
开发者ID:synctext,项目名称:tribler,代码行数:12,代码来源:tribler_request_manager.py

示例13: _load_content

    def _load_content(self, content_type, content):
        """
        This method is for displaying some content of
        such types: local web pages, remote web pages,
        local pdf`s, local videos.

        It should be called like in the following example
        to work correctly:
        self._load_content('local_video', 'some_video.mp4')
        """
        self._main_browser_reset_zoom()  # reset zoom
        if content_type == 'local_url':
            source = config['flask_server_home'] + \
                config['flask_server_local_page_client'] + \
                content  # simply get the file from flask-server by its relative path-id
            # specify type of currently opened file for zoom and scroll methods
            self._cur_filetype = "webpage"
        elif content_type == 'external_url':
            self._cur_filetype = "webpage"
            # no needs required as, link should be given in
            # 'http://yoursite.com/yourpage'
            source = content
        elif content_type == 'local_pdf':
            # to render PDF`s we use PDF.js, so we open its page and send it a
            # path for the target file.
            source = config['flask_server_home'] + \
                config['flask_server_local_page_client'] + \
                content
            self._cur_filetype = "pdf"
        elif content_type == 'local_video':
            # in case of opening local videos we need to modify the path to the video in the source code of
            # the videoplayer, so don`t die after reading this code. It works just in the same style as other
            # filetypes, but in a very weird way.
            source = config['flask_server_home'] + \
                config['flask_server_video_addr_client'] + content
            logger.info('Opening video at {}'.format(source))
            self._cur_filetype = "video"
        # Set a custom user agent to avoid message about deprecated version of
        # browser

        self._main_browser.page().userAgentForUrl = self._custom_ua

        logger.info('Loading data on address: {}'.format(source))

        # Create a request to be able to set user-agent data. Without
        # it, it`s impossible to customize request data.
        request = QNetworkRequest()
        request.setUrl(QUrl(source))
        request.setRawHeader("USER-AGENT", config['output_user_agent'])

        # and finally load the result
        self._main_browser.load(request)
开发者ID:TarasZelyk,项目名称:ariusproject,代码行数:52,代码来源:output_main.py

示例14: __tabContextMenuClone

 def __tabContextMenuClone(self):
     """
     Private method to clone the selected tab.
     """
     idx = self.__tabContextMenuIndex
     if idx < 0:
         idx = self.currentIndex()
     if idx < 0 or idx > self.count():
         return
     
     req = QNetworkRequest(self.widget(idx).url())
     req.setRawHeader(b"X-Eric6-UserLoadAction", b"1")
     self.newBrowser(None, (req, QNetworkAccessManager.GetOperation, b""))
开发者ID:testmana2,项目名称:test,代码行数:13,代码来源:HelpTabWidget.py

示例15: _doGet

	def _doGet(self, path):
		url = urlunsplit(('http', self.addr, path, '', ''))
		sig = self._sign(b'GET', path.encode('utf-8'), b'')
		headers = {
			HMAC_HEADER: b64encode(sig)
		}

		request = QNetworkRequest(QUrl(url))
		for hname in headers:
			request.setRawHeader(hname, headers[hname])

		reply = self.network.get(request)
		return reply
开发者ID:hydrargyrum,项目名称:eye,代码行数:13,代码来源:daemon.py


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