-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
81 lines (62 loc) · 2.39 KB
/
main.py
File metadata and controls
81 lines (62 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/python
# SPDX-FileCopyrightText: 2023 Karl Bauer (BAUER GROUP)
# SPDX-License-Identifier: MIT
#######################################################################################################################
#
# Description : Toni der Topf
# Author : Karl Bauer (karl.bauer@bauer-group.com) / www.bauer-group.com
#
#######################################################################################################################
# Version
from version import __version__
# System Imports
import sys
import os
import signal
import time
import logging
# Local Imports
from Application.configuration import Configuration
from Application.app import Application
#######################################################################################################################
class AppMain:
def __init__(self):
self.is_running = False
self._initialize()
def _initialize(self):
self.Configuration = Configuration()
self.Application = Application(config=self.Configuration)
signal.signal(signal.SIGTERM, self._stop_signal)
def _stop_signal(self, signal_received, frame):
print('SIGTERM Signal! => Shutting Down...')
self.is_running = False
def run(self):
print("--- Application Start ---", end=os.linesep)
print(f"Application Version: {__version__}")
self.Configuration.show_configuration()
print("Cancel with CTRL+C", end=os.linesep)
# Start Application
self.Application.start_application()
self.is_running = True
# Sleep Main Thread
try:
while self.is_running:
#sys.stdout.write('.')
#sys.stdout.flush()
time.sleep(1)
except KeyboardInterrupt:
print("Shutting Down (CTRL+C) ...")
self.is_running = False
# Stop Application
self.Application.stop_application()
print(f"", end=os.linesep)
print("--- Application Stop ---", end=os.linesep)
#######################################################################################################################
### Main Programm Code ###
if __name__ == "__main__":
try:
app = AppMain()
app.run()
except KeyboardInterrupt:
pass
#######################################################################################################################