def command(self, command): """Perform one command.""" command = command.split() cmd = command[0] args = command[1:] win = QApplication.activeWindow() if win not in app.windows: if not app.windows: import mainwindow mainwindow.MainWindow().show() win = app.windows[0] if cmd == b'open': url = QUrl.fromEncoded(args[0]) win.openUrl(url, self.encoding) elif cmd == b'encoding': self.encoding = str(args[0]) elif cmd == b'activate_window': win.activateWindow() win.raise_() elif cmd == b'set_current': url = QUrl.fromEncoded(args[0]) win.setCurrentDocument(app.openUrl(url, self.encoding)) elif cmd == b'set_cursor': line, column = map(int, args) cursor = win.textCursor() pos = cursor.document().findBlockByNumber(line - 1).position() + column cursor.setPosition(pos) win.currentView().setTextCursor(cursor) elif cmd == b'bye': self.close()
def command(self, command): """Perform one command.""" command = command.split() cmd = command[0] args = command[1:] win = QApplication.activeWindow() if win not in app.windows: if not app.windows: import mainwindow mainwindow.MainWindow().show() win = app.windows[0] if cmd == b'open': url = QUrl.fromEncoded(args[0]) win.openUrl(url, self.encoding) elif cmd == b'encoding': self.encoding = str(args[0]) elif cmd == b'activate_window': win.activateWindow() win.raise_() elif cmd == b'set_current': url = QUrl.fromEncoded(args[0]) win.setCurrentDocument(app.openUrl(url, self.encoding)) elif cmd == b'set_cursor': line, column = map(int, args) cursor = win.textCursor() pos = cursor.document().findBlockByNumber(line - 1).position() + column cursor.setPosition(pos) win.currentView().setTextCursor(cursor) elif cmd == b'bye': self.close()
def from_user_input(userInput): # Toma una URL en string y la transforma a un QUrl bien formado userInput = QString(userInput) trimmedString = userInput.trimmed() url = QUrl.fromEncoded(trimmedString.toUtf8(), QUrl.TolerantMode) urlPrepended = QUrl.fromEncoded((QLatin1String("http://") + trimmedString).toUtf8(), QUrl.TolerantMode) # Check the most common case of a valid url with scheme and host # We check if the port would be valid by adding the scheme to handle the case host:port # where the host would be interpretted as the scheme if (url.isValid() and not url.scheme().isEmpty() and (not url.host().isEmpty() or not url.path().isEmpty()) and urlPrepended.port() == -1): return url # Else, try the prepended one and adjust the scheme from the host name if (urlPrepended.isValid() and (not urlPrepended.host().isEmpty() or not urlPrepended.path().isEmpty())): dotIndex = trimmedString.indexOf(".") hostscheme = trimmedString.left(dotIndex).toLower() if (hostscheme == QLatin1String("ftp")): urlPrepended.setScheme(QLatin1String("ftp")) return urlPrepended return QUrl()
def test1(self): d = QgsVirtualLayerDefinition() self.assertEqual(d.toString(), "") d.setFilePath("/file") self.assertEqual(d.toString(), "/file") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).filePath(), "/file") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).filePath(), "/file") d.setFilePath("C:\\file") self.assertEqual(d.toString(), "C:%5Cfile") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).filePath(), "C:\\file") d.setQuery("SELECT * FROM mytable") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).query(), "SELECT * FROM mytable") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).query(), "SELECT * FROM mytable") q = u"SELECT * FROM tableéé /*:int*/" d.setQuery(q) self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).query(), q) self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).query(), q) s1 = u"file://foo&bar=okié" d.addSource("name", s1, "provider", "utf8") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).sourceLayers()[0].source(), s1) self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).sourceLayers()[0].source(), s1) n1 = u"éé ok" d.addSource(n1, s1, "provider") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).sourceLayers()[1].name(), n1) self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).sourceLayers()[1].name(), n1) d.addSource("ref1", "id0001") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).sourceLayers()[2].reference(), "id0001") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).sourceLayers()[2].reference(), "id0001") s = "dbname='C:\\tt' table=\"test\" (geometry) sql=" d.addSource("nn", s, "spatialite") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).sourceLayers()[3].source(), s) self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).sourceLayers()[3].source(), s) d.setGeometryField("geom") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).geometryField(), "geom") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).geometryField(), "geom") d.setGeometryWkbType(QgsWKBTypes.Point) self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).geometryWkbType(), QgsWKBTypes.Point) self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).geometryWkbType(), QgsWKBTypes.Point) f = QgsFields() f.append(QgsField("a", QVariant.Int)) f.append(QgsField("f", QVariant.Double)) f.append(QgsField("s", QVariant.String)) d.setFields(f) f2 = QgsVirtualLayerDefinition.fromUrl(d.toUrl()).fields() self.assertEqual(f[0].name(), f2[0].name()) self.assertEqual(f[0].type(), f2[0].type()) self.assertEqual(f[1].name(), f2[1].name()) self.assertEqual(f[1].type(), f2[1].type()) self.assertEqual(f[2].name(), f2[2].name()) self.assertEqual(f[2].type(), f2[2].type())
def test1(self): d = QgsVirtualLayerDefinition() self.assertEqual(d.toString(), "") d.setFilePath("/file") self.assertEqual(d.toString(), "file:///file") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).filePath(), "/file") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).filePath(), "/file") d.setFilePath("C:\\file") self.assertEqual(d.toString(), "file:///C:%5Cfile") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).filePath(), "C:\\file") d.setQuery("SELECT * FROM mytable") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).query(), "SELECT * FROM mytable") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).query(), "SELECT * FROM mytable") q = u"SELECT * FROM tableéé /*:int*/" d.setQuery(q) self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).query(), q) self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).query(), q) s1 = u"file://foo&bar=okié" d.addSource("name", s1, "provider", "utf8") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).sourceLayers()[0].source(), s1) self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).sourceLayers()[0].source(), s1) n1 = u"éé ok" d.addSource(n1, s1, "provider") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).sourceLayers()[1].name(), n1) self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).sourceLayers()[1].name(), n1) d.addSource("ref1", "id0001") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).sourceLayers()[2].reference(), "id0001") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).sourceLayers()[2].reference(), "id0001") s = "dbname='C:\\tt' table=\"test\" (geometry) sql=" d.addSource("nn", s, "spatialite") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).sourceLayers()[3].source(), s) self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).sourceLayers()[3].source(), s) d.setGeometryField("geom") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).geometryField(), "geom") self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).geometryField(), "geom") d.setGeometryWkbType(QgsWKBTypes.Point) self.assertEqual(QgsVirtualLayerDefinition.fromUrl(d.toUrl()).geometryWkbType(), QgsWKBTypes.Point) self.assertEqual(QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(d.toString())).geometryWkbType(), QgsWKBTypes.Point) f = QgsFields() f.append(QgsField("a", QVariant.Int)) f.append(QgsField("f", QVariant.Double)) f.append(QgsField("s", QVariant.String)) d.setFields(f) f2 = QgsVirtualLayerDefinition.fromUrl(d.toUrl()).fields() self.assertEqual(f[0].name(), f2[0].name()) self.assertEqual(f[0].type(), f2[0].type()) self.assertEqual(f[1].name(), f2[1].name()) self.assertEqual(f[1].type(), f2[1].type()) self.assertEqual(f[2].name(), f2[2].name()) self.assertEqual(f[2].type(), f2[2].type())
def get_next_fuzz_item(self): self.qlock.lock() locked = True fuzz_item = None try: data_item = self.queueDataModel.popleft_data() if not data_item: self.keep_fuzzing = False return fuzz_id = data_item[DomFuzzerQueueTable.ID] row = self.Data.read_responses_by_id(self.read_cursor, data_item[DomFuzzerQueueTable.RESPONSE_ID]) if not row: self.framework.log_warning('missing response id: %s' % (response_id)) return responseItems = interface.data_row_to_response_items(row) target_url = self.compute_url_from_payload(data_item) qurl = QUrl.fromEncoded(target_url) dataContent = responseItems[ResponsesTable.RES_DATA] # TODO: store reference fuzz_item = (fuzz_id, dataContent, qurl) self.qlock.unlock() locked = False finally: if locked: self.qlock.unlock() return fuzz_item
def get_next_fuzz_item(self): self.qlock.lock() locked = True fuzz_item = None try: data_item = self.queueDataModel.popleft_data() if not data_item: self.keep_fuzzing = False return fuzz_id = data_item[DomFuzzerQueueTable.ID] row = self.Data.read_responses_by_id( self.read_cursor, data_item[DomFuzzerQueueTable.RESPONSE_ID]) if not row: self.framework.log_warning('missing response id: %s' % (response_id)) return responseItems = interface.data_row_to_response_items(row) target_url = self.compute_url_from_payload(data_item) qurl = QUrl.fromEncoded(target_url) dataContent = responseItems[ResponsesTable.RES_DATA] # TODO: store reference fuzz_item = (fuzz_id, dataContent, qurl) self.qlock.unlock() locked = False finally: if locked: self.qlock.unlock() return fuzz_item
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
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 xml: request.setRawHeader("Accept", "application/xml") 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
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
def read_data(self, url): """ Reads data from website and saves them to variables which you can get by using corresponding method. """ if not url.startswith("http://"): url = "http://" + url page_response = urllib.request.urlopen(url) page = page_response.read() soup = bs4.BeautifulSoup(page) content_div = soup.find("div", id="block-system-main") site = oga_site.ContentSite(url) title_div = content_div.find("div", {"property": "dc:title"}) site.title = title_div.contents[0].string span_username = content_div.find("span", {"class": "username"}) site.author = span_username.contents[0].string # TODO: Add compatibility code for texture-pages art_type_div = content_div.find("div", {"class": "field-name-field-art-type"}) site.art_type_string = art_type_div.select("div > div > a")[0].string site.art_type = self._match_string_with_art_type(site.art_type_string) license_divs = content_div.find_all("div", {"class": "license-name"}) site.licenses = [lic_div.string for lic_div in license_divs] files_div = content_div.find("div", {"class": "field-name-field-art-files"}) files_links = files_div.select("a") site.files = {link.string: QUrl.fromEncoded("http://" + URL_OGA + link["href"]) for link in files_links} for key, val in site.files.items(): site.files[key] = QUrl.fromEncoded(val.queryItemValue("file")) date_div = content_div.find("div", {"class": "field-name-post-date"}) site.date_string = date_div.select("div > div")[0].string body_div = content_div.find("div", {"class": "field-name-body"}) body_strings = body_div.select("div p")[0].strings site.body = " ".join(list(body_strings)) attr_instruction_div = content_div.find("div", {"class": "field-name-field-art-attribution"}) if attr_instruction_div: site.attr_instructions = attr_instruction_div.select("div > div")[0].string return site
def to_qurl(s): if isinstance(s, QUrl): return s if isinstance(s, unicode): s = s.encode('utf-8') return QUrl.fromEncoded(s)
def command(self, command): """Perform one command.""" command = command.split() cmd = command[0] args = command[1:] win = QApplication.activeWindow() if win not in app.windows: if not app.windows: import mainwindow mainwindow.MainWindow().show() win = app.windows[0] if cmd == b'open': url = QUrl.fromEncoded(args[0]) try: win.openUrl(url, self.encoding) except IOError as e: filename = url.toLocalFile() msg = _("{message}\n\n{strerror} ({errno})").format( message=_("Could not read from: {url}").format( url=filename), strerror=e.strerror, errno=e.errno) QMessageBox.critical(win, app.caption(_("Error")), msg) elif cmd == b'encoding': self.encoding = str(args[0]) elif cmd == b'activate_window': win.activateWindow() win.raise_() elif cmd == b'set_current': url = QUrl.fromEncoded(args[0]) try: win.setCurrentDocument(app.openUrl(url)) # already loaded except IOError: pass elif cmd == b'set_cursor': line, column = map(int, args) cursor = win.textCursor() pos = cursor.document().findBlockByNumber(line - 1).position() + column cursor.setPosition(pos) win.currentView().setTextCursor(cursor) elif cmd == b'bye': self.close()
def _make_request(self, url): url = QUrl.fromEncoded(url, QUrl.TolerantMode) #url = QUrl(url, QUrl.StrictMode) #url = QUrl.setUrl(url, QUrl.StrictMode) request = QNetworkRequest(url) #request = QNetworkRequest(url) return request
def to_qurl(s): if isinstance(s, QUrl): return s if isinstance(s, unicode): s = s.encode('utf-8') return QUrl.fromEncoded(s)
def getQueryGeometryName(sqlite_file): # introspect the file with sqlite3_connection(sqlite_file) as conn: c = conn.cursor() for r in c.execute("SELECT url FROM _meta"): d = QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(r[0])) if d.hasDefinedGeometry(): return d.geometryField() return None
def path2qurl (path): # path= '/home/mdione/media/music/Patricio Rey Y Sus Redonditos De Ricota/\xc3\x9altimo bondi a Finisterre/07- La peque\xf1a novia del carioca.wav' qba= QByteArray (path) qu= QUrl.fromEncoded (qba.toPercentEncoding ("/ ")) # older versions need this, at least for the gstreamer backend if qu.scheme ()=='': qu.setScheme ('file') return qu
def _check_for_redirect(self, status_code): if status_code in (301, 302, 303, 307): header = self.rawHeader("Location") url = QUrl.fromEncoded(header) if not url.isValid(): url = QUrl(QLatin1String(header)) self.setAttribute(QNetworkRequest.RedirectionTargetAttribute, url)
def _check_for_redirect(self, status_code): if status_code in (301, 302, 303, 307): header = self.rawHeader("Location") url = QUrl.fromEncoded(header) if not url.isValid(): url = QUrl(QLatin1String(header)) self.setAttribute(QNetworkRequest.RedirectionTargetAttribute, url)
def getQueryGeometryName(sqlite_file): # introspect the file with sqlite3_connection(sqlite_file) as conn: c = conn.cursor() for r in c.execute("SELECT url FROM _meta"): d = QgsVirtualLayerDefinition.fromUrl(QUrl.fromEncoded(r[0])) if d.hasDefinedGeometry(): return d.geometryField() return None
def command(self, command): """Perform one command.""" command = command.split() cmd = command[0] args = command[1:] win = QApplication.activeWindow() if win not in app.windows: if not app.windows: import mainwindow mainwindow.MainWindow().show() win = app.windows[0] if cmd == b'open': url = QUrl.fromEncoded(args[0]) try: win.openUrl(url, self.encoding) except IOError as e: filename = url.toLocalFile() msg = _("{message}\n\n{strerror} ({errno})").format( message = _("Could not read from: {url}").format(url=filename), strerror = e.strerror, errno = e.errno) QMessageBox.critical(win, app.caption(_("Error")), msg) elif cmd == b'encoding': self.encoding = str(args[0]) elif cmd == b'activate_window': win.activateWindow() win.raise_() elif cmd == b'set_current': url = QUrl.fromEncoded(args[0]) try: win.setCurrentDocument(app.openUrl(url)) # already loaded except IOError: pass elif cmd == b'set_cursor': line, column = map(int, args) cursor = win.textCursor() pos = cursor.document().findBlockByNumber(line - 1).position() + column cursor.setPosition(pos) win.currentView().setTextCursor(cursor) elif cmd == b'bye': self.close()
def _start_request_continue(self, method, host, port, path, data, handler, xml, mblogin=False, cacheloadcontrol=None, refresh=None, access_token=None): if (mblogin and host in MUSICBRAINZ_SERVERS and port == 80) or port == 443: urlstring = "https://%s%s" % (host, path) elif port is None or port == 80: urlstring = "http://%s%s" % (host, path) else: urlstring = "http://%s:%d%s" % (host, port, path) log.debug("%s %s", method, urlstring) url = QUrl.fromEncoded(urlstring) 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)
def navTo(self, index): navPoint = index.internalPointer() href = posixpath.join(self.ebook_info['temp_path'], self.ebook_info['opf_root'], navPoint.src) try: path, anchor = href.split('#') if path == self.webView.url().path(): self.webView.page().mainFrame().scrollToAnchor(anchor) return else: self.anchor = anchor except ValueError: pass url = QUrl.fromEncoded(href) self.webView.setUrl(url)
def _start_request_continue( self, method, host, port, path, data, handler, xml, mblogin=False, cacheloadcontrol=None, refresh=None, access_token=None, ): if (mblogin and host in MUSICBRAINZ_SERVERS and port == 80) or port == 443: urlstring = "https://%s%s" % (host, path) elif port is None or port == 80: urlstring = "http://%s%s" % (host, path) else: urlstring = "http://%s:%d%s" % (host, port, path) log.debug("%s %s", method, urlstring) url = QUrl.fromEncoded(urlstring) 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)
def get_next_render_item(self): render_item = None self.qlock.lock() keep_looping = True try: putback_rows = [] while keep_looping: data_item = self.pendingResponsesDataModel.popleft_data() ###-> print(data_item) if data_item: response_id, request_type, depth, status = data_item else: keep_looping = False if data_item is not None: if 'render' == request_type: row = self.Data.read_responses_by_id( self.read_cursor, response_id) if not row: self.framework.log_warning( 'missing response id: %s' % (response_id)) continue response_items = [m or '' for m in row] qurl = QUrl.fromEncoded( response_items[ResponsesTable.URL]) dataContent = str( response_items[ResponsesTable.RES_DATA]) render_item = (response_id, dataContent, qurl, depth) keep_looping = False else: # put back putback_rows.append(data_item) self.pendingResponsesDataModel.appendleft_data(putback_rows) except Exception as error: self.framework.report_exception(error) finally: self.qlock.unlock() ###--> print('next render item', render_item) return render_item
def getScenesOrtho(self, url, setFinished): @pyqtSlot(dict) def finished(response): self.access.finished.disconnect(finished) if response['isOk']: data = json.loads(str(response['data'])) response['url'] = data['links']['next'] response['scenes'] = data['features'] response['data'].clear() del response['data'] del response['statusRequest'] setFinished(response) url = QUrl.fromEncoded(url) self.access.finished.connect(finished) self.access.run(url, API_PlanetLabs.validKey, True)
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
def get_next_render_item(self): render_item = None self.qlock.lock() keep_looping = True try: putback_rows = [] while keep_looping: data_item = self.pendingResponsesDataModel.popleft_data() ###-> print(data_item) if data_item: response_id, request_type, depth, status = data_item else: keep_looping = False if data_item is not None: if 'render' == request_type: row = self.Data.read_responses_by_id(self.read_cursor, response_id) if not row: self.framework.log_warning('missing response id: %s' % (response_id)) continue response_items = [m or '' for m in row] qurl = QUrl.fromEncoded(response_items[ResponsesTable.URL]) dataContent = str(response_items[ResponsesTable.RES_DATA]) render_item = (response_id, dataContent, qurl, depth) keep_looping = False else: # put back putback_rows.append(data_item) self.pendingResponsesDataModel.appendleft_data(putback_rows) except Exception as error: self.framework.report_exception(error) finally: self.qlock.unlock() ###--> print('next render item', render_item) return render_item
def send(self, method, url, headers, body, context=None): qurl = QUrl.fromEncoded(url) request = QNetworkRequest() request.setUrl(qurl) method = self.translate_method(method, request) host, useragent, content_type = None, None, None for name, value in headers.items(): lname = name.lower() if 'user-agent' == lname: useragent = value elif 'host' == lname: host = value elif 'content-type' == lname: content_type = value elif 'content-length' == lname: continue request.setRawHeader(name, value) if not host: request.setRawHeader('Host', str(qurl.host())) if not useragent: request.setRawHeader('User-Agent', self.framework.useragent()) if 'POST' == method and not content_type: request.setRawHeader('Content-Type', 'application/x-www-form-urlencoded') if not body: if method in ( 'POST', 'PUT', 'CUSTOM' ): # TODO: determine specific methods that expect content? body = '' else: device = None if method in ('GET', 'HEAD', 'DELETE'): # can't have body, because not supported by Qt network logic body = None device = None if body is not None: request.setRawHeader('Content-Length', str(len(body))) data = QByteArray(body) device = QBuffer(self) device.setData(data) device.open(QIODevice.ReadOnly) request.setAttribute(request.CacheLoadControlAttribute, request.AlwaysNetwork) if 'GET' == method: reply = self.networkAccessManager.get(request) elif 'HEAD' == method: reply = self.networkAccessManager.head(request) elif 'DELETE' == method: reply = self.networkAccessManager.head(request) elif 'POST' == method: reply = self.networkAccessManager.post(request, device) elif 'PUT' == method: reply = self.networkAccessManager.put(request, device) else: reply = self.networkAccessManager.sendCustomRequest( request, method, device) response = NetworkResponse(self.framework, self.callback, reply, context, self) return NetworkRequest(request, reply, response, context, self)
def load_url(self,url): self.url=QUrl.fromEncoded(url) self.web.setUrl(self.url)
def doUpdateSiteMap(self): if not self.qlock.tryLock(): return try: if self.fillAll: self.fillAll = False self.treeViewModel.clearModel() self.lastId = 0 rows = self.Data.get_sitemap_info(self.cursor, self.lastId) global_cookie_jar = self.framework.get_global_cookie_jar() count = 0 for row in rows: count += 1 if 0 == (count % 100): self.yieldCurrentThread() rowItems = [m or "" for m in list(row)] Id = str(rowItems[0]) try: self.lastId = int(Id) except ValueError: pass # XXX: review all for bytes usage if isinstance(rowItems[1], bytes): url = str(rowItems[1], "utf-8", "ignore") else: url = str(rowItems[1]) status = str(rowItems[2]) response_headers = str(rowItems[3]) request_headers = str(rowItems[4]) # TODO: make configurable if status in ("400", "404", "500", "501"): continue # TODO: m = self.re_set_cookie.search(response_headers) if m: setCookies = m.group(1) cookieList = QNetworkCookie.parseCookies(setCookies) global_cookie_jar.setCookiesFromUrl(cookieList, QUrl.fromEncoded(url)) parsed = urlparse.urlsplit(url) hostname = "" if not parsed.hostname: m = self.re_host_name.search(request_headers) if m: hostname = m.group(1).rstrip() else: hostname = parsed.hostname hostname = hostname.lower() hostloc = urlparse.urlunsplit((parsed.scheme, parsed.netloc, "/", "", "")) rootNode = self.treeViewModel.findOrAddNode(hostname) hostLocNode = rootNode.findOrAddNode(self.treeViewModel, hostloc) pathval = parsed.path # add directories parentNode = hostLocNode parentNode.setResponseId(None, hostloc) lastSlash = 0 slash = 0 while True: slash = pathval.find("/", slash + 1) if slash < 0: break dirname = pathval[lastSlash + 1 : slash + 1] parentNode = parentNode.findOrAddNode(self.treeViewModel, dirname) parentNode.setResponseId( None, urlparse.urlunsplit((parsed.scheme, parsed.netloc, pathval[0 : slash + 1], "", "")) ) lastSlash = slash # add file element if lastSlash + 1 < len(pathval): filename = pathval[lastSlash + 1 :] parentNode = parentNode.findOrAddNode(self.treeViewModel, filename) parentNode.setResponseId(None, urlparse.urlunsplit((parsed.scheme, parsed.netloc, pathval, "", ""))) # add query if parsed.query: parentNode = parentNode.findOrAddNode(self.treeViewModel, "?" + parsed.query) # store the latest Id # TODO: should determine best candidate to display parentNode.setResponseId(Id, url) finally: self.qlock.unlock()
def load_url(self, url): self.url = QUrl.fromEncoded(url) self.web.setUrl(self.url)
def send(self, method, url, headers, body, context = None): qurl = QUrl.fromEncoded(url) request = QNetworkRequest() request.setUrl(qurl) method = self.translate_method(method, request) host, useragent, content_type = None, None, None for name, value in headers.items(): lname = name.lower() if 'user-agent' == lname: useragent = value elif 'host' == lname: host = value elif 'content-type' == lname: content_type = value elif 'content-length' == lname: continue request.setRawHeader(name, value) if not host: request.setRawHeader('Host', str(qurl.host())) if not useragent: request.setRawHeader('User-Agent', self.framework.useragent()) if 'POST' == method and not content_type: request.setRawHeader('Content-Type', 'application/x-www-form-urlencoded') if not body: if method in ('POST', 'PUT', 'CUSTOM'): # TODO: determine specific methods that expect content? body = '' else: device = None if method in ('GET', 'HEAD', 'DELETE'): # can't have body, because not supported by Qt network logic body = None device = None if body is not None: request.setRawHeader('Content-Length', str(len(body))) data = QByteArray(body) device = QBuffer(self) device.setData(data) device.open(QIODevice.ReadOnly) request.setAttribute(request.CacheLoadControlAttribute, request.AlwaysNetwork) if 'GET' == method: reply = self.networkAccessManager.get(request) elif 'HEAD' == method: reply = self.networkAccessManager.head(request) elif 'DELETE' == method: reply = self.networkAccessManager.head(request) elif 'POST' == method: reply = self.networkAccessManager.post(request, device) elif 'PUT' == method: reply = self.networkAccessManager.put(request, device) else: reply = self.networkAccessManager.sendCustomRequest(request, method, device) response = NetworkResponse(self.framework, self.callback, reply, context, self) return NetworkRequest(request, reply, response, context, self)
def __initializeUi(self): """ Initializes the Widget ui. """ umbra.ui.common.setWindowDefaultIcon(self) LOGGER.debug("> Initializing '{0}' ui.".format(self.__class__.__name__)) if Constants.applicationName not in self.__releases: self.sIBL_GUI_frame.hide() self.Get_sIBL_GUI_pushButton.hide() else: self.Logo_label.setPixmap(QPixmap(os.path.join(self.__uiResourcesDirectory, self.__uiLogoImage))) self.Your_Version_label.setText(self.__releases[Constants.applicationName].localVersion) self.Latest_Version_label.setText(self.__releases[Constants.applicationName].repositoryVersion) self.Change_Log_webView.load(QUrl.fromEncoded(QByteArray(self.__applicationChangesUrl))) templatesReleases = dict(self.__releases) if Constants.applicationName in self.__releases: templatesReleases.pop(Constants.applicationName) if not templatesReleases: self.Templates_frame.hide() self.Get_Latest_Templates_pushButton.hide() else: self.Templates_label.setPixmap(QPixmap(os.path.join(self.__uiResourcesDirectory, self.__uiTemplatesImage))) self.Templates_tableWidget.setParent(None) self.Templates_tableWidget = TemplatesReleases_QTableWidget(self, message="No Releases to view!") self.Templates_tableWidget.setObjectName("Templates_tableWidget") self.Templates_frame_gridLayout.addWidget(self.Templates_tableWidget, 1, 0) self.__view = self.Templates_tableWidget self.__view.clear() self.__view.setEditTriggers(QAbstractItemView.NoEditTriggers) self.__view.setRowCount(len(templatesReleases)) self.__view.setColumnCount(len(self.__headers)) self.__view.setHorizontalHeaderLabels(self.__headers) self.__view.hideColumn(0) self.__view.horizontalHeader().setStretchLastSection(True) palette = QPalette() palette.setColor(QPalette.Base, Qt.transparent) self.__view.setPalette(palette) verticalHeaderLabels = [] for row, release in enumerate(sorted(templatesReleases)): verticalHeaderLabels.append(release) tableWidgetItem = QTableWidgetItem() tableWidgetItem.data = templatesReleases[release] self.__view.setItem(row, 0, tableWidgetItem) tableWidgetItem = Variable_QPushButton(self, True, (self.__uiLightGrayColor, self.__uiDarkGrayColor), ("Yes", "No")) tableWidgetItem.setObjectName("Spread_Sheet_pushButton") self.__view.setCellWidget(row, 1, tableWidgetItem) tableWidgetItem = QTableWidgetItem(templatesReleases[release].localVersion or Constants.nullObject) tableWidgetItem.setTextAlignment(Qt.AlignCenter) self.__view.setItem(row, 2, tableWidgetItem) tableWidgetItem = QTableWidgetItem(templatesReleases[release].repositoryVersion) tableWidgetItem.setTextAlignment(Qt.AlignCenter) self.__view.setItem(row, 3, tableWidgetItem) tableWidgetItem = QTableWidgetItem(templatesReleases[release].type) tableWidgetItem.setTextAlignment(Qt.AlignCenter) self.__view.setItem(row, 4, tableWidgetItem) tableWidgetItem = QTableWidgetItem(templatesReleases[release].comment) self.__view.setItem(row, 5, tableWidgetItem) self.__view.setVerticalHeaderLabels(verticalHeaderLabels) self.__view.resizeColumnsToContents() # Signals / Slots. self.Get_sIBL_GUI_pushButton.clicked.connect(self.__Get_sIBL_GUI_pushButton__clicked) self.Get_Latest_Templates_pushButton.clicked.connect(self.__Get_Latest_Templates_pushButton__clicked) self.Open_Repository_pushButton.clicked.connect(self.__Open_Repository_pushButton__clicked) self.Close_pushButton.clicked.connect(self.__Close_pushButton__clicked)
def process_request(self): socket = self.sender() request_data = socket.readAll() if not self.authorize_request(request_data): socket.write('HTTP/1.1 407 Proxy Authentication Required\r\n') if self.debug: self.log.write('407 Proxy Authentication Required\n\n') socket.write('Proxy-Authenticate: Basic realm="test"\r\n') socket.write('\r\n') socket.disconnectFromHost() return else: # remove Proxy-Authorization header start = request_data.indexOf('Proxy-Authorization:') end = request_data.lastIndexOf('\r\n') request_data.remove(start, end) request_data.append('\r\n') pos = request_data.indexOf('\r\n') request_line = request_data.left(pos) request_data.remove(0, pos + 2) entries = request_line.split(' ') method = entries[0] address = entries[1] version = entries[2] port = '80' if address.count(':') > 1: protocol, host, port = address.split(':') else: protocol, host = address.split(':') print 'address', address #url = QUrl( protocol + host ) url = QUrl.fromEncoded(address) #url.setHost( host ) #url.setPort( int(port) ) if not url.isValid(): if self.debug: self.log.write('Invalid URL: %s\n\n', url) socket.disconnectFromHost() return host = url.host() port = 80 if (url.port() < 0) else url.port() req = url.encodedPath() if url.hasQuery(): req.append('?').append(url.encodedQuery()) request_line = method + ' ' + req + ' ' + version + '\r\n' request_data.prepend(request_line) if self.debug: self.log.write(method + ' ' + address + ' ' + version + '\n\n') key = host + ':' + QString.number(port) proxy_socket = socket.findChild(QTcpSocket, key) if proxy_socket: proxy_socket.setObjectName(key) proxy_socket.setProperty('url', url) proxy_socket.setProperty('request_data', request_data) proxy_socket.write(request_data) else: proxy_socket = QTcpSocket(socket) proxy_socket.setObjectName(key) proxy_socket.setProperty('url', url) proxy_socket.setProperty('request_data', request_data) proxy_socket.connected.connect(self.send_request) proxy_socket.readyRead.connect(self.transfer_data) proxy_socket.disconnected.connect(self.close_connection) proxy_socket.error.connect(self.close_connection) proxy_socket.connectToHost(host, port)
def doUpdateSiteMap(self): if not self.qlock.tryLock(): return try: if self.fillAll: self.fillAll = False self.treeViewModel.clearModel() self.lastId = 0 rows = self.Data.get_sitemap_info(self.cursor, self.lastId) global_cookie_jar = self.framework.get_global_cookie_jar() count = 0 for row in rows: count += 1 if 0 == (count % 100): self.yieldCurrentThread() rowItems = [m or '' for m in list(row)] Id = str(rowItems[0]) try: self.lastId = int(Id) except ValueError: pass # XXX: review all for bytes usage if isinstance(rowItems[1], bytes): url = str(rowItems[1], 'utf-8', 'ignore') else: url = str(rowItems[1]) status = str(rowItems[2]) response_headers = str(rowItems[3]) request_headers = str(rowItems[4]) # TODO: make configurable if status in ('400', '404', '500', '501'): continue # TODO: m = self.re_set_cookie.search(response_headers) if m: setCookies = m.group(1) cookieList = QNetworkCookie.parseCookies(setCookies) global_cookie_jar.setCookiesFromUrl( cookieList, QUrl.fromEncoded(url)) parsed = urlparse.urlsplit(url) hostname = '' if not parsed.hostname: m = self.re_host_name.search(request_headers) if m: hostname = m.group(1).rstrip() else: hostname = parsed.hostname hostname = hostname.lower() hostloc = urlparse.urlunsplit( (parsed.scheme, parsed.netloc, '/', '', '')) rootNode = self.treeViewModel.findOrAddNode(hostname) hostLocNode = rootNode.findOrAddNode(self.treeViewModel, hostloc) pathval = parsed.path # add directories parentNode = hostLocNode parentNode.setResponseId(None, hostloc) lastSlash = 0 slash = 0 while True: slash = pathval.find('/', slash + 1) if slash < 0: break dirname = pathval[lastSlash + 1:slash + 1] parentNode = parentNode.findOrAddNode( self.treeViewModel, dirname) parentNode.setResponseId( None, urlparse.urlunsplit((parsed.scheme, parsed.netloc, pathval[0:slash + 1], '', ''))) lastSlash = slash # add file element if lastSlash + 1 < len(pathval): filename = pathval[lastSlash + 1:] parentNode = parentNode.findOrAddNode( self.treeViewModel, filename) parentNode.setResponseId( None, urlparse.urlunsplit( (parsed.scheme, parsed.netloc, pathval, '', ''))) # add query if parsed.query: parentNode = parentNode.findOrAddNode( self.treeViewModel, '?' + parsed.query) # store the latest Id # TODO: should determine best candidate to display parentNode.setResponseId(Id, url) finally: self.qlock.unlock()
def process_request(self): socket = self.sender() request_data = socket.readAll() if not self.authorize_request(request_data): socket.write('HTTP/1.1 407 Proxy Authentication Required\r\n') if self.debug: self.log.write('407 Proxy Authentication Required\n\n') socket.write('Proxy-Authenticate: Basic realm="test"\r\n') socket.write('\r\n') socket.disconnectFromHost() return else: # remove Proxy-Authorization header start = request_data.indexOf('Proxy-Authorization:') end = request_data.lastIndexOf('\r\n') request_data.remove(start, end) request_data.append('\r\n') pos = request_data.indexOf('\r\n') request_line = request_data.left(pos) request_data.remove(0, pos + 2) entries = request_line.split(' ') method = entries[0] address = entries[1] version = entries[2] port = '80' if address.count(':') > 1: protocol, host, port = address.split(':') else: protocol, host = address.split(':') print 'address', address #url = QUrl( protocol + host ) url = QUrl.fromEncoded(address) #url.setHost( host ) #url.setPort( int(port) ) if not url.isValid(): if self.debug: self.log.write('Invalid URL: %s\n\n', url) socket.disconnectFromHost() return host = url.host() port = 80 if (url.port() < 0) else url.port() req = url.encodedPath() if url.hasQuery(): req.append('?').append(url.encodedQuery()) request_line = method + ' ' + req + ' ' + version + '\r\n' request_data.prepend(request_line) if self.debug: self.log.write(method + ' ' + address + ' ' + version + '\n\n') key = host + ':' + QString.number(port) proxy_socket = socket.findChild(QTcpSocket, key) if proxy_socket: proxy_socket.setObjectName(key) proxy_socket.setProperty('url', url) proxy_socket.setProperty('request_data', request_data) proxy_socket.write(request_data) else: proxy_socket = QTcpSocket(socket) proxy_socket.setObjectName(key) proxy_socket.setProperty('url', url) proxy_socket.setProperty('request_data', request_data) proxy_socket.connected.connect(self.send_request) proxy_socket.readyRead.connect(self.transfer_data) proxy_socket.disconnected.connect(self.close_connection) proxy_socket.error.connect(self.close_connection) proxy_socket.connectToHost(host, port)
def __initializeUi(self): """ Initializes the Widget ui. """ umbra.ui.common.setWindowDefaultIcon(self) LOGGER.debug("> Initializing '{0}' ui.".format( self.__class__.__name__)) if Constants.applicationName not in self.__releases: self.sIBL_GUI_frame.hide() self.Get_sIBL_GUI_pushButton.hide() else: self.Logo_label.setPixmap( QPixmap( os.path.join(self.__uiResourcesDirectory, self.__uiLogoImage))) self.Your_Version_label.setText( self.__releases[Constants.applicationName].localVersion) self.Latest_Version_label.setText( self.__releases[Constants.applicationName].repositoryVersion) self.Change_Log_webView.load( QUrl.fromEncoded(QByteArray(self.__applicationChangesUrl))) templatesReleases = dict(self.__releases) if Constants.applicationName in self.__releases: templatesReleases.pop(Constants.applicationName) if not templatesReleases: self.Templates_frame.hide() self.Get_Latest_Templates_pushButton.hide() else: self.Templates_label.setPixmap( QPixmap( os.path.join(self.__uiResourcesDirectory, self.__uiTemplatesImage))) self.Templates_tableWidget.setParent(None) self.Templates_tableWidget = TemplatesReleases_QTableWidget( self, message="No Releases to view!") self.Templates_tableWidget.setObjectName("Templates_tableWidget") self.Templates_frame_gridLayout.addWidget( self.Templates_tableWidget, 1, 0) self.__view = self.Templates_tableWidget self.__view.clear() self.__view.setEditTriggers(QAbstractItemView.NoEditTriggers) self.__view.setRowCount(len(templatesReleases)) self.__view.setColumnCount(len(self.__headers)) self.__view.setHorizontalHeaderLabels(self.__headers) self.__view.hideColumn(0) self.__view.horizontalHeader().setStretchLastSection(True) palette = QPalette() palette.setColor(QPalette.Base, Qt.transparent) self.__view.setPalette(palette) verticalHeaderLabels = [] for row, release in enumerate(sorted(templatesReleases)): verticalHeaderLabels.append(release) tableWidgetItem = QTableWidgetItem() tableWidgetItem.data = templatesReleases[release] self.__view.setItem(row, 0, tableWidgetItem) tableWidgetItem = Variable_QPushButton( self, True, (self.__uiLightGrayColor, self.__uiDarkGrayColor), ("Yes", "No")) tableWidgetItem.setObjectName("Spread_Sheet_pushButton") self.__view.setCellWidget(row, 1, tableWidgetItem) tableWidgetItem = QTableWidgetItem( templatesReleases[release].localVersion or Constants.nullObject) tableWidgetItem.setTextAlignment(Qt.AlignCenter) self.__view.setItem(row, 2, tableWidgetItem) tableWidgetItem = QTableWidgetItem( templatesReleases[release].repositoryVersion) tableWidgetItem.setTextAlignment(Qt.AlignCenter) self.__view.setItem(row, 3, tableWidgetItem) tableWidgetItem = QTableWidgetItem( templatesReleases[release].type) tableWidgetItem.setTextAlignment(Qt.AlignCenter) self.__view.setItem(row, 4, tableWidgetItem) tableWidgetItem = QTableWidgetItem( templatesReleases[release].comment) self.__view.setItem(row, 5, tableWidgetItem) self.__view.setVerticalHeaderLabels(verticalHeaderLabels) self.__view.resizeColumnsToContents() # Signals / Slots. self.Get_sIBL_GUI_pushButton.clicked.connect( self.__Get_sIBL_GUI_pushButton__clicked) self.Get_Latest_Templates_pushButton.clicked.connect( self.__Get_Latest_Templates_pushButton__clicked) self.Open_Repository_pushButton.clicked.connect( self.__Open_Repository_pushButton__clicked) self.Close_pushButton.clicked.connect(self.__Close_pushButton__clicked)