Ejemplo n.º 1
0
 def run(self):
     self.progress_reset.emit()
     self.progress_log.emit("Downloading map " + self.map_name)
     self.reply = util.network.get(QtNetwork.QNetworkRequest(self.url))
     self.reply.readyRead.connect(self._read_data)
     self.reply.finished.connect(self._save_data)
     self.reply.downloadProgress.connect(self._propagate_progress)
Ejemplo n.º 2
0
    def _consultar_ultima_version_del_servidor(self):
        direccion = QtCore.QUrl("http://www.pilas-engine.com.ar/version.json")
        self.manager = QtNetwork.QNetworkAccessManager(self.main)
        self.manager.get(QtNetwork.QNetworkRequest(direccion))

        self.manager.connect(self.manager, QtCore.SIGNAL("finished(QNetworkReply*)"),
                self._cuando_termina_de_consultar_version)
Ejemplo n.º 3
0
    def load(self, page, api=None, application=None):
        if application is None and api is not None:
            application = api.application
        if api is None:
            self.api = WebDriveApi(application, self)
        else:
            api.dialog = self
            self.api = api
        if not page.startswith(('http', 'file://')):
            filename = application.get_htmlpage(page)
        else:
            filename = page
        # If connect to a remote page add the X-Authentication-Token
        if filename.startswith('http'):
            log.trace('Load web page: %s', filename)
            self.request = url = QtNetwork.QNetworkRequest(
                QtCore.QUrl(filename))
            if self.token is not None:
                url.setRawHeader('X-Authentication-Token',
                                 QtCore.QByteArray(self.token))
            self._set_proxy(application.manager, server_url=page)
            self.api.last_url = filename
        else:
            self.request = None
            log.trace('Load web file: %s', filename)
            url = QtCore.QUrl.fromLocalFile(os.path.realpath(filename))
            url.setScheme('file')

        self.frame = self.page.mainFrame()
        self.frame.load(url)
        self.attachJsApi()
        self.frame.javaScriptWindowObjectCleared.connect(self.attachJsApi)
        self.activateWindow()
Ejemplo n.º 4
0
 def _start_request(self,
                    method,
                    host,
                    port,
                    path,
                    data,
                    handler,
                    xml,
                    mblogin=False):
     self.log.debug("%s http://%s:%d%s", method, host, port, path)
     url = QUrl.fromEncoded("http://%s:%d%s" % (host, port, path))
     if mblogin:
         url.setUserName(self.config.setting["username"])
         url.setPassword(self.config.setting["password"])
     request = QtNetwork.QNetworkRequest(url)
     request.setRawHeader("User-Agent",
                          "MusicBrainz-Picard/%s" % version_string)
     if data is not None:
         if method == "POST" and host == self.config.setting["server_host"]:
             request.setHeader(QtNetwork.QNetworkRequest.ContentTypeHeader,
                               "application/xml; charset=utf-8")
         else:
             request.setHeader(QtNetwork.QNetworkRequest.ContentTypeHeader,
                               "application/x-www-form-urlencoded")
     send = self._request_methods[method]
     reply = send(request, data) if data is not None else send(request)
     key = (host, port)
     self._last_request_times[key] = time.time()
     self._active_requests[reply] = (request, handler, xml)
     return True
Ejemplo n.º 5
0
 def send(self):
     self.request = QtNetwork.QNetworkRequest(self.url)
     if logger.isEnabledFor(logging.INFO):
         logger.info("GET to %s", self.url.toString())
     self.reply = self.parent.network_manager.get(self.request)
     self.reply.finished.connect(self._extract_reply)
     self.parent.replies.add(self)
