comparison Mac/scripts/RunLibScript.py @ 3043:4581a0f0353e legacy-trunk

- imp seems to always want a file object arg - continue if resource file not found (may be an applet)
author Jack Jansen <jack.jansen@cwi.nl>
date Thu, 31 Aug 1995 13:46:13 +0000
parents 7eea9b426802
children fc77e34ef274
comparison
equal deleted inserted replaced
3042:6af0fbc8553a 3043:4581a0f0353e
22 PAUSE=10 22 PAUSE=10
23 23
24 def import_as_main(name): 24 def import_as_main(name):
25 fp, path, (suffix, mode, type) = imp.find_module(name) 25 fp, path, (suffix, mode, type) = imp.find_module(name)
26 if type == imp.PY_SOURCE: 26 if type == imp.PY_SOURCE:
27 imp.load_source('__main__', path) 27 imp.load_source('__main__', path, fp)
28 elif type == imp.PY_COMPILED: 28 elif type == imp.PY_COMPILED:
29 imp.load_compiled('__main__', path) 29 imp.load_compiled('__main__', path, fp)
30 elif type == imp.PY_RESOURCE: 30 elif type == imp.PY_RESOURCE:
31 imp.load_resource('__main__', path) 31 imp.load_resource('__main__', path)
32 32
33 def interact(): 33 def interact():
34 d = Dlg.GetNewDialog(DIALOG_ID, -1) 34 d = Dlg.GetNewDialog(DIALOG_ID, -1)
82 return name, argv, stdin, stdout, wdir, pause 82 return name, argv, stdin, stdout, wdir, pause
83 83
84 def main(): 84 def main():
85 curdir = os.getcwd() 85 curdir = os.getcwd()
86 import Res 86 import Res
87 Res.OpenResFile('RunLibScript.rsrc') 87 try:
88 Res.OpenResFile('RunLibScript.rsrc')
89 except:
90 pass # Assume we're an applet already
88 name, argv, stdin, stdout, wdir, pause = interact() 91 name, argv, stdin, stdout, wdir, pause = interact()
89 if not name: 92 if not name:
90 sys.exit(0) 93 sys.exit(0)
91 sys.argv = [name] + string.split(argv) 94 sys.argv = [name] + string.split(argv)
92 if stdin: 95 if stdin: