-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorbit.py
More file actions
60 lines (50 loc) · 1.71 KB
/
orbit.py
File metadata and controls
60 lines (50 loc) · 1.71 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
import time
from lib.api import LastFM, Params
from lib.user_config import ConfigFile, Arguments
from lib.display.display_manager import DisplayManager
from lib.display.view import Interface
import getopt, sys
if __name__ == "__main__":
# basic command line handling
args = sys.argv[1:]
options = "ho"
long_options = ["help", "once"]
argument = Arguments()
try:
arguments, values = getopt.getopt(args, options, long_options)
for currentArg, currentVal in arguments:
if currentArg in ("-h", "--help"):
print("TODO: do help part")
elif currentArg in ("-o", "--once"):
argument.once = True
except getopt.error as err:
print(str(err))
configFile = ConfigFile("config.toml")
match configFile.source:
case "LASTFM":
source = LastFM(
Params(configFile),
)
case _:
raise RuntimeError(
f"Source '{configFile.source}' found in config file does not match any of the possible values ('LASTFM')")
displayManager = DisplayManager(
source,
configFile
)
for output in configFile.outputs:
match output:
case "terminal":
displayManager.displays.append(Interface(
source,
configFile
))
case _:
raise RuntimeError(
f"Output '{output}' found in config file does not match any of the possible values ('terminal', 'LED')")
if argument.once:
displayManager.display()
else:
while True:
displayManager.display()
time.sleep(configFile.refresh_interval)