def get_data(self): print("checking %s" % self.server_config.url) try: data = self.connection.connect(self.server_config, self.timeout) except Exception as ex: print(ex) return Response( ContinuousIntegrationServer(self.server_config.url, [], True), ex) dom = minidom.parseString(data) print("processed %s" % self.server_config.url) projects = [] for node in dom.getElementsByTagName('Project'): projects.append( Project( self.server_config.url, self.server_config.prefix, self.server_config.timezone, { 'name': node.getAttribute('name'), 'lastBuildStatus': node.getAttribute('lastBuildStatus'), 'lastBuildLabel': node.getAttribute('lastBuildLabel'), 'activity': node.getAttribute('activity'), 'url': node.getAttribute('webUrl'), 'lastBuildTime': node.getAttribute('lastBuildTime') })) return Response( ContinuousIntegrationServer(self.server_config.url, projects))
def get_data(self) -> Response: print("checking %s" % self.server_config.url) try: headers = {} if self.server_config.authentication_type == ServerConfig.AUTH_BEARER_TOKEN: headers['Authorization'] = 'Bearer %s' % self.server_config.password data = self.connection.connect(self.server_config, self.timeout, headers) except Exception as ex: print(ex) return Response(ContinuousIntegrationServer(self.server_config.url, [], True), ex) dom = minidom.parseString(data) print("processed %s" % self.server_config.url) projects = [] for node in dom.getElementsByTagName('Project'): projects.append(Project( self.server_config.url, self.server_config.prefix, self.server_config.timezone, { 'name': node.getAttribute('name'), 'lastBuildStatus': node.getAttribute('lastBuildStatus'), 'lastBuildLabel': node.getAttribute('lastBuildLabel'), 'activity': node.getAttribute('activity'), 'url': node.getAttribute('webUrl'), 'lastBuildTime': node.getAttribute('lastBuildTime') })) return Response(ContinuousIntegrationServer(self.server_config.url, projects))
def handle_errors(self, response: Response): if response.ssl_error(): reply = QMessageBox.question( self, "Failed to fetch projects", "<b>SSL error, retry without verification?:</b> %s" % self.qtText(str(response.error)), QMessageBox.Yes, QMessageBox.No) if reply == QMessageBox.Yes: self.skip_ssl_verification = True self.fetch_data() return if response.failed(): QMessageBox.critical( self, "Failed to fetch projects", "<b>Error:</b> %s" % self.qtText(str(response.error)))
def load_data(self, response: Response): self.ui.loadUrlButton.setEnabled(True) if response.failed(): self.handle_errors(response) return self.ui.stackedWidget.setCurrentIndex(1) projects_model = QtGui.QStandardItemModel() projects_model.itemChanged.connect( self.project_checked) # type: ignore projects_model.setHorizontalHeaderLabels(['Select Projects']) self.projects_list = QtGui.QStandardItem("All") self.projects_list.setCheckable(True) for project in response.server.projects: item = QtGui.QStandardItem(project.name) item.setCheckable(True) check = Qt.Unchecked if project.name in self.server.excluded_projects else Qt.Checked item.setCheckState(check) self.projects_list.appendRow(item) projects_model.appendRow(self.projects_list) self.ui.projectsList.setModel(projects_model) self.ui.projectsList.expandToDepth(1) self.ui.projectsList.setItemsExpandable(False) self.ui.projectsList.setRootIsDecorated(False)
class ProjectLoader(object): def __init__(self, server_config, timeout, connection=HttpConnection()): self.server_config = server_config self.timeout = timeout self.connection = connection def get_data(self): print "checking %s" % self.server_config.url try: data = self.connection.connect(self.server_config, self.timeout) except Exception, ex: print ex return Response( ContinuousIntegrationServer(self.server_config.url, [], True), ex) dom = minidom.parse(data) print "processed %s" % self.server_config.url projects = [] for node in dom.getElementsByTagName('Project'): projects.append( Project( self.server_config.url, self.server_config.prefix, self.server_config.timezone, { 'name': node.getAttribute('name'), 'lastBuildStatus': node.getAttribute('lastBuildStatus'), 'lastBuildLabel': node.getAttribute('lastBuildLabel'), 'activity': node.getAttribute('activity'), 'url': node.getAttribute('webUrl'), 'lastBuildTime': node.getAttribute('lastBuildTime') })) return Response( ContinuousIntegrationServer(self.server_config.url, projects))
def get_data(self): print "checking %s" % self.server_config.url try: data = self.connection.connect(self.server_config, self.timeout) except Exception, ex: print ex return Response( ContinuousIntegrationServer(self.server_config.url, [], True), ex)
def test_should_return_ssl_error(self): response = Response({}, SSLError()) self.assertTrue(response.failed()) self.assertTrue(response.ssl_error())