-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrontside.py
More file actions
executable file
·60 lines (49 loc) · 1.62 KB
/
frontside.py
File metadata and controls
executable file
·60 lines (49 loc) · 1.62 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import logging
from frontside import OptionsParser
from frontside import ConfigParser
from frontside import Frontside
from frontside import GlobalObjects
__description__ = 'Frontside. M.A.M.E. Front end using pyGame. Good for frame buffers.'
__author__ = 'Chris Read'
__version__ = '0.0.1'
__date__ = '2016/01/17'
"""
FRONTSIDE
=========
MAME frontend using Python and PyGame. Frame buffer friendly.
"""
EXIT_OK = 0
EXIT_OTHER_ERROR = 1
EXIT_PARAM_ERROR = 2
def main():
"""
Deal with startup config, merge file config and priority command line options. Respect the command line.
:return: Provide the proper exit code
"""
options = OptionsParser.parse(__description__, __version__)
if options['log_level'] not in OptionsParser.LOG_LEVELS:
print('Not a valid log level')
return EXIT_PARAM_ERROR
config, results = ConfigParser.parse(options['config_file'])
if type(results) is dict:
ConfigParser.display_errors(config, results)
return EXIT_PARAM_ERROR
for key in options:
if key != 'config_file':
config['frontside'][key] = options[key]
# Merge options and config
logging.basicConfig(
filename=config['frontside']['log_file'],
level=OptionsParser.LOG_LEVELS[config['frontside']['log_level']]
)
logging.info('Entering frontside')
application = Frontside(config)
application.start()
if GlobalObjects.scanner is not None and GlobalObjects.scanner.get_status():
GlobalObjects.scanner.halt()
return EXIT_OK
if __name__ == '__main__':
sys.exit(main())