Esempio n. 1
0
    def init(self):

        self.header.addPosition('UPs List')
        upsList = self.DBJobs.read({}, {'fields': ['up', 'COUNT(id) AS count'], 'groupBy': 'up', 'order': 'up', 'sort': 'DESC'})

        self.upsList = []
        for up in upsList:
            if not up['up']:
                continue

            parts = up['up'].split('-')
            self.upsList.append({
                'name'    : up['up'],
                'product' : parts[0],
                'revision': parts[1] if len(parts) > 1 else '',
                'count'   : up['count'],
                'upgrade' : 1 if len(up['up'].split('R')) > 2 else 0
            })


        self.list = List.List(self.window, self.finder, self.upsList, self.menuHeader)
        self.list.refresh()

        keysHelper = KeysHelper.KeysHelper()
        exporter   = Exporter.Exporter(self.screen, self.window, self.header, self.menuHeader)

        while 1:
            key = self.screen.getch()

            if key not in keysHelper.getAll():
                continue

            if key in keysHelper.getEscape():
                break

            if key in keysHelper.getExport():
                exporter.jira(self.list.getFilteredData())
                self.list.refresh()

            if key in keysHelper.getNavigation():
                self.list.input(key)

            if key in keysHelper.getInput():
                self.finder.input(key)
                self.list.refresh()

            if key in keysHelper.getEnter():
                self.enter()

        self.header.removePosition()
        self.finder.clear()
Esempio n. 2
0
    def init(self):

        self.header.addPosition('Test Suites List')
        self.suitesList = self.DBJobsSuites.read(
            [['suite', '!=', '""']], {
                'fields': ['suite', 'COUNT(suite) AS count'],
                'groupBy': 'suite',
                'sort': 'ASC',
                'order': 'suite'
            })

        self.list = List.List(self.window, self.finder, self.suitesList,
                              self.menuHeader)
        self.list.refresh()

        keysHelper = KeysHelper.KeysHelper()
        exporter = Exporter.Exporter(self.screen, self.window, self.header,
                                     self.menuHeader)

        while 1:
            key = self.screen.getch()

            if key not in keysHelper.getAll():
                continue

            if key in keysHelper.getEscape():
                break

            if key in keysHelper.getExport():
                exporter.jira(self.list.getFilteredData())
                self.list.refresh()

            if key in keysHelper.getNavigation():
                self.list.input(key)

            if key in keysHelper.getInput():
                self.finder.input(key)
                self.list.refresh()

            if key in keysHelper.getEnter():
                self.enter()

        self.header.removePosition()
        self.finder.clear()
Esempio n. 3
0
    def init(self):

        self.oldFilter = self.finder.getData()
        self.finder.clear()

        self.header.addPosition('Comments')

        self.list = List.List(self.window, self.finder, self.comments,
                              self.menuHeader)
        self.list.refresh()

        keysHelper = KeysHelper.KeysHelper()
        exporter = Exporter.Exporter(self.screen, self.window, self.header,
                                     self.menuHeader)

        while 1:
            key = self.screen.getch()

            if key not in keysHelper.getAll():
                continue

            if key in keysHelper.getEscape():
                self.finder.clear()
                break

            if key in keysHelper.getExport():
                exporter.jira(self.list.getFilteredData())
                self.list.refresh()

            if key in keysHelper.getNavigation():
                self.list.input(key)

            if key in keysHelper.getInput():
                self.finder.input(key)
                self.list.refresh()

        self.header.removePosition()
        self.finder.clear()
