[Popcon-commits] cvs commit to popularity-contest by pere

pere at cvs.alioth.debian.org pere at cvs.alioth.debian.org
Wed Jul 20 10:02:59 UTC 2005


Update of /cvsroot/popcon/popularity-contest
In directory haydn:/tmp/cvs-serv22223

Modified Files:
	popcon-submit-ubuntu.cgi 
Log Message:
Change popcon-submit-ubuntu.cgi to make it easier to run with
older python versions, and make sure the reply matches the
"success" string used by popcon-upload.


Index: popcon-submit-ubuntu.cgi
===================================================================
RCS file: /cvsroot/popcon/popularity-contest/popcon-submit-ubuntu.cgi,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- popcon-submit-ubuntu.cgi	2 Jul 2005 17:18:05 -0000	1.1
+++ popcon-submit-ubuntu.cgi	20 Jul 2005 10:02:57 -0000	1.2
@@ -1,9 +1,20 @@
 #!/usr/bin/python
+#
+# Script to receive popcon reports using HTTP POST, and store them in
+# a directory.
+#
+# Require at least python version 2.2 to use the cgitb module.
 
 import os, sys, cgi, errno
-import cgitb; cgitb.enable()
-uploadDir = '/srv/popcon.ubuntu.com/popcon-data/'
-logDir = '/srv/popcon.ubuntu.com/logs/'
+try: # Use cgitb when available
+    import cgitb
+    cgitb.enable()
+except:
+    sys.stderr = sys.stdout
+
+basedir   = '/srv/popcon.ubuntu.com'
+uploadDir = '%s/popcon-data/' % basedir
+logDir    = '%s/logs/' % basedir
 
 def mkdirs(newdir,mode=0777):
         try: os.makedirs(newdir,mode)
@@ -11,7 +22,7 @@
                 if err.errno != errno.EEXIST or not os.path.isdir(newdir):
                         raise
 
-
+error = 0
 formStorage = cgi.FieldStorage()
 fileitem = formStorage["popcondata"]
 if fileitem.file:
@@ -31,8 +42,13 @@
         data.writelines(header)
         data.writelines(fileitem.file)
         data.close()
+else:
+	error = "Unable to find uploaded file in POST request"
 
 print """Content-Type: text/plain
-
-Thanks!
 """
+if error:
+	print error
+else:
+	print "Thanks for your submission to Debian Popularity-Contest!"
+	print "DEBIAN POPCON HTTP-POST OK\n"




More information about the Popcon-commits mailing list