forked from foobnix/foobnix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
foobnix.py
executable file
·97 lines (82 loc) · 2.8 KB
/
foobnix.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
90
91
92
93
94
95
96
97
#!/usr/bin/env python3
import gi
import os
import sys
import time
import logging
import traceback
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GLib
from threading import Timer
from foobnix.fc.fc import FC
from foobnix.util import LOG, analytics
from foobnix.fc.fc_helper import CONFIG_DIR
def except_hook(exc_t, exc_v, traceback):
logging.error("*** Uncaught exception ***")
logging.error(exc_t)
logging.error(exc_v)
logging.error(traceback)
#sys.excepthook = except_hook
def foobnix():
if "--debug" in sys.argv:
LOG.with_print = True
for param in sys.argv:
if param.startswith("--log"):
if "=" in param:
filepath = param[param.index("=")+1 : ]
if filepath.startswith('~'):
filepath = os.path.expanduser("~") + filepath[1 : ]
else:
filepath = os.path.join(CONFIG_DIR, "foobnix.log")
LOG.setup("debug", filename=filepath)
else:
LOG.setup("debug")
LOG.print_platform_info()
else:
LOG.setup("error")
from foobnix.gui.foobnix_core import FoobnixCore
if "--test" in sys.argv:
from test.all import run_all_tests
print("""TEST MODE""")
result = run_all_tests(ignore="test_core")
if not result:
raise SystemExit("Test failures are listed above.")
exit()
init_time = time.time()
if "--nt" in sys.argv or os.name == 'nt':
core = FoobnixCore(False)
core.run()
analytics.begin_session()
print("******Foobnix run in", time.time() - init_time, " seconds******")
Gtk.main()
else:
init_time = time.time()
from foobnix.gui.controls.dbus_manager import foobnix_dbus_interface
iface = foobnix_dbus_interface()
if "--debug" in sys.argv or not iface:
print("start program")
core = FoobnixCore(True)
core.run()
analytics.begin_session()
#core.dbus.parse_arguments(sys.argv)
analytics.begin_session()
print("******Foobnix run in", time.time() - init_time, " seconds******")
if sys.argv:
Timer(1, GLib.idle_add, [core.check_for_media, sys.argv]).start()
Gtk.main()
else:
print(iface.parse_arguments(sys.argv))
if "--profile" in sys.argv:
import cProfile
cProfile.run('foobnix()')
else:
try:
foobnix()
analytics.end_session()
except Exception as e:
analytics.end_session()
analytics.error("Main Exception"+str(e))
exc_type, exc_value, exc_traceback = sys.exc_info()
traceback.print_exception(exc_type, exc_value, exc_traceback, file=sys.stdout)
FC().save()