Example #1
0
 def get(self):
     # Actually render the page: HTML content
     self.response.headers['Content-Type'] = 'text/html'
     template_vars = self.base_template_vars()
     template_vars['myrialKeywords'] = get_keywords()
     template_vars['subset'] = 'perfenforce'
     # .. load and render the template
     template = JINJA_ENVIRONMENT.get_template('perfenforce.html')
     self.response.out.write(template.render(template_vars))
Example #2
0
 def get(self):
     # Actually render the page: HTML content
     self.response.headers['Content-Type'] = 'text/html'
     template_vars = self.base_template_vars()
     template_vars['myrialKeywords'] = get_keywords()
     template_vars['subset'] = 'perfenforce'
     # .. load and render the template
     template = JINJA_ENVIRONMENT.get_template('perfenforce.html')
     self.response.out.write(template.render(template_vars))
Example #3
0
    def get(self):
        conn = self.app.connection
        args = {a: self.request.get(a) for a in self.request.arguments()}

        try:
            result = conn.queries(limit=args.get("limit", QUERIES_PER_PAGE),
                                  min_id=args.get("min"),
                                  max_id=args.get("max"),
                                  q=args.get("q"))
        except myria.MyriaError:
            result = {'max': 0, 'min': 0, 'results': []}

        query_string = ''
        if 'q' in args:
            query_string = args['q'].strip()
            if not query_string:
                del args['q']
            else:
                args['q'] = query_string

        queries = result['results']

        for q in queries:
            q['elapsedStr'] = nano_to_str(q['elapsedNanos'])
            bootstrap_status = {
                'ERROR': 'danger',
                'KILLED': 'danger',
                'SUCCESS': 'success',
                'RUNNING': 'warning',
            }
            q['bootstrapStatus'] = bootstrap_status.get(q['status'], '')

        template_vars = self.base_template_vars()
        template_vars.update({'queries': queries})
        template_vars['myrialKeywords'] = get_keywords()
        template_vars['pagination'] = Pagination(args, result)
        template_vars['page_url'] = lambda largs: '{}?{}'.format(
            self.request.path, urllib.urlencode(largs))
        template_vars['query_string'] = query_string

        # Actually render the page: HTML content
        self.response.headers['Content-Type'] = 'text/html'
        # .. load and render the template
        template = JINJA_ENVIRONMENT.get_template('queries.html')
        self.response.out.write(template.render(template_vars))
    def get(self):
        conn = self.app.connection
        args = {a: self.request.get(a) for a in self.request.arguments()}

        try:
            result = conn.queries(limit=args.get("limit", QUERIES_PER_PAGE),
                                  min_id=args.get("min"),
                                  max_id=args.get("max"),
                                  q=args.get("q"))
        except myria.MyriaError:
            result = {'max': 0, 'min': 0, 'results': []}

        query_string = ''
        if 'q' in args:
            query_string = args['q'].strip()
            if not query_string:
                del args['q']
            else:
                args['q'] = query_string

        queries = result['results']

        for q in queries:
            q['elapsedStr'] = nano_to_str(q['elapsedNanos'])
            bootstrap_status = {
                'ERROR': 'danger',
                'KILLED': 'danger',
                'SUCCESS': 'success',
                'RUNNING': 'warning',
            }
            q['bootstrapStatus'] = bootstrap_status.get(q['status'], '')

        template_vars = self.base_template_vars()
        template_vars.update({'queries': queries})
        template_vars['myrialKeywords'] = get_keywords()
        template_vars['pagination'] = Pagination(args, result)
        template_vars['page_url'] = lambda largs: '{}?{}'.format(
            self.request.path, urllib.urlencode(largs))
        template_vars['query_string'] = query_string

        # Actually render the page: HTML content
        self.response.headers['Content-Type'] = 'text/html'
        # .. load and render the template
        template = JINJA_ENVIRONMENT.get_template('queries.html')
        self.response.out.write(template.render(template_vars))
Example #5
0
    def get(self):
        conn = self.app.connection
        try:
            limit = int(self.request.get('limit', QUERIES_PER_PAGE))
        except (ValueError, TypeError):
            limit = 1

        try:
            max_ = int(self.request.get('max', None))
        except (ValueError, TypeError):
            max_ = None
        try:
            count, queries = conn.queries(limit, max_)
        except myria.MyriaError:
            queries = []
            count = 0

        if max_ is None:
            max_ = count

        for q in queries:
            q['elapsedStr'] = nano_to_str(q['elapsedNanos'])
            if q['status'] in ['ERROR', 'KILLED']:
                q['bootstrapStatus'] = 'danger'
            elif q['status'] == 'SUCCESS':
                q['bootstrapStatus'] = 'success'
            elif q['status'] == 'RUNNING':
                q['bootstrapStatus'] = 'warning'
            else:
                q['bootstrapStatus'] = ''

        template_vars = self.base_template_vars()
        template_vars.update({'queries': queries,
                              'prevUrl': None,
                              'nextUrl': None})
        template_vars['myrialKeywords'] = get_keywords()

        if queries:
            page = int(math.ceil(count - max_) / limit) + 1
            args = {arg: self.request.get(arg)
                    for arg in self.request.arguments()
                    if arg != 'page'}

            def page_url(page, current_max, pagination):
                largs = copy.copy(args)
                if page > 0:
                    largs['max'] = (current_max +
                                    (pagination.page - page) * limit)
                else:
                    largs.pop("max", None)
                return '{}?{}'.format(
                    self.request.path, urllib.urlencode(largs))

            template_vars['pagination'] = Pagination(
                page, limit, count)
            template_vars['current_max'] = max_
            template_vars['page_url'] = page_url
        else:
            template_vars['current_max'] = 0
            template_vars['pagination'] = Pagination(
                1, limit, 0)
            template_vars['page_url'] = lambda *args: self.request.path

        # Actually render the page: HTML content
        self.response.headers['Content-Type'] = 'text/html'
        # .. load and render the template
        template = JINJA_ENVIRONMENT.get_template('queries.html')
        self.response.out.write(template.render(template_vars))