-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstartup.py
64 lines (53 loc) · 1.8 KB
/
startup.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
import pentai.db.zodb_dict as z_m
from kivy.config import Config
import os, sys
def run():
#Config.set('kivy', 'log_level', 'info')
Config.set('kivy', 'log_level', 'debug')
Config.set('kivy', 'log_enable', 1)
Config.set('kivy', 'log_dir', 'logs')
Config.set('kivy', 'log_name', 'kivy_%y-%m-%d_%_.txt')
Config.set('graphics', 'fullscreen', '0')
try:
pentai_path = os.environ['PENTAIPATH']
except KeyError:
pentai_path = None
try:
from pentai.gui.kivy_gui_main import PentAIApp
pa = PentAIApp()
if pentai_path == None:
pentai_path = pa.user_data_dir
print "User Data Dir: %s" % pa.user_data_dir
db_path = os.path.join(pentai_path, "db.fs")
print "Loading DB from %s" % db_path
lockfile_path = db_path + ".lock"
if os.path.isfile(lockfile_path):
os.unlink(lockfile_path)
print "Cleared DB lock"
z_m.set_db(db_path)
err_fn = os.path.join(pentai_path, "err.txt")
try:
print "Previous crash:"
with open(err_fn) as err_log:
print err_log.readlines()
except:
pass
pa.run()
except Exception, e:
print
print "PentAI crashed!"
import traceback
traceback.print_exc()
try:
with open(err_fn, "w") as err_log:
print "saving traceback to %s" % err_fn
traceback.print_exc(None, err_log)
except:
pass
if __name__ == '__main__':
import pstats, cProfile
cProfile.runctx("main()", globals(), locals(), "Profile.prof")
s = pstats.Stats("Profile.prof")
s.strip_dirs().sort_stats("cumulative").print_stats(20) # or "time"
#s.strip_dirs().sort_stats("time").print_stats(20)
# main()