This repository has been archived by the owner on Dec 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpiavswictrl.py
executable file
·83 lines (59 loc) · 1.75 KB
/
piavswictrl.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/python3
import sys
import logging
import dbus
from state import State
__version__ = "0.7.0"
def _do_install() -> None:
"""Installs any necessary dependencies."""
import installer
installer.install()
def _do_setup() -> None:
"""Performs any necessary setup tasks."""
import setup
setup.perform()
def _run_app() -> None:
"""Runs the application."""
import app
app.main()
def _may_shut_down() -> None:
"""Will shutdown the system if the user requested."""
import app
if State.current.shutting_down:
app.shutdown()
def _main() -> int:
"""The main entry point for the application."""
with State():
logging.info("Starting A/V Switch Controller {}".format(__version__))
logging.info("Last version `{0}` using configuration from `{1}`".format(
State.current.last_setup_version, State.current.config_file_path))
# Perform any installation tasks that might be required.
try:
_do_install()
except dbus.exceptions.DBusException as e:
logging.error("Failed to install dependencies")
logging.exception(e)
return 1
except Exception as e:
logging.error("Failed to install dependencies")
logging.exception(e)
return 1
try:
_do_setup()
except Exception as e:
logging.exception(e)
return 1
try:
_run_app()
except Exception as e:
logging.exception(e)
return 1
logging.info('Clean exit')
try:
_may_shut_down()
except Exception as e:
logging.exception(e)
return 1
return 0
if __name__ == "__main__":
sys.exit(_main())