Esempio n. 4
0
    def init(self):

        if self.params:
            if 'showStpOwners' in self.params:
                self.header.addPosition('Owners of STP: {0}'.format(
                    self.params['showStpOwners']))

                stpId = self.DBStps.read(
                    {'name': self.params['showStpOwners']},
                    {'fields': 'id'})[0]['id']
                owners = self.DBStpOwners.read({'stp_id': stpId},
                                               {'fields': 'user_id'})
                usersIds = map(lambda x: x['user_id'], owners)
                usersList = self.DBUsers.read({'id': usersIds})
                stpOwners = self.DBStpOwners.read({'user_id': usersIds})

        else:
            self.header.addPosition('Users List')
            usersList = self.DBUsers.read({})
            stpOwners = self.DBStpOwners.read({})

        countedOwners = {}
        for stpOwner in stpOwners:
            if stpOwner['user_id'] in countedOwners:
                countedOwners[stpOwner['user_id']] += 1
            else:
                countedOwners[stpOwner['user_id']] = 1

        # Wyliczmy ile jobow przypada na poszczegolnego uzytkownika
        usersSignums = map(lambda x: x['signum'], usersList)
        OwnerJobsCount = self.DBJobs.read(
            {'owner': usersSignums}, {
                'fields': ['owner', 'COUNT(*) AS count'],
                'groupBy': 'owner'
            })
        countedJobs = {}
        for jobCnt in OwnerJobsCount:
            countedJobs[jobCnt['owner']] = jobCnt['count']

        self.usersList = []
        for user in usersList:
            if not user['signum']:
                continue

            self.usersList.append({
                'signum':
                user['signum'],
                'email':
                user['email'] if user['email'] else '-',
                'stps':
                countedOwners[user['id']]
                if user['id'] in countedOwners else 0,
                'jobsCount':
                countedJobs[user['signum']]
                if user['signum'] in countedJobs else 0
            })

        self.list = List.List(self.window, self.finder, self.usersList,
                              self.menuHeader)
        self.list.refresh()

        keysHelper = KeysHelper.KeysHelper()
        exporter = Exporter.Exporter(self.screen, self.window, self.header,
                                     self.menuHeader)

        while 1:
            key = self.screen.getch()

            if key not in keysHelper.getAll():
                continue

            if key in keysHelper.getEscape():
                break

            if key in keysHelper.getExport():
                exporter.jira(self.list.getFilteredData())
                self.list.refresh()

            if key in keysHelper.getNavigation():
                self.list.input(key)

            if key in keysHelper.getInput():
                self.finder.input(key)
                self.list.refresh()

            if key in keysHelper.getEnter():
                self.enter()

        self.header.removePosition()
        self.finder.clear()
Esempio n. 5
0
    def init(self):

        if self.params:
            if 'showUserStps' in self.params:
                self.header.addPosition('STPs of user: {0}'.format(
                    self.params['showUserStps']))

                userData = self.DBUsers.read(
                    {'signum': self.params['showUserStps']})
                userStpsList = self.DBStpOwners.read(
                    {'user_id': userData[0]['id']})
                userStpsIds = map(lambda x: x['stp_id'], userStpsList)

                self.stpsList = self.DBStps.read({'id': userStpsIds})

            elif 'showOrgStps' in self.params:
                self.header.addPosition('STPs of org: {0}'.format(
                    self.params['showOrgStps']))
                self.stpsList = self.DBStps.read(
                    {'customer_organization': self.params['showOrgStps']})

            elif 'showWorkerStps' in self.params:
                self.header.addPosition('STPs of worker: {0}'.format(
                    self.params['showWorkerStps']))
                self.stpsList = self.DBStps.read(
                    {'worker': self.params['showWorkerStps']})

            elif 'showSiteStps' in self.params:
                self.header.addPosition('STPs from Site: {0}'.format(
                    self.params['showSiteStps']))
                self.stpsList = self.DBStps.read(
                    {'site': self.params['showSiteStps']})

        else:
            self.header.addPosition('STPs List')
            self.stpsList = self.DBStps.read({})

        self.list = List.List(self.window, self.finder, self.stpsList,
                              self.menuHeader)
        self.list.refresh()

        keysHelper = KeysHelper.KeysHelper()
        exporter = Exporter.Exporter(self.screen, self.window, self.header,
                                     self.menuHeader)

        while 1:
            key = self.screen.getch()

            if key not in keysHelper.getAll():
                continue

            if key in keysHelper.getEscape():
                break

            if key in keysHelper.getExport():
                exporter.jira(self.list.getFilteredData())
                self.list.refresh()

            if key in keysHelper.getNavigation():
                self.list.input(key)

            if key in keysHelper.getInput():
                self.finder.input(key)
                self.list.refresh()

            if key in keysHelper.getEnter():
                self.enter()

        self.header.removePosition()
        self.finder.clear()
