Passed
Push — master ( 227024...1d0698 )
by Oleksandr
02:44
created

tabpy.tabpy_server.handlers.status_handler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 26
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A StatusHandler.get() 0 21 3
A StatusHandler.initialize() 0 2 1
1
import json
2
import logging
3
from tabpy.tabpy_server.handlers import BaseHandler
4
5
6
class StatusHandler(BaseHandler):
7
    def initialize(self, app):
8
        super(StatusHandler, self).initialize(app)
9
10
    def get(self):
11
        if self.should_fail_with_not_authorized():
12
            self.fail_with_not_authorized()
13
            return
14
15
        self._add_CORS_header()
16
17
        status_dict = {}
18
        for k, v in self.python_service.ps.query_objects.items():
19
            status_dict[k] = {
20
                'version': v['version'],
21
                'type': v['type'],
22
                'status': v['status'],
23
                'last_error': v['last_error']}
24
25
        self.logger.log(
26
            logging.DEBUG,
27
            f'Found models: {status_dict}')
28
        self.write(json.dumps(status_dict))
29
        self.finish()
30
        return
31