-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
89 lines (66 loc) · 3.07 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
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
84
85
86
87
88
89
#!/usr/bin/python3
# -*- coding: latin-1 -*-
"""
Copyright (C) 2014 Technische Universität Berlin,
Fakultät IV - Elektrotechnik und Informatik,
Fachgebiet Regelungssysteme,
Einsteinufer 17, D-10587 Berlin, Germany
This file is part of PaPI.
PaPI is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PaPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PaPI. If not, see <http://www.gnu.org/licenses/>.
Contributors
Sven Knuth
"""
from papi.core import Core
from papi.gui.default.GUI import GUI, run_gui_in_own_process
import papi.constants as pc
import platform
import sys
import os
import argparse
parser = argparse.ArgumentParser(epilog="Documentation can be found here: http://tub-control.github.io/PaPI/dev/")
parser.add_argument("-c", "--config", dest = "config", default = "", help="Configuration file loaded after startup.")
parser.add_argument("-u", "--user_config", dest = "user_config", default='0', help="Loads a user specific configuration")
parser.add_argument("-v", "--version", dest = "version", action="store_true", default=False, help="Prints current PaPI version.")
parser.add_argument("-d", "--debug_level", dest = "debug_level", default='0', help="Sets debug level.")
parser.add_argument("-f", "--full_screen", dest = "full_screen", action='store_true', default=False, help="Use full screen.")
parser.add_argument("-r", "--run_mode", dest = "run_mode", action='store_true', default=False, help="Start PaPI in run_mode.")
args = parser.parse_args()
def start_PaPI(args=None):
print('Plattform of the system running PaPI: ' + platform.system())
if args is not None:
if args.version:
print("Current PaPI version: " + pc.CORE_PAPI_VERSION)
return
# start on PaPI on system running Linux
if platform.system() == 'Linux':
path = os.path.dirname(pc.PAPI_USER_CFG)
if not os.path.exists(path):
os.mkdir(path)
core = Core(run_gui_in_own_process, is_parent=True, use_gui=True, args=args)
core.run()
return
# start on PaPI on system running Windows
if platform.system() == 'Windows':
print('Windows port is NOT ready')
raise Exception('Windows is not supported yet')
return
# start on PaPI on system running Mac OS X
if platform.system() == 'Darwin':
path = os.path.dirname(pc.PAPI_USER_CFG)
if not os.path.exists(path):
os.mkdir(path)
core = Core(run_gui_in_own_process, is_parent=True, use_gui=True, args=args)
core.run()
return
raise Exception('Seems like the os you are using is not supported by PaPI')
if __name__ == '__main__':
sys.exit(start_PaPI(args=args))