-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
69 lines (51 loc) · 1.66 KB
/
main.py
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
import os
import threading as th
from logging import getLogger
from logging.config import fileConfig
from sami.ui import MainApp
from sami.threads.events import GlobalStopEvent
from sami.config import settings
from sami.threads import JobsThread, RequestHandlingThread, RequestSenderThread
# Load logging config
fileConfig(
settings.logging_conf_file, defaults={"log_file_name": str(settings.log_file)}
)
logger = getLogger()
def main():
global_app_stop_event: th.Event = GlobalStopEvent()
logger.info("Launching")
# The main thread will be the UI's
controller = MainApp()
# controller = sami.Controller()
# Define background threads
request_handling_thread = RequestHandlingThread(global_app_stop_event)
sender_thread = RequestSenderThread(global_app_stop_event)
jobs_thread = JobsThread(global_app_stop_event)
# Start threads
request_handling_thread.start()
sender_thread.start()
jobs_thread.start()
# Turns the server up on the user interface.
# controller.main_frame.set_server_display(True)
# Run the UI, holding the application open
# controller.app.MainLoop()
controller.run()
# Stops all threads
global_app_stop_event.set()
request_handling_thread.stop()
sender_thread.stop()
jobs_thread.stop()
# Wait for all threads to finish
jobs_thread.join()
sender_thread.join()
request_handling_thread.join()
def update():
# Updates the client using Git.
try:
import git
g = git.cmd.Git(os.getcwd())
g.pull()
except ImportError:
logger.warning("Could not check for software updates.")
if __name__ == "__main__":
main()