python: Initial porting of the Python code to Python 3.
[ashd.git] / python / scgi-wsgi
index 4258566..9befb25 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import sys, os, getopt
 import socket
@@ -20,7 +20,7 @@ for o, a in opts:
         sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         p = a.rfind(":")
         if p < 0:
-            bindhost = "hostname"
+            bindhost = "localhost"
             bindport = int(a)
         else:
             bindhost = a[:p]
@@ -41,14 +41,14 @@ if sk is None:
 
 try:
     handlermod = __import__(args[0], fromlist = ["dummy"])
-except ImportError, exc:
-    sys.stderr.write("scgi-wsgi: handler %s not found: %s\n" % (args[0], exc.message))
+except ImportError as exc:
+    sys.stderr.write("scgi-wsgi: handler %s not found: %s\n" % (args[0], exc.args[0]))
     sys.exit(1)
 if not modwsgi_compat:
     if not hasattr(handlermod, "wmain"):
         sys.stderr.write("scgi-wsgi: handler %s has no `wmain' function\n" % args[0])
         sys.exit(1)
-    handler = handlermod.wmain(args[1:])
+    handler = handlermod.wmain(*args[1:])
 else:
     if not hasattr(handlermod, "application"):
         sys.stderr.write("scgi-wsgi: handler %s has no `application' object\n" % args[0])