Beispiel #1
0
    def create_menu_item(self, project: Project, icon: QIcon):
        menu_item_label = project.label(self.conf.get_show_last_build_label())
        if self.conf.get_value("lastBuildTimeForProject"):
            menu_item_label = menu_item_label + ", " + DistanceOfTime(
                project.get_last_build_time()).age() + " ago"

        action = self.menu.addAction(icon, menu_item_label)
        action.setIconVisibleInMenu(True)
        action.triggered.connect(partial(self.open_url, url=project.url))
Beispiel #2
0
 def test_should_ignore_empty_last_build_time(self):
     project = Project('i', None, 'None', {
         'lastBuildTime': '',
         'name': 'g',
         'lastBuildStatus': 'n',
         'activity': 'o',
         'url': 'r'})
     self.assertEqual(datetime.datetime.now().date(), project.get_last_build_time().date())
     self.assertEqual(tzlocal(), project.get_last_build_time().tzinfo)
Beispiel #3
0
    def test_should_display_last_build_label_on_demand(self):
        project = Project('url', None, 'None', {
            'name': 'proj1',
            'lastBuildStatus': 'Success',
            'activity': 'Sleeping',
            'url': '1.2.3.4:8080/cc.xml',
            'lastBuildLabel': 'master',
            'lastBuildTime': '2009-05-29T13:54:07'
        })

        self.assertEqual('proj1', project.label())
        self.assertEqual('proj1 (master)', project.label(True))
Beispiel #4
0
 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))
Beispiel #5
0
    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))
Beispiel #6
0
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))
Beispiel #7
0
 def tzproj(cls, time, timezone='None'):
     return Project('url', None, timezone, {
         'name': 'proj1',
         'lastBuildStatus': 'Success',
         'activity': 'Sleeping',
         'url': 'someurl',
         'lastBuildLabel': '120',
         'lastBuildTime': time
     })
Beispiel #8
0
 def test_should_not_override_existing_url_scheme(self):
     project = Project('url', '', 'tz', {
         'name': 'proj1',
         'lastBuildStatus': 'Success',
         'activity': 'Sleeping',
         'url': 'https://10.0.0.1/project1',
         'lastBuildLabel': '120',
         'lastBuildTime': '2009-05-29T13:54:07'
     })
     self.assertEqual('https://10.0.0.1/project1', project.url)
Beispiel #9
0
    def test_should_correctly_parse_project(self):
        project = Project('url', None, 'None', {
            'name': 'proj1',
            'lastBuildStatus': 'Success',
            'activity': 'Sleeping',
            'url': '1.2.3.4:8080/cc.xml',
            'lastBuildLabel': '120',
            'lastBuildTime': '2009-05-29T13:54:07'
        })

        self.assertEqual('url', project.server_url)
        self.assertEqual('proj1', project.name)
        self.assertEqual('Success', project.status)
        self.assertEqual('http://1.2.3.4:8080/cc.xml', project.url)
        self.assertEqual('Sleeping', project.activity)
        self.assertEqual('2009-05-29T13:54:07', project.last_build_time)
        self.assertEqual('120', project.last_build_label)
        self.assertEqual(datetime.datetime(2009, 5, 29, 13, 54, 7, 0, tzlocal()), project.get_last_build_time())
        self.assertEqual("Success.Sleeping", project.get_build_status())
 def tuple_for(self, new_project: Project) -> ProjectTuple:
     for project in self.old_projects:
         if new_project.matches(project):
             return ProjectTuple(new_project, project)
     return ProjectTuple(new_project, None)
Beispiel #11
0
 def build(self):
     return Project(self.url, self._prefix, self._timezone,
                    Attrs(self.attrs))