summaryrefslogtreecommitdiffstats
path: root/Mac/Tools/CGI/BuildCGIApplet.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/Tools/CGI/BuildCGIApplet.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/Tools/CGI/BuildCGIApplet.py')
-rw-r--r--Mac/Tools/CGI/BuildCGIApplet.py76
1 files changed, 0 insertions, 76 deletions
diff --git a/Mac/Tools/CGI/BuildCGIApplet.py b/Mac/Tools/CGI/BuildCGIApplet.py
deleted file mode 100644
index 0ee2ce0..0000000
--- a/Mac/Tools/CGI/BuildCGIApplet.py
+++ /dev/null
@@ -1,76 +0,0 @@
-"""BuildCGIApplet.py -- Create a CGI applet from a Python script.
-
-Specilized version of BuildApplet, enabling Python CGI scripts to be
-used under Mac web servers like WebStar. The __main__ program is
-PythonCGISlave.py, which provides a compatibility layer, emulating
-Unix-style CGI scripts. See CGI_README.txt for details.
-"""
-
-import sys
-import os
-import macfs
-import MacOS
-from Carbon import Res
-import EasyDialogs
-import buildtools
-import py_resource
-
-
-def main():
- try:
- buildcgiapplet()
- except buildtools.BuildError, detail:
- EasyDialogs.Message(detail)
-
-
-def buildcgiapplet():
- buildtools.DEBUG=1
-
- # Find the template
- # (there's no point in proceeding if we can't find it)
-
- template = buildtools.findtemplate()
- wrapper = "PythonCGISlave.py"
- if not os.path.exists("PythonCGISlave.py"):
- wrapper = os.path.join(sys.exec_prefix, ":Mac:Tools:CGI", wrapper)
-
- # Ask for source text if not specified in sys.argv[1:]
- if not sys.argv[1:]:
- srcfss, ok = macfs.PromptGetFile('Select a CGI script:', 'TEXT', 'APPL')
- if not ok:
- return
- filename = srcfss.as_pathname()
- dstfilename = mkcgifilename(filename)
- dstfss, ok = macfs.StandardPutFile('Save application as:',
- os.path.basename(dstfilename))
- if not ok:
- return
- dstfilename = dstfss.as_pathname()
- buildone(template, wrapper, filename, dstfilename)
- else:
- # Loop over all files to be processed
- for filename in sys.argv[1:]:
- dstfilename = mkcgifilename(filename)
- buildone(template, wrapper, filename, dstfilename)
-
-
-def mkcgifilename(filename):
- if filename[-3:] == '.py':
- filename = filename[:-3]
- filename = filename + ".cgi"
- return filename
-
-
-def buildone(template, wrapper, src, dst):
- buildtools.process(template, wrapper, dst, 1)
- # write source as a PYC resource into dst
- ref = Res.FSpOpenResFile(dst, 2)
- try:
- Res.UseResFile(ref)
- py_resource.frompyfile(src, "CGI_MAIN", preload=1)
- finally:
- Res.CloseResFile(ref)
-
-
-if __name__ == '__main__':
- main()