summaryrefslogtreecommitdiffstats
path: root/Mac/Unsupported/run.py
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2001-08-27 21:17:44 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2001-08-27 21:17:44 (GMT)
commit8f2b13efce66d1ce66060d55f26753d0e593d19f (patch)
tree0bbebe473c62673fcb94908db9674bd4743aa3f8 /Mac/Unsupported/run.py
parentcd8a127e1a0dac4a4cd4b12bdffe8a17dd75cef9 (diff)
downloadcpython-8f2b13efce66d1ce66060d55f26753d0e593d19f.zip
cpython-8f2b13efce66d1ce66060d55f26753d0e593d19f.tar.gz
cpython-8f2b13efce66d1ce66060d55f26753d0e593d19f.tar.bz2
These have long outlived there usefulness, in my opinion. Moved to Unsupported.
Diffstat (limited to 'Mac/Unsupported/run.py')
-rw-r--r--Mac/Unsupported/run.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/Mac/Unsupported/run.py b/Mac/Unsupported/run.py
new file mode 100644
index 0000000..75c6129
--- /dev/null
+++ b/Mac/Unsupported/run.py
@@ -0,0 +1,41 @@
+# Script (applet) to run any Python command
+
+def main():
+ import sys
+ sys.stdout = sys.stderr
+ del sys.argv[:1]
+ if not sys.argv:
+ import macfs
+ srcfss, ok = macfs.StandardGetFile('TEXT')
+ if not ok:
+ return
+ filename = srcfss.as_pathname()
+ sys.argv.append(filename)
+ import __main__
+ try:
+ execfile(sys.argv[0], __main__.__dict__)
+ except SystemExit, msg:
+ if msg:
+ message("Exit status: %s" % str(msg))
+ print "exit", `msg`
+ #sys.exit(msg)
+ except:
+ etype = sys.exc_type
+ if hasattr(etype, "__name__"): etype = etype.__name__
+ message("%s: %s" % (etype, sys.exc_value))
+ print "exit 1"
+ #sys.exit(1)
+
+def message(str = "Hello, world!", id = 256):
+ from Carbon import Dlg
+ d = Dlg.GetNewDialog(id, -1)
+ if not d:
+ print str
+ return
+ tp, h, rect = d.GetDItem(2)
+ Dlg.SetIText(h, str)
+ while 1:
+ n = Dlg.ModalDialog(None)
+ if n == 1: break
+
+main()