Completed
Push — master ( 72b331...d4b7d2 )
by Steffen
02:14
created

kuon.watcher.settings   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

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