| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
from warnings import warnpy3k |
| 9 |
warnpy3k("In 3.x, the appletrawmain module is removed.", stacklevel=2) |
| 10 |
|
| 11 |
import argvemulator |
| 12 |
import os |
| 13 |
import sys |
| 14 |
import marshal |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
if not sys.argv or sys.argv[0][:1] == '-': |
| 21 |
|
| 22 |
_dir = os.path.split(sys.executable)[0] |
| 23 |
_dir = os.path.split(_dir)[0] |
| 24 |
_dir = os.path.join(_dir, 'Resources') |
| 25 |
sys.argv.insert(0, '__rawmain__') |
| 26 |
else: |
| 27 |
_dir = os.path.split(sys.argv[0])[0] |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
sys.path.insert(0, _dir) |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
argvemulator.ArgvCollector().mainloop() |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
__file__ = os.path.join(_dir, '__main__.py') |
| 42 |
if os.path.exists(__file__): |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
sys.argv[0] = __file__ |
| 47 |
del argvemulator, os, sys, _dir |
| 48 |
execfile(__file__) |
| 49 |
else: |
| 50 |
__file__ = os.path.join(_dir, '__main__.pyc') |
| 51 |
if os.path.exists(__file__): |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
sys.argv[0] = __file__ |
| 56 |
_fp = open(__file__, 'rb') |
| 57 |
_fp.read(8) |
| 58 |
__code__ = marshal.load(_fp) |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
del argvemulator, os, sys, marshal, _dir, _fp |
| 64 |
exec __code__ |
| 65 |
else: |
| 66 |
sys.stderr.write("%s: neither __main__.py nor __main__.pyc found\n"%sys.argv[0]) |
| 67 |
sys.exit(1) |