8 out.write("usage: scgi-wsgi [-hA] [-p MODPATH] [-T [HOST:]PORT] HANDLER-MODULE [ARGS...]\n")
11 modwsgi_compat = False
12 opts, args = getopt.getopt(sys.argv[1:], "+hAp:T:")
20 sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
27 bindport = int(a[p + 1:])
28 sk.bind((bindhost, bindport))
37 # This is suboptimal, since the socket on stdin is not necessarily
38 # AF_UNIX, but Python does not seem to offer any way around it,
40 sk = socket.fromfd(0, socket.AF_UNIX, socket.SOCK_STREAM)
43 handlermod = __import__(args[0], fromlist = ["dummy"])
44 except ImportError, exc:
45 sys.stderr.write("scgi-wsgi: handler %s not found: %s\n" % (args[0], exc.message))
47 if not modwsgi_compat:
48 if not hasattr(handlermod, "wmain"):
49 sys.stderr.write("scgi-wsgi: handler %s has no `wmain' function\n" % args[0])
51 handler = handlermod.wmain(*args[1:])
53 if not hasattr(handlermod, "application"):
54 sys.stderr.write("scgi-wsgi: handler %s has no `application' object\n" % args[0])
56 handler = handlermod.application
58 ashd.scgi.servescgi(sk, ashd.scgi.wrapwsgi(handler))