Esempio n. 6
0
    def init(self):

        if self.params:
            if 'showStpAlarms' in self.params:
                self.header.addPosition('Alarms of STP: {0}'.format(
                    self.params['showStpAlarms']))
                stpData = self.DBStps.read(
                    {'name': self.params['showStpAlarms']})
                alarmList = self.DBAlarms.read({'stp_id': stpData[0]['id']}, {
                    'sort': 'DESC',
                    'order': 'id'
                })
        else:
            self.header.addPosition('Active Alarms List')
            alarmList = self.DBAlarms.read([['date_notice_end', 'IS', 'NULL']])

        stpIds = map(lambda x: x['stp_id'], alarmList)
        stpData = self.DBStps.read({'id': stpIds})
        stpMap = {}
        for stp in stpData:
            stpMap[stp['id']] = stp['name']

        self.alarmsList = []
        for alarm in alarmList:
            alarm['stp_name'] = stpMap[alarm['stp_id']]
            alarm[
                'active'] = 'YES' if alarm['date_notice_end'] == None else 'NO'
            self.alarmsList.append(alarm)

        self.list = List.List(self.window, self.finder, self.alarmsList,
                              self.menuHeader)
        self.list.refresh()

        keysHelper = KeysHelper.KeysHelper()
        exporter = Exporter.Exporter(self.screen, self.window, self.header,
                                     self.menuHeader)

        while 1:
            key = self.screen.getch()

            if key not in keysHelper.getAll():
                continue

            if key in keysHelper.getEscape():
                break

            if key in keysHelper.getExport():
                exporter.jira(self.list.getFilteredData())
                self.list.refresh()

            if key in keysHelper.getNavigation():
                self.list.input(key)

            if key in keysHelper.getInput():
                self.finder.input(key)
                self.list.refresh()

            if key in keysHelper.getEnter():
                self.enter()

        self.header.removePosition()
        self.finder.clear()
Esempio n. 7
0
    def init(self):

        if self.params:
            if 'showUpJobs' in self.params:
                self.header.addPosition('Jobs for UP: {0}'.format(
                    self.params['showUpJobs']))
                jobsList = self.DBJobs.read({'up': self.params['showUpJobs']},
                                            {
                                                'sort': 'DESC',
                                                'order': 'id'
                                            })

            elif 'showStpJobs' in self.params:
                self.header.addPosition('Jobs for STP: {0}'.format(
                    self.params['showStpJobs']))
                jobsList = self.DBJobs.read(
                    {'stp': self.params['showStpJobs']}, {
                        'sort': 'DESC',
                        'order': 'id'
                    })

            elif 'showUserJobs' in self.params:
                self.header.addPosition('Jobs for User: {0}'.format(
                    self.params['showUserJobs']))
                jobsList = self.DBJobs.read(
                    {'owner': self.params['showUserJobs']}, {
                        'sort': 'DESC',
                        'order': 'id'
                    })

            elif 'showSuiteJobs' in self.params:
                self.header.addPosition('Jobs for Suite: {0}'.format(
                    self.params['showSuiteJobs']))
                suitesIds = self.DBJobsSuites.read(
                    {'suite': self.params['showSuiteJobs']},
                    {'fields': 'job_id'})
                suiteJobsIds = map(lambda x: x['job_id'], suitesIds)
                jobsList = self.DBJobs.read({'id': suiteJobsIds}, {
                    'sort': 'DESC',
                    'order': 'id'
                })

        else:
            self.header.addPosition('Jobs List')
            jobsList = self.DBJobs.read({}, {
                'sort': 'DESC',
                'order': 'id',
                'limit': 10000
            })

        jobsIds = map(lambda x: x['id'], jobsList)
        jobsSuites = self.DBJobsSuites.read({'job_id': jobsIds})
        mappedSuites = {}
        for prop in jobsSuites:
            tmpJobId = prop['job_id']
            del (prop['job_id'])
            if tmpJobId in mappedSuites:
                mappedSuites[tmpJobId].append(prop)
            else:
                mappedSuites[tmpJobId] = [prop]

        self.jobsList = []
        for job in jobsList:
            job['suite'] = map(lambda x: x['suite'], mappedSuites[job['id']])
            job['ok'] = map(lambda x: x['ok'], mappedSuites[job['id']])
            job['nok'] = map(lambda x: x['nok'], mappedSuites[job['id']])
            job['skip'] = map(lambda x: x['skip'], mappedSuites[job['id']])
            self.jobsList.append(job)

        self.list = List.List(self.window, self.finder, self.jobsList,
                              self.menuHeader)
        self.list.refresh()

        keysHelper = KeysHelper.KeysHelper()
        exporter = Exporter.Exporter(self.screen, self.window, self.header,
                                     self.menuHeader)

        while 1:
            key = self.screen.getch()

            if key not in keysHelper.getAll():
                continue

            if key in keysHelper.getEscape():
                break

            if key in keysHelper.getExport():
                exporter.jira(self.list.getFilteredData())
                self.list.refresh()

            if key in keysHelper.getNavigation():
                self.list.input(key)

            if key in keysHelper.getInput():
                self.finder.input(key)
                self.list.refresh()

            if key in keysHelper.getEnter():
                self.enter()

        self.header.removePosition()
        self.finder.clear()