This repository has been archived by the owner on Sep 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlauncher.py
67 lines (46 loc) · 1.6 KB
/
launcher.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
#coding=utf-8
import sys
import os
import appuifw
MAIN_ON_PC = False
MAIN_ON_PYCON = False
MAIN_ON_SIS = True
if MAIN_ON_PYCON:
os.chdir("e:\\python")
sys.path.insert(0, os.path.join(os.getcwd(), 'lib.zip'))
sys.path.insert(0, os.getcwd())
sys.path.insert(0, "c:\\sys\\bin")
sys.path.insert(0, "e:\\sys\\bin")
#my_console = series60_console.Console()
#saved_exit_key_handler = appuifw.app.exit_key_handler
def restore_defaults():
appuifw.app.body = my_console.text
sys.stderr = sys.stdout = my_console
appuifw.app.screen = 'large'
appuifw.app.menu = []
# restore_defaults()
def display_traceback():
import traceback
sys.stderr.write(traceback.format_exc() + '\n')
import progressnotes
globalProg = progressnotes.ProgressNote()
globalProg.wait()
globalProg.update(0, "正在加载…".decode("utf-8"))
def globalProgUpdate(sth):
globalProg.update(0, sth.decode("utf-8"))
default_namespace = {'__builtins__': __builtins__, '__name__': '__main__', 'SYS_STDERR': sys.stderr, 'MAIN_ON_PC' : MAIN_ON_PC,
'MAIN_ON_PYCON': MAIN_ON_PYCON, 'MAIN_ON_SIS': MAIN_ON_SIS, 'globalProg' : globalProg, 'globalProgUpdate' : globalProgUpdate }
globalProgUpdate("设置错误输出")
from util import getNewStdErrForLauncher
sys.stderr = getNewStdErrForLauncher(sys.stderr)
try:
globalProgUpdate("启动主程序")
execfile('default.py', default_namespace)
except Exception, e:
globalProgUpdate("出现错误!")
globalProg.finish()
display_traceback()
finally:
globalProg.finish()
sys.stderr = sys.stderr.originalStderr
default_namespace.clear()