def authorise(self): with Busy(): # do full authentication procedure if self.auth_server: self.auth_server.running = False self.auth_server_thread.quit() self.auth_server = AuthServer() self.auth_server_thread = QtCore.QThread(self) self.auth_server.moveToThread(self.auth_server_thread) self.auth_server.response.connect(self.auth_response) self.auth_server_thread.started.connect(self.auth_server.start) self.auth_server_thread.start() redirect_uri = 'http://127.0.0.1:' + str(self.auth_server.port) auth_url = self.session.get_auth_url(redirect_uri) if not QtGui.QDesktopServices.openUrl(QtCore.QUrl(auth_url)): logger.error('Failed to open web browser') self.auth_server.running = False self.auth_server = None self.auth_server_thread.quit()
def authorise(self): with Busy(): # do full authentication procedure http_server = HTTPServer(('127.0.0.1', 0), AuthRequestHandler) redirect_uri = 'http://127.0.0.1:' + str(http_server.server_port) auth_url = self.session.get_auth_url(redirect_uri) if not auth_url: logger.error('Failed to get auth URL') http_server.server_close() return server = AuthServer() thread = QtCore.QThread(self) server.moveToThread(thread) server.server = http_server server.response.connect(self.auth_response) thread.started.connect(server.handle_requests) server.finished.connect(thread.quit) server.finished.connect(server.deleteLater) thread.finished.connect(thread.deleteLater) thread.start() if QtGui.QDesktopServices.openUrl(QtCore.QUrl(auth_url)): return logger.error('Failed to open web browser')
def load_mapbox_tos(self): QtGui.QDesktopServices.openUrl( QtCore.QUrl('https://www.mapbox.com/tos/'))
def load_tou_osm(self): QtGui.QDesktopServices.openUrl( QtCore.QUrl('http://www.openstreetmap.org/copyright'))
def load_tou_opencage(self): QtGui.QDesktopServices.openUrl( QtCore.QUrl('https://geocoder.opencagedata.com/'))
def load_url(self, auth_url): self.browser.load(QtCore.QUrl(auth_url))
def open_docs(self): QtGui.QDesktopServices.openUrl( QtCore.QUrl('http://photini.readthedocs.io/'))