git » pyweave » commit c69f0e1

Wrap the main code in "if __name__ == '__main__'"

author Alberto Bertogli
2009-09-29 17:45:25 UTC
committer Alberto Bertogli
2009-09-29 17:45:25 UTC
parent 630f934cd200e39484b6bec1109de6de8204500b

Wrap the main code in "if __name__ == '__main__'"

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

pyweave.cgi +9 -8

diff --git a/pyweave.cgi b/pyweave.cgi
index 060015d..1d06c71 100755
--- a/pyweave.cgi
+++ b/pyweave.cgi
@@ -520,12 +520,13 @@ def handle_cmd():
 	print "It only runs inside a web server."
 	return 1
 
-if os.environ.has_key('GATEWAY_INTERFACE'):
-	try:
-		handle_cgi()
-	except Exception, e:
-		error(500, "Unhandled exception")
-		raise
-else:
-	sys.exit(handle_cmd())
+if __name__ == '__main__':
+	if os.environ.has_key('GATEWAY_INTERFACE'):
+		try:
+			handle_cgi()
+		except Exception, e:
+			error(500, "Unhandled exception")
+			raise
+	else:
+		sys.exit(handle_cmd())