summaryrefslogtreecommitdiffstats
path: root/Mac/Contrib/mpwsystem/mpwsystem.py
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2003-11-19 14:34:18 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2003-11-19 14:34:18 (GMT)
commit28ecf70db57828db2ca279643bf9aeca7662f35c (patch)
tree09b7767bbc411f85313b58d6fe7e5e67d9392973 /Mac/Contrib/mpwsystem/mpwsystem.py
parent6045b9c93511c767f6cfa2d2fa299c76181acd9b (diff)
downloadcpython-28ecf70db57828db2ca279643bf9aeca7662f35c.zip
cpython-28ecf70db57828db2ca279643bf9aeca7662f35c.tar.gz
cpython-28ecf70db57828db2ca279643bf9aeca7662f35c.tar.bz2
Getting rid of support for MacOS9 and earlier. This is the first step,
and the biggest in size, but probably the easiest. Hunting through the source code comes next.
Diffstat (limited to 'Mac/Contrib/mpwsystem/mpwsystem.py')
-rw-r--r--Mac/Contrib/mpwsystem/mpwsystem.py67
1 files changed, 0 insertions, 67 deletions
diff --git a/Mac/Contrib/mpwsystem/mpwsystem.py b/Mac/Contrib/mpwsystem/mpwsystem.py
deleted file mode 100644
index 34646c4..0000000
--- a/Mac/Contrib/mpwsystem/mpwsystem.py
+++ /dev/null
@@ -1,67 +0,0 @@
-
-"""mpwsystem -
-A simple example of how to use Apple Events to implement a "system()"
-call that invokes ToolServer on the command.
-
-Contributed by Daniel Brotsky <dev@brotsky.com>.
-
-(renamed from aesystem to mpwsystem by Jack)
-
-system(cmd, infile = None, outfile = None, errfile = None)
-
-1. Every call to system sets "lastStatus" and "lastOutput" to the
-status and output
-produced by the command when executed in ToolServer. (lastParameters
-and lastAttributes
-are set to the values of the AppleEvent result.)
-
-2. system returns lastStatus unless the command result indicates a MacOS error,
-in which case os.Error is raised with the errnum as associated value.
-
-3. You can specify ToolServer-understandable pathnames for
-redirection of input,
-output, and error streams. By default, input is Dev:Null, output is captured
-and returned to the caller, diagnostics are captured and returned to
-the caller.
-(There's a 64K limit to how much can be captured and returned this way.)"""
-
-import os
-import aetools
-
-try: server
-except NameError: server = aetools.TalkTo("MPSX", 1)
-
-lastStatus = None
-lastOutput = None
-lastErrorOutput = None
-lastScript = None
-lastEvent = None
-lastReply = None
-lastParameters = None
-lastAttributes = None
-
-def system(cmd, infile = None, outfile = None, errfile = None):
- global lastStatus, lastOutput, lastErrorOutput
- global lastScript, lastEvent, lastReply, lastParameters, lastAttributes
- cmdline = cmd
- if infile: cmdline += " <" + infile
- if outfile: cmdline += " >" + outfile
- if errfile: cmdline += " " + str(chr(179)) + errfile
- lastScript = "set Exit 0\r" + cmdline + "\rexit {Status}"
- lastEvent = server.newevent("misc", "dosc", {"----" : lastScript})
- (lastReply, lastParameters, lastAttributes) = server.sendevent(lastEvent)
- if lastParameters.has_key('stat'): lastStatus = lastParameters['stat']
- else: lastStatus = None
- if lastParameters.has_key('----'): lastOutput = lastParameters['----']
- else: lastOutput = None
- if lastParameters.has_key('diag'): lastErrorOutput = lastParameters['diag']
- else: lastErrorOutput = None
- if lastParameters['errn'] != 0:
- raise os.Error, lastParameters['errn']
- return lastStatus
-
-if __name__ == '__main__':
- sts = system('alert "Hello World"')
- print 'system returned', sts
-
-