Ejemplo n.º 6
0
 def _start_request(self, method, host, port, path, data, handler, xml,
                    mblogin=False, cacheloadcontrol=None, refresh=None):
     if mblogin and host in MUSICBRAINZ_SERVERS and port == 80:
         urlstring = "https://%s%s" % (host, path)
     else:
         urlstring = "http://%s:%d%s" % (host, port, path)
     log.debug("%s %s", method, urlstring)
     url = QUrl.fromEncoded(urlstring)
     if mblogin:
         url.setUserName(config.setting["username"])
         url.setPassword(config.setting["password"])
     request = QtNetwork.QNetworkRequest(url)
     if mblogin or (method == "GET" and refresh):
         request.setPriority(QtNetwork.QNetworkRequest.HighPriority)
         request.setAttribute(QtNetwork.QNetworkRequest.CacheLoadControlAttribute,
                              QtNetwork.QNetworkRequest.AlwaysNetwork)
     elif method == "PUT" or method == "DELETE":
         request.setPriority(QtNetwork.QNetworkRequest.HighPriority)
     elif cacheloadcontrol is not None:
         request.setAttribute(QtNetwork.QNetworkRequest.CacheLoadControlAttribute,
                              cacheloadcontrol)
     request.setRawHeader("User-Agent", USER_AGENT_STRING)
     if data is not None:
         if method == "POST" and host == config.setting["server_host"]:
             request.setHeader(QtNetwork.QNetworkRequest.ContentTypeHeader, "application/xml; charset=utf-8")
         else:
             request.setHeader(QtNetwork.QNetworkRequest.ContentTypeHeader, "application/x-www-form-urlencoded")
     send = self._request_methods[method]
     reply = send(request, data) if data is not None else send(request)
     key = (host, port)
     self._last_request_times[key] = time.time()
     self._active_requests[reply] = (request, handler, xml, refresh)
     return True
Ejemplo n.º 7
0
    def run(self,
            url,
            credential=None,
            responseAllFinished=True,
            json_request=None):
        if credential is None:
            credential = {'user': '', 'password': ''}
        (self.credential, self.responseAllFinished) = (credential,
                                                       responseAllFinished)
        self._connect()
        self.totalReady = 0
        self.isKilled = False
        request = QtNetwork.QNetworkRequest(url)
        if json_request is None:
            reply = self.networkAccess.get(request)
        else:
            request.setHeader(QtNetwork.QNetworkRequest.ContentTypeHeader,
                              "application/json")
            data = QtCore.QByteArray(json.dumps(json_request))
            reply = self.networkAccess.post(request, data)
        if reply is None:
            response = {
                'isOk': False,
                'message': "Network error",
                'errorCode': -1
            }
            self._connect(False)
            self.finished.emit(response)
            return

        self.triedAuthentication = False
        self.reply = reply
        self._connectReply()
Ejemplo n.º 8
0
    def _consultar_ultima_version_del_servidor(self):
        direccion = QtCore.QUrl("https://raw.githubusercontent.com/hugoruscitti/pilas/gh-pages/version.json")
        self.manager = QtNetwork.QNetworkAccessManager(self.MainWindow)
        self.manager.get(QtNetwork.QNetworkRequest(direccion))

        self.manager.connect(self.manager, QtCore.SIGNAL("finished(QNetworkReply*)"),
                self._cuando_termina_de_consultar_version)
Ejemplo n.º 9
0
    def load(self, page, api=None, application=None):
        if application is None and api is not None:
            application = api._application
        if api is None:
            self._api = WebDriveApi(application, self)
        else:
            api.set_dialog(self)
            self._api = api
        if not (page.startswith("http") or page.startswith("file://")):
            filename = application.get_htmlpage(page)
        else:
            filename = page
        # If connect to a remote page add the X-Authentication-Token
        if filename.startswith("http"):
            log.trace("Load web page: %s", filename)
            self._request = url = QtNetwork.QNetworkRequest(
                QtCore.QUrl(filename))
            if self._token is not None:
                url.setRawHeader("X-Authentication-Token",
                                 QtCore.QByteArray(self._token))
            self._set_proxy(application.manager)
            self._api.set_last_url(filename)
        else:
            self._request = None
            log.trace("Load web file: %s", filename)
            if filename[0] != '/':
                filename = u"///" + filename
            url = QtCore.QUrl(filename)
            url.setScheme("file")

        self._frame = self._page.mainFrame()
        self._frame.load(url)
        self._attachJsApi()
        self._frame.javaScriptWindowObjectCleared.connect(self._attachJsApi)
        self.activateWindow()
Ejemplo n.º 10
0
def download(manager, url, identifier):
    QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
    request = QtNetwork.QNetworkRequest()
    request.setUrl(QtCore.QUrl(url))
    request.setAttribute(QtNetwork.QNetworkRequest.User, identifier)
    reply = manager.get(request)
    reply.finished.connect(lambda: QtGui.QApplication.restoreOverrideCursor())
Ejemplo n.º 11
0
 def fill_from_db(self, responseId, responseUrl):
     if responseId and responseUrl:
         request = QtNetwork.QNetworkRequest(QUrl(responseUrl))
         request.setRawHeader(self.framework.X_RAFT_ID, str(responseId))
         self.load(request)
     else:
         self.setHtml('', 'about:blank')
