kuon.watcher.settings   A
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 86.67%

Importance

Changes 0
Metric Value
wmc 0
eloc 31
dl 0
loc 55
ccs 26
cts 30
cp 0.8667
rs 10
c 0
b 0
f 0
1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3 1
import os
4
5 1
import dotenv
6
7 1
dotenv_path = os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir, '.env')
8 1
dotenv.load_dotenv(dotenv_path)
9
10
11 1
class NotificationType:
12 1
    Nothing = 0
13 1
    Telegram = 1
14 1
    Mail = 2
15
16
17 1
class Settings:
18
    """Settings for Watcher"""
19
20 1
    class Notification:
21
        """Settings for Notifications"""
22
23 1
        class Telegram:
24
            """Settings for Telegram"""
25 1
            token = os.environ.get('TELEGRAM_API_KEY')
26
27 1
            if os.environ.get('TELEGRAM_USER_ID') and os.environ.get('TELEGRAM_USER_ID').isnumeric():
28
                chat_id = int(os.environ.get('TELEGRAM_USER_ID'))
29
            else:
30 1
                chat_id = 0
31
32 1
        class Mail:
33
            """Settings for Mail"""
34 1
            sender_mail = os.environ.get('MAIL_SENDER_USER')
35 1
            sender_pass = os.environ.get('MAIL_SENDER_PASS')
36 1
            recipient_mail = os.environ.get('MAIL_RECIPIENT')
37 1
            smtp_server = os.environ.get('MAIL_SMTP_SERVER')
38
39 1
            if os.environ.get('MAIL_SMTP_SERVER_PORT') and os.environ.get('MAIL_SMTP_SERVER_PORT').isnumeric():
40
                smtp_port = int(os.environ.get('MAIL_SMTP_SERVER_PORT'))
41
            else:
42 1
                smtp_port = 587
43
44 1
    LIMIT_60_SECONDS = 20
45
46 1
    if os.environ.get('CHECK_FREQUENCY') and os.environ.get('CHECK_FREQUENCY').isnumeric():
47
        check_frequency = int(os.environ.get('CHECK_FREQUENCY'))
48
    else:
49 1
        check_frequency = 20
50
51 1
    if os.environ.get('NOTIFICATION_TYPE') and os.environ.get('NOTIFICATION_TYPE').isnumeric():
52
        notification_type = int(os.environ.get('NOTIFICATION_TYPE'))
53
    else:
54
        notification_type = NotificationType.Nothing
55