-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·29 lines (24 loc) · 737 Bytes
/
run.py
File metadata and controls
executable file
·29 lines (24 loc) · 737 Bytes
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
import sys
import os
import pixray
import yaml
# example: python run.py cogs/hello_pixray/pixray.yaml
def main():
if len(sys.argv) < 2:
print("Usage: python run_yaml file.yaml [other settings]")
sys.exit(1)
settings_file = sys.argv.pop(1)
with open(settings_file, 'r') as stream:
try:
base_settings = yaml.safe_load(stream)
except yaml.YAMLError as exc:
print("YAML ERROR", exc)
sys.exit(1)
# This loads in default settings, but command line can override
pixray.reset_settings()
pixray.add_settings(**base_settings)
settings = pixray.apply_settings()
pixray.do_init(settings)
pixray.do_run(settings)
if __name__ == '__main__':
main()