Ejemplo n.º 12
0
 def _start_request_continue(self, method, host, port, path, data, handler, xml,
                             mblogin=False, cacheloadcontrol=None, refresh=None,
                             access_token=None, queryargs=None):
     url = build_qurl(host, port, path=path, mblogin=mblogin,
                      queryargs=queryargs)
     request = QtNetwork.QNetworkRequest(url)
     if mblogin and access_token:
         request.setRawHeader("Authorization", "Bearer %s" % access_token)
     if mblogin or (method == "GET" and refresh):
         request.setPriority(QtNetwork.QNetworkRequest.HighPriority)
         request.setAttribute(QtNetwork.QNetworkRequest.CacheLoadControlAttribute,
                              QtNetwork.QNetworkRequest.AlwaysNetwork)
     elif method == "PUT" or method == "DELETE":
         request.setPriority(QtNetwork.QNetworkRequest.HighPriority)
     elif cacheloadcontrol is not None:
         request.setAttribute(QtNetwork.QNetworkRequest.CacheLoadControlAttribute,
                              cacheloadcontrol)
     request.setRawHeader("User-Agent", USER_AGENT_STRING)
     if xml:
         request.setRawHeader("Accept", "application/xml")
     if data is not None:
         if method == "POST" and host == config.setting["server_host"] and xml:
             request.setHeader(QtNetwork.QNetworkRequest.ContentTypeHeader, "application/xml; charset=utf-8")
         else:
             request.setHeader(QtNetwork.QNetworkRequest.ContentTypeHeader, "application/x-www-form-urlencoded")
     send = self._request_methods[method]
     reply = send(request, data) if data is not None else send(request)
     self._remember_request_time((host, port))
     self._active_requests[reply] = (request, handler, xml, refresh)
Ejemplo n.º 13
0
    def createRequest(self, op, request, device=None):
        global lst, pg
        try:
            #print(str(request.url()))
            urlLnk = (request.url()).toString()
            #print(urlLnk)
            path = str(request.url().path())
        except UnicodeEncodeError:
            pass
        #print(path)
        lower_case = path.lower()
        #lst = tuple(open("easylist.txt", 'r'))
        lst = [
            "doubleclick.net", "ads", '.jpg', '.png', '.gif', '.css',
            'facebook', '.aspx', r"||youtube-nocookie.com/gen_204?",
            r"youtube.com###watch-branded-actions", "imagemapurl",
            "b.scorecardresearch.com", "rightstuff.com", "scarywater.net",
            "popup.js", "banner.htm", "_tribalfusion",
            "||n4403ad.doubleclick.net^$third-party", ".googlesyndication.com",
            "graphics.js", "fonts.googleapis.com/css", "s0.2mdn.net",
            "server.cpmstar.com", "||banzai/banner.$subdocument",
            "@@||anime-source.com^$document", "/pagead2.", "frugal.gif",
            "jriver_banner.png", "show_ads.js",
            '##a[href^="http://billing.frugalusenet.com/"]',
            "http://jriver.com/video.html", "||animenewsnetwork.com^*.aframe?",
            "||contextweb.com^$third-party", ".gutter", ".iab",
            'http://www.animenewsnetwork.com/assets/[^"]*.jpg'
        ]
        block = False
        for l in lst:
            if lower_case.find(l) != -1:
                block = True
                break
        if block:
            #print ("Skipping")
            #print (request.url().path())

            return QNetworkAccessManager.createRequest(
                self, QNetworkAccessManager.GetOperation,
                QtNetwork.QNetworkRequest(QtCore.QUrl()))
        else:
            if 'itag=' in urlLnk and 'redirector' not in urlLnk:
                print('*********')
                #print()
                #print(path)
                #print(urlLnk)
                #pg.web.setHtml('<html>got the link</html>')
                #self.lnkUrl.emit(path)
                f = open('/tmp/AnimeWatch/lnk.txt', 'w')
                f.write(urlLnk)
                f.close()
                return QNetworkAccessManager.createRequest(
                    self, op, request, device)
                #return QNetworkAccessManager.createRequest(self, op, request, device)
                #return QNetworkAccessManager.createRequest(self, QNetworkAccessManager.GetOperation, QtNetwork.QNetworkRequest(QtCore.QUrl()))

            else:
                return QNetworkAccessManager.createRequest(
                    self, op, request, device)
