StatusHandler.initialize()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.125

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 2
ccs 1
cts 2
cp 0.5
rs 10
c 0
b 0
f 0
cc 1
nop 2
crap 1.125
1 1
import json
2 1
import logging
3 1
from tabpy.tabpy_server.handlers import BaseHandler
4 1
from tabpy.tabpy_server.handlers.util import AuthErrorStates
5
6 1
class StatusHandler(BaseHandler):
7 1
    def initialize(self, app):
8
        super(StatusHandler, self).initialize(app)
9
10 1
    def get(self):
11
        if self.should_fail_with_auth_error() != AuthErrorStates.NONE:
12
            self.fail_with_auth_error()
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
26
        self.logger.log(logging.DEBUG, f"Found models: {status_dict}")
27
        self.write(json.dumps(status_dict))
28
        self.finish()
29
        return
30