From d05107eb18164141674e68541ad981f9bc706348 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Wed, 20 Jul 2005 10:02:57 +0000 Subject: [PATCH] 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. --- debian/changelog | 3 +++ popcon-submit-ubuntu.cgi | 28 ++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index fa25126..fe89f53 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,9 @@ popularity-contest (1.31) UNRELEASED; urgency=low (uncompressed) format. - Add support in popcon-submit.cgi to save directly to disk instead of sending emails. + - 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. * Translations - Updated Japanese from Kenshi Muto. (Closes: #317402) - Updated Russian from Yuri Kozlov. (Closes: #317449) diff --git a/popcon-submit-ubuntu.cgi b/popcon-submit-ubuntu.cgi index 7f8e7af..2ca399a 100755 --- a/popcon-submit-ubuntu.cgi +++ b/popcon-submit-ubuntu.cgi @@ -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 @@ def mkdirs(newdir,mode=0777): 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 @@ if fileitem.file: 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"