[xiph-commits] r13900 - websites/validator.xspf.org
sping at svn.xiph.org
sping at svn.xiph.org
Sun Sep 23 21:58:46 PDT 2007
Author: sping
Date: 2007-09-23 21:58:45 -0700 (Sun, 23 Sep 2007)
New Revision: 13900
Modified:
websites/validator.xspf.org/check.py
Log:
Now testable from the command line
Modified: websites/validator.xspf.org/check.py
===================================================================
--- websites/validator.xspf.org/check.py 2007-09-24 04:16:28 UTC (rev 13899)
+++ websites/validator.xspf.org/check.py 2007-09-24 04:58:45 UTC (rev 13900)
@@ -33,6 +33,7 @@
# 2007-09-24 -- Sebastian Pipping <webmaster at hartwork.org>
#
# * Fixed: Another bug in whitespace handling
+# * Added: Finally made testable from the command line
#
# 2007-09-21 -- Sebastian Pipping <webmaster at hartwork.org>
#
@@ -93,7 +94,7 @@
except ImportError:
print "ERROR: Package 'Ft.Lib' is missing. On Debian testing/unstable run:\n" \
"sudo apt-get install python-4suite-xml"
- sys.exit(1)
+ sys.exit(2)
print "Content-Type: text/html" # HTML is following
print # blank line, end of headers
@@ -223,38 +224,54 @@
<!-- BORDER -->"""
+
+valid = False
intro = ""
+input = ""
-input = ""
-form = cgi.FieldStorage()
-if form.has_key("pasted") and form.has_key("submitPasted"):
- input = form.getlist("pasted")[0]
+if (len(sys.argv) == 3) and (sys.argv[1] == "--shell"):
+ try:
+ f = open(sys.argv[2])
+ try:
+ input = f.read()
+ finally:
+ f.close()
+ except IOError:
+ pass
+
if input != "":
intro = "Validating pasted text<br><br>"
+
+else:
+ form = cgi.FieldStorage()
+ if form.has_key("pasted") and form.has_key("submitPasted"):
+ input = form.getlist("pasted")[0]
+ if input != "":
+ intro = "Validating pasted text<br><br>"
-elif form.has_key("uploaded") and form.has_key("submitUploaded"):
- uploaded = form["uploaded"]
- if uploaded.file:
- input = uploaded.file.read()
+ elif form.has_key("uploaded") and form.has_key("submitUploaded"):
+ uploaded = form["uploaded"]
+ if uploaded.file:
+ input = uploaded.file.read()
- if input != "":
- intro = "Validating uploaded file<br><b><i>" + uploaded.filename + "</i></b><br><br>"
+ if input != "":
+ intro = "Validating uploaded file<br><b><i>" + uploaded.filename + "</i></b><br><br>"
-elif form.has_key("url"): ### and form.has_key("submitUrl")
- url = form.getlist("url")[0]
+ elif form.has_key("url"): ### and form.has_key("submitUrl")
+ url = form.getlist("url")[0]
- try:
- file = urllib2.urlopen(url)
- input = file.read()
- except ValueError:
- intro = """<b style="color:red;">Invalid URL.</b><br><br>"""
+ try:
+ file = urllib2.urlopen(url)
+ input = file.read()
+ except ValueError:
+ intro = """<b style="color:red;">Invalid URL.</b><br><br>"""
- except urllib2.URLError:
- # 404, non-existent host, IPv6 (not supported), ...
- intro = """<b style="color:red">Could not download from URL.</b><br><br>"""
+ except urllib2.URLError:
+ # 404, non-existent host, IPv6 (not supported), ...
+ intro = """<b style="color:red">Could not download from URL.</b><br><br>"""
- if input != "":
- intro = "Validating data from URL<br><b><i><a href=\"" + url + "\" class=\"blackLink\">" + url + "</a></i></b><br><br>"
+ if input != "":
+ intro = "Validating data from URL<br><b><i><a href=\"" + url + "\" class=\"blackLink\">" + url + "</a></i></b><br><br>"
@@ -1207,3 +1224,11 @@
</table>
</body>
</html>"""
+
+
+
+if valid:
+ sys.exit(0)
+
+else:
+ sys.exit(1)
More information about the commits
mailing list