Ejemplo n.º 14
0
    def __init__(self, url):
        self.deferred = defer.Deferred()
        self.deferred._store_it_because_qt_needs_or_wont_work = self
        request = QtNetwork.QNetworkRequest(QtCore.QUrl(url))

        self.req = _qt_network_manager.get(request)
        self.req.error.connect(self.deferred.errback)
        self.req.finished.connect(self.end)
Ejemplo n.º 15
0
 def downloadFile(self):
     url = inputDialog(tr("query"), tr('enterURL'))
     if url:
         fname = saveDialog(os.path.split(unicode(url))[1])
         if fname:
             nm = self.networkAccessManager
             reply = nm.get(QtNetwork.QNetworkRequest(QtCore.QUrl(url)))
             self.newReply(reply, fname)
Ejemplo n.º 16
0
 def _prepare_request(self):
     self.request = QtNetwork.QNetworkRequest(self.url)
     self.request.setHeader(QtNetwork.QNetworkRequest.ContentTypeHeader,
                            "application/x-www-form-urlencoded")
     query = QtCore.QUrl()
     if self.params:
         for key, value in list(self.params['query'].items()):
             query.addQueryItem(key, value)
     self.query = query.encodedQuery()
Ejemplo n.º 17
0
	def showEvent(self, event):
		QtGui.QWidget.showEvent(self, event)
		settings = QtCore.QSettings(Keys.organization, Keys.app)
		uri = str(settings.value("lasturi", None).toString())
		if uri:
			url = QtCore.QUrl(uri + ServerPath.STATUS)
			request = QtNetwork.QNetworkRequest(url)
			reply = QtGui.QApplication.instance().NAM.get(request)
			reply.finished.connect(lambda: self.onStartReply(uri))
Ejemplo n.º 18
0
 def _send_handshake(self, url):
     self.host = url.host()
     url.setPath('/socket.io/1')
     # TODO might need to strip query arguments
     # TODO this request should have a User-Agent,
     # there is a overidden request class for that in network/__init__.py
     request = QtNetwork.QNetworkRequest(url)
     self.reply = self.network_manager.get(request)
     self.reply.finished.connect(self._receive_handshake)
Ejemplo n.º 19
0
 def createRequest(self, op, req, outgoingData):
     if self.token is not None:
         req.setRawHeader("X-Authentication-Token", QtCore.QByteArray(self.token))
     # Block TTF under Mac
     if sys.platform == "darwin" and unicode(req.url().path()).endswith(".ttf"):
         # Block .ttf file for now as there are badly displayed
         return super(TokenNetworkAccessManager, self).createRequest(op,
                     QtNetwork.QNetworkRequest(QtCore.QUrl()), outgoingData)
     return super(TokenNetworkAccessManager, self).createRequest(op, req, outgoingData)
Ejemplo n.º 20
0
    def httpPost(self, url, param):

        param = urllib.urlencode(param)
        param = QtCore.QString(param).toUtf8()
        request = QtNetwork.QNetworkRequest(QtCore.QUrl(url))
        request.setRawHeader(
            "Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")
        request.setRawHeader("Origin", "http://user.qzone.qq.com")
        reply = self.networkAccessManager.post(request, param)
        return reply
Ejemplo n.º 21
0
	def setPassword(self, dialog):
		mpass = str(dialog.edit1.text())
		npass = str(dialog.edit2.text())
		uri = self.createRequestUri(ServerPath.SET_PASSWORD)
		if uri:
			uri.addQueryItem(ServerPath.MASTER_PASSWORD, mpass)
			uri.addQueryItem(ServerPath.PASSWORD, npass)
			request = QtNetwork.QNetworkRequest(uri)
			reply = QtGui.QApplication.instance().NAM.get(request)
			reply.finished.connect(lambda: self.onPasswordReply(dialog))
Ejemplo n.º 22
0
	def performRequest(self, uri, lazy, init):
		if not DataHolder.uri:
			return
		if lazy:
			self.lazyStatusInProgress = True
		else:
			pass
		request = QtNetwork.QNetworkRequest(uri)
		reply = QtGui.QApplication.instance().NAM.get(request)
		reply.finished.connect(lambda: self.onRequestReply(lazy, init))
