-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
39 lines (33 loc) · 1.1 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
from __future__ import unicode_literals
# !/usr/bin/env python
# -*- coding: utf-8 -*-
from config import Config
from logger import Logger
from jukebox import Jukebox
import logging
import sys
config = Config()
# Initializing the logger with the correct settings
logger = Logger(log_format=config.log['format'],
path=config.log['path'],
level=config.log['level']).root_logger
def main(loaded_config):
"""
This method main.main() initializes a jukebox.Jukebox class with loaded_config
"""
# You may toggle to True when debugging to avoid restarting loops
debug = True
try:
Jukebox(loaded_config)
except Exception as e:
logger.critical("Jukebox has crashed with error %s restarting... " % e)
if not debug:
main(loaded_config)
else:
raise
if __name__ == '__main__':
# This code executes the following if and only if main.py is first started, not another file.
logging.warning("Starting...")
if len(sys.argv) >= 2 and sys.argv[1] == 'dummy':
config.lcd['type'] = 'dummy'
main(config)