From 490c169716903958fdf39e8138492870dcf7a9b1 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 24 May 2012 08:58:22 -0400 Subject: Separate defaults from field keys. --- www/gps_report.cgi.in | 68 ++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 36 deletions(-) (limited to 'www/gps_report.cgi.in') diff --git a/www/gps_report.cgi.in b/www/gps_report.cgi.in index 8aa3a44e..f7be7f69 100644 --- a/www/gps_report.cgi.in +++ b/www/gps_report.cgi.in @@ -12,7 +12,7 @@ import cgitb; cgitb.enable() # for troubleshooting # All information on the project siting, mailing # lists, and originating host lives here. website = '@WEBSITE@' -to_address = '@DEVMAIL@' +to_address = "esr@thyrsus.com" #'@DEVMAIL@' servaddr = '@FORMSERVER@' # Get form value, send mail on submission @@ -25,49 +25,52 @@ print "" def hasNeededElements(form): return True -defaults = {"submitter":"", - "vendor": "", - "model": "", - "techdoc": "", - "packaging": "mouse", - "chipset": "", - "firmware": "", - "nmea": "", - "interfaces": "USB", - "usbchip": "", - "tested": "", - "rating": "", - "noconfigure": "", - "sample": "", - "location": "", - "date": "", - "sample_notes": "", -} +formfields = ("submitter", + "vendor", + "model", + "techdoc", + "packaging", + "chipset", + "firmware", + "nmea", + "interfaces", + "usbchip", + "tested", + "rating", + "noconfigure", + "sample", + "location", + "date", + "sample_notes", + ) if hasNeededElements(form) and form.getvalue("action") == "Send Report": print cgi.print_form(form) msg = "" - for field in defaults: + for field in formfields: msg += "%s: %s\n" % (field, form.getvalue(field)) print "
"
     print msg
     print "
" msg = "This is only a test" - smtp = smtplib.SMTP(host=servaddr.split("@")[1]) + #smtp = smtplib.SMTP(host=servaddr.split("@")[1]) #smtp.set_debuglevel(1) - smtp.sendmail(servaddr, ["esr@thyrsus.com"], msg) - smtp.quit() + #smtp.sendmail(servaddr, ["esr@thyrsus.com"], msg) + #smtp.quit() print "

New device report accepted. Thanks for helping improve GPSD.\n"; sys.exit(0) # Everything below here is page generation -for key in form.keys(): +defaults = {} +for key in formfields: if key in form.keys(): - defaults[key] = form.getvalue(key) + defaults[key] = form.getvalue(key) + else: + defaults[key] = "" defaults['request_uri'] = os.getenv('REQUEST_URI') defaults["website"] = website -defaults["to_address"] = 'esr@thyrsus.com' +defaults["to_address"] = to_address defaults["servaddr"] = servaddr print ''' @@ -188,12 +191,8 @@ packagetypes = ( ('other', 'None of the above'), ) -pkgline = '%s
' for (ptype, plegend) in packagetypes: - if defaults['packaging'] == ptype: - print pkgline % (ptype, " checked", plegend) - else: - print pkgline % (ptype, "", plegend) + print '%s
' % (ptype, plegend) print ''' @@ -237,13 +236,10 @@ tell us about it in "Technical Notes".

''' % defaults -ifline = '%s
' +ifline = '%s
' for itype in ('USB', 'Serial', 'Bluetooth', 'TTL', 'Compact Flash', 'RS-232', 'Other'): - if defaults['interfaces'] == itype: - print ifline % (itype, " checked", itype) - else: - print ifline % (itype, "", itype) + print ifline % (itype, itype) print '''

If your device is USB, it probably uses a USB-to-serial adapter -- cgit v1.2.1