forked from gauravssnl/Symbian-Python-Files
/
py2sis.py
79 lines (69 loc) · 2.54 KB
/
py2sis.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
from lite_fm import *
import os
import e32
import appuifw
import uikludges
def copy(x, y):
e32.file_copy(x, y)
print ('copy ' + y + '\r\nin ' + x + '\r\n'),
print
e32.ao_yield()
def en(x):
return x.decode('utf-8')
def Exit():
x = appuifw.query(en('Are you sure?'), 'query')
if x == 1 :
os.abort()
uikludges.set_right_softkey_text(en('Exit'))
appuifw.app.screen = 'normal'
appuifw.app.title = u'py2sis'
priv = en('While processing please be patient\nIt may take 2-3 minutes..\n\n\n\n\nby Gabriel\n\n@\n\nwww.roznida.com')
appuifw.app.body = appuifw.Text()
appuifw.app.body.color = (0, 0, 0)
appuifw.app.body.set(priv)
appuifw.app.body.focus = False
def exit_key_handler():
create
def create():
apps = manager('e:/system/apps', 'dir')
if apps == None :
return 'Program not selected'
appuifw.note(en('Please Wait...'))
if len(os.path.split(apps)[1]) > 10 :
return 'name programs is long'
apps += '\\'
if not os.path.exists((apps + 'default.py')) :
return 'default.py not exists'
os.makedirs((apps + 'libs\\encodings'))
for drive in ['c:\\system\\', 'e:\\system\\']:
for dll in [('python222.dll', 'libs\\python222.dll'), ('python_appui.dll', 'libs\\python_appui.dll'), ('ui.rsc', 'data\\appuifwmodule.rsc')]:
if os.path.exists((drive + dll[1])) :
copy((apps + dll[0]), (drive + dll[1]))
for path in ['libs\\', 'libs\\encodings\\']:
try :
sp = os.listdir((drive + path))
except :
continue
for name in sp:
name = name.lower()
if os.path.splitext(name)[1] in ['.py', '.pyc', '.pyd'] :
copy((apps + path + name), (drive + path + name))
f = open((apps + 'python_appui.dll'), 'r+')
txt = f.read()
i = txt.find('\x00'.join(list('data\\appuifwmodule.rsc')))
f.seek(i)
nt = '\x00'.join(list(('apps\\' + os.path.split(apps[ : -1])[1] + '\\ui.rsc')))
nt += (((43 - len(nt)) / 2) * '\x00 ')
(f.write(nt), f.close())
f = open((apps + 'default.py'), 'r+')
txt = f.read()
f.seek(0)
apps = (apps[1 : -1]).replace('\\', '\\\\')
f.write(('import sys\r\nsys.path=["c' + apps + '","e' + apps + '","c' + apps + '\\\\libs","e' + apps + '\\\\libs"]\r\n' + txt))
appuifw.note(en('Finished'))
f.close()
return 'ok'
print create(),
print
appuifw.app.menu = [(en('py2sis'), create)]
appuifw.app.exit_key_handler = Exit