Esempio n. 1
0
File: root.py Progetto: H3C/pulpito
    def index(self, latest=False, branch='', machine_type='', status='',
              suite='', date='', to_date=''):
        filters = get_run_filters(latest=latest, branch=branch,
                                  machine_type=machine_type, status=status,
                                  suite=suite, date=date, to_date=to_date)
        request.context['filters'] = filters

        uri = '{base}/runs/'.format(base=base_url)
        if branch:
            uri += 'branch/%s/' % branch
        if machine_type:
            uri += 'machine_type/%s/' % machine_type
        if status:
            uri += 'status/%s/' % status
        if suite:
            uri += 'suite/%s/' % suite
        if to_date and date:
            uri += 'date/from/{from_}/to/{to}/'.format(from_=date, to=to_date)
        elif date:
            uri += 'date/%s/' % date
        if status == 'running':
            uri += '?count=9999'

        latest_runs = requests.get(uri).json()
        for run in latest_runs:
            prettify_run(run)
        latest_runs.sort(key=run_sorter, reverse=True)
        return dict(runs=latest_runs,
                    filters=request.context.get('filters', dict()),
                    branch=branch,
                    machine_type=machine_type,
                    suite=suite,
                    dates=[date, to_date],
                    )
Esempio n. 2
0
File: root.py Progetto: H3C/pulpito
    def date(self, from_date_str, to='', to_date_str=''):
        filters = get_run_filters(date=from_date_str, to_date=to_date_str)
        request.context['filters'] = filters
        if to:
            resp = requests.get(
                '{base}/runs/date/from/{from_}/to/{to}'.format(
                    base=base_url, from_=from_date_str, to=to_date_str))
        else:
            resp = requests.get('{base}/runs/date/{date}/'.format(
                base=base_url, date=from_date_str))

        if resp.status_code == 400:
            error('/errors/invalid/',
                  resp.json().get('message'))
        elif resp.status_code == 404:
            error('/errors/not_found/',
                  resp.json().get('message'))
        else:
            runs = resp.json()

        for run in runs:
            prettify_run(run)
        runs.sort(key=run_sorter)
        return dict(runs=runs,
                    filters=request.context.get('filters', dict()),
                    dates=[from_date_str, to_date_str]
                    )
Esempio n. 3
0
    def date(self, from_date_str, to='', to_date_str=''):
        filters = get_run_filters(date=from_date_str, to_date=to_date_str)
        request.context['filters'] = filters
        if to:
            url = urlparse.urljoin(
                base_url,
                '/runs/date/from/{0}/to/{1}'.format(from_date_str,
                                                    to_date_str))
        else:
            url = urlparse.urljoin(base_url,
                                   '/runs/date/{0}/'.format(from_date_str))
        resp = requests.get(url)

        if resp.status_code == 400:
            error('/errors/invalid/', resp.json().get('message'))
        elif resp.status_code == 404:
            error('/errors/not_found/', resp.json().get('message'))
        else:
            runs = resp.json()

        for run in runs:
            prettify_run(run)
        runs.sort(key=run_sorter)
        return dict(runs=runs,
                    filters=request.context.get('filters', dict()),
                    dates=[from_date_str, to_date_str])
Esempio n. 4
0
    def index(self,
              latest=False,
              branch='',
              machine_type='',
              sha1='',
              status='',
              suite='',
              date='',
              to_date='',
              page='1'):
        filters = get_run_filters(
            latest=latest,
            branch=branch,
            machine_type=machine_type,
            sha1=sha1,
            status=status,
            suite=suite,
            date=date,
            to_date=to_date,
        )
        request.context['filters'] = filters
        urlencode_args = dict()

        uri = urlparse.urljoin(base_url, '/runs/')
        if branch:
            uri += 'branch/%s/' % branch
        if machine_type:
            uri += 'machine_type/%s/' % machine_type
        if sha1:
            uri += 'sha1/%s/' % sha1
        if status:
            uri += 'status/%s/' % status
        if suite:
            uri += 'suite/%s/' % suite
        if to_date and date:
            uri += 'date/from/{from_}/to/{to}/'.format(from_=date, to=to_date)
        elif date:
            uri += 'date/%s/' % date
        if status == 'running':
            urlencode_args['count'] = 9999
        if page > 1:
            urlencode_args['page'] = page
        if urlencode_args:
            uri += '?%s' % urllib.urlencode(urlencode_args)

        latest_runs = requests.get(uri).json()
        for run in latest_runs:
            prettify_run(run)
        latest_runs.sort(key=run_sorter, reverse=True)
        return dict(
            runs=latest_runs,
            filters=request.context.get('filters', dict()),
            branch=branch,
            machine_type=machine_type,
            suite=suite,
            dates=[date, to_date],
            page=page,
            sha1=sha1,
        )