Ejemplo n.º 23
0
    def checkRewrting(self):
        remote = unicode(self.dialog.edit2.text())
        if not DataHolder.uri:
            return
        url = QtCore.QUrl(DataHolder.uri + ServerPath.CHECK)
        url.addQueryItem(ServerPath.PATH, remote)

        request = QtNetwork.QNetworkRequest(url)
        reply = QtGui.QApplication.instance().NAM.get(request)
        reply.finished.connect(self.onCheckReply)
Ejemplo n.º 24
0
    def __switchVideo2(self):       
        #m_netwManager.finished.connect(self.__netwManagerFinished)
        request = QtNetwork.QNetworkRequest();
        request.setUrl(QtCore.QUrl(Utils.getWebcamUrl(self.interactiveIdEdit.text())))
        request.setRawHeader("User-Agent", "MyOwnBrowser 1.0");
        
        reply = self.m_netwManager.get(request);
        reply.readyRead.connect(self.__netwManagerFinished)

        #self.videoWidget.load(QtCore.QUrl(Utils.getWebcamUrl(self.interactiveIdEdit.text())))
        pass
 def downloadRequested(self, qrequest):
     orgFileName = QtCore.QFileInfo(qrequest.url().toString()).fileName()
     filename = QtGui.QFileDialog.getSaveFileName(self, "Save file as...",
                                                  orgFileName)
     if filename.isEmpty():
         return
     nrequest = QtNetwork.QNetworkRequest(qrequest)
     nrequest.setAttribute(QtNetwork.QNetworkRequest.User, filename)
     self.files[filename] = self.netmanager.get(nrequest)
     QObject.connect(self.files[filename], QtCore.SIGNAL("finished()"),
                     self.downloadFinished_Slot)
Ejemplo n.º 26
0
 def login(self, widget, uri):
     password, ok = QtGui.QInputDialog.getText(widget, "Auhtorization",
                                               "Password for \n%s" % uri)
     if ok:
         url = QtCore.QUrl(uri + ServerPath.LOGIN)
         url.addQueryItem(ServerPath.PASSWORD, password)
         request = QtNetwork.QNetworkRequest(url)
         reply = QtGui.QApplication.instance().NAM.get(request)
         reply.finished.connect(lambda: self.onLoginReply(widget, uri))
     else:
         self.loginCancel.emit()
Ejemplo n.º 27
0
 def process(self, path, action):
     self.action = action
     self.path = path
     if not DataHolder.uri:
         return
     self.isWorking = True
     url = QtCore.QUrl(DataHolder.uri + ServerPath.CHECK)
     url.addQueryItem(ServerPath.PATH, self.path)
     request = QtNetwork.QNetworkRequest(url)
     reply = QtGui.QApplication.instance().NAM.get(request)
     reply.finished.connect(self.onReply)
Ejemplo n.º 28
0
    def onChecked(self):
        path = ServerPath.ENQUEUE if self.action == self.ENQUEUE else (
            ServerPath.ENQUEUE_AND_PLAY if self.action == self.ENQUEUE_AND_PLAY
            else ServerPath.PLAY_BACKGROUND)
        url = QtCore.QUrl(DataHolder.uri + path)
        url.addQueryItem(ServerPath.PATH, self.path)

        request = QtNetwork.QNetworkRequest(url)
        reply = QtGui.QApplication.instance().NAM.get(request)
        self.isWorking = False
        self.enqueued.emit()
Ejemplo n.º 29
0
 def check(self):
     login = str(self.dialog.edit1.text())
     password = str(self.dialog.edit2.text())
     if not DataHolder.uri:
         return
     url = QtCore.QUrl(DataHolder.uri + ServerPath.CHECK)
     url.addQueryItem(ServerPath.PASSWORD, password)
     url.addQueryItem(ServerPath.LOGIN, login)
     url.addQueryItem(ServerPath.PATH, self.share)
     request = QtNetwork.QNetworkRequest(url)
     reply = QtGui.QApplication.instance().NAM.get(request)
     reply.finished.connect(self.onReply)
Ejemplo n.º 30
0
 def viewSource(self):
     try:
         self.sourceViews
     except:
         self.sourceViews = []
     nm = self.page().networkAccessManager()
     reply = nm.get(QtNetwork.QNetworkRequest(self.url()))
     s = ViewSourceDialog(reply, None)
     self.sourceViews.append(s)
     s.closed.connect(self.removeSourceView)
     s.show()
     s.resize(640, 480)
     s.setWindowIcon(self.icon())