Esempio n. 5
0
 def index(self):
     url = urlparse.urljoin(base_url, '/runs/queued/')
     resp = requests.get(url)
     runs = resp.json()
     for run in runs:
         prettify_run(run)
     return dict(
         title="The Queue",
         runs=runs,
     )
Esempio n. 6
0
File: queue.py Progetto: H3C/pulpito
 def index(self):
     url = "{base}/runs/queued/".format(base=base_url)
     resp = requests.get(url)
     runs = resp.json()
     for run in runs:
         prettify_run(run)
     return dict(
         title="The Queue",
         runs=runs,
     )
Esempio n. 7
0
    def get_run(self):
        url = urlparse.urljoin(base_url, '/runs/%s/' % self.name)
        resp = requests.get(url)
        if resp.status_code == 404:
            error('/errors/not_found/', 'requested run does not exist')
        else:
            run = resp.json()

        if 'scheduled' in run:
            run['scheduled_day'] = run['scheduled'].split()[0]

        if 'jobs' in run:
            for job in run['jobs']:
                prettify_job(job)

        prettify_run(run)
        self.run = run
        return self.run
Esempio n. 8
0
File: root.py Progetto: ceph/pulpito
    def get_run(self):
        url = urlparse.urljoin(base_url, '/runs/%s/' % self.name)
        resp = requests.get(url)
        if resp.status_code == 404:
            error('/errors/not_found/',
                  'requested run does not exist')
        else:
            run = resp.json()

        if 'scheduled' in run:
            run['scheduled_day'] = run['scheduled'].split()[0]

        if 'jobs' in run:
            for job in run['jobs']:
                prettify_job(job)

        prettify_run(run)
        self.run = run
        return self.run
Esempio n. 9
0
File: root.py Progetto: H3C/pulpito
    def get_run(self):
        resp = requests.get(
            '{base}/runs/{name}'.format(base=base_url,
                                        name=self.name))
        if resp.status_code == 404:
            error('/errors/not_found/',
                  'requested run does not exist')
        else:
            run = resp.json()

        if 'scheduled' in run:
            run['scheduled_day'] = run['scheduled'].split()[0]

        if 'jobs' in run:
            for job in run['jobs']:
                prettify_job(job)

        prettify_run(run)
        self.run = run
        return self.run
Esempio n. 10
0
File: root.py Progetto: ceph/pulpito
    def index(self, latest=False, branch='', machine_type='', status='',
              suite='', date='', to_date='', page='1'):
        filters = get_run_filters(
            latest=latest, branch=branch, machine_type=machine_type,
            status=status, suite=suite, date=date, to_date=to_date,
        )
        request.context['filters'] = filters
        urlencode_args = dict()

        uri = urlparse.urljoin(base_url, '/runs/')
        if branch:
            uri += 'branch/%s/' % branch
        if machine_type:
            uri += 'machine_type/%s/' % machine_type
        if status:
            uri += 'status/%s/' % status
        if suite:
            uri += 'suite/%s/' % suite
        if to_date and date:
            uri += 'date/from/{from_}/to/{to}/'.format(from_=date, to=to_date)
        elif date:
            uri += 'date/%s/' % date
        if status == 'running':
            urlencode_args['count'] = 9999
        if page > 1:
            urlencode_args['page'] = page
        if urlencode_args:
            uri += '?%s' % urllib.urlencode(urlencode_args)

        latest_runs = requests.get(uri).json()
        for run in latest_runs:
            prettify_run(run)
        latest_runs.sort(key=run_sorter, reverse=True)
        return dict(runs=latest_runs,
                    filters=request.context.get('filters', dict()),
                    branch=branch,
                    machine_type=machine_type,
                    suite=suite,
                    dates=[date, to_date],
                    page=page,
                    )