| 1 |
hertzog |
382 |
#!/usr/bin/python |
| 2 |
|
|
# vim: expandtab |
| 3 |
|
|
|
| 4 |
hertzog |
601 |
# Copyright 2002-2003 Raphaël Hertzog |
| 5 |
hertzog |
382 |
# Available under the terms of the General Public License version 2 |
| 6 |
|
|
# or (at your option) any later version. |
| 7 |
|
|
|
| 8 |
|
|
import cgi, os, sys, re, string |
| 9 |
|
|
#import cgitb; cgitb.enable() |
| 10 |
|
|
|
| 11 |
|
|
src = {} |
| 12 |
hertzog |
812 |
if os.path.isfile("../incoming/sources.map"): |
| 13 |
|
|
f = open("../incoming/sources.map") |
| 14 |
hertzog |
382 |
while 1: |
| 15 |
|
|
line = f.readline(); |
| 16 |
|
|
if not line: break #eof |
| 17 |
|
|
line = string.strip(line) |
| 18 |
|
|
(binary, source) = string.split(line, None, 1) |
| 19 |
|
|
src[binary] = source |
| 20 |
|
|
f.close() |
| 21 |
|
|
|
| 22 |
hertzog |
393 |
error = "404 File not found" |
| 23 |
|
|
url = "" |
| 24 |
|
|
if os.environ.has_key("REDIRECT_ERROR_NOTES"): |
| 25 |
|
|
error = os.environ["REDIRECT_ERROR_NOTES"] |
| 26 |
|
|
if os.environ.has_key("REDIRECT_URL"): |
| 27 |
|
|
url = os.environ["REDIRECT_URL"] |
| 28 |
hertzog |
382 |
pkgbin = "" |
| 29 |
|
|
pkgsrc = "" |
| 30 |
hertzog |
601 |
hash = "" |
| 31 |
|
|
srcfile = "" |
| 32 |
hertzog |
382 |
|
| 33 |
|
|
res = re.match(r"^/.*/(.*)\.html", url) |
| 34 |
|
|
if res: |
| 35 |
|
|
pkgbin = res.group(1) |
| 36 |
|
|
if src.has_key(pkgbin): |
| 37 |
|
|
pkgsrc = src[pkgbin] |
| 38 |
hertzog |
601 |
hash = pkgsrc[0] |
| 39 |
hertzog |
602 |
if pkgsrc[0:3] == "lib": |
| 40 |
|
|
hash = pkgsrc[0:4] |
| 41 |
hertzog |
601 |
srcfile = "../web/%s/%s.html" % (hash, pkgsrc) |
| 42 |
hertzog |
382 |
|
| 43 |
|
|
print "Content-Type: text/html" |
| 44 |
|
|
print |
| 45 |
|
|
print "<html><head><title>Error 404</title>" |
| 46 |
hertzog |
601 |
if pkgsrc and os.path.isfile(srcfile): |
| 47 |
hertzog |
382 |
print "<meta http-equiv='refresh' content='10;url=/%s'>" % pkgsrc |
| 48 |
|
|
print "</head><body>" |
| 49 |
|
|
|
| 50 |
hertzog |
601 |
if pkgsrc and os.path.isfile(srcfile): |
| 51 |
hertzog |
382 |
print "<h1>Little error ...</h1>" |
| 52 |
|
|
print "<p>The page you asked doesn't exist." |
| 53 |
|
|
print "However it looks like you were trying to look for `%s' binary package." % pkgbin |
| 54 |
|
|
print "The Package Tracking System is source based, therefore you should" |
| 55 |
|
|
print "have looked for `%s'." % pkgsrc |
| 56 |
|
|
print "<p><a href='/%s'>Click here to be redirected or wait 10 seconds.</a>" % pkgsrc |
| 57 |
|
|
else: |
| 58 |
|
|
print "<h1>Error 404</h1>" |
| 59 |
|
|
print "I'm sorry, the page that you asked doesn't exist :<br>" |
| 60 |
|
|
print "<pre>%s</pre>" % error |
| 61 |
jeroen |
1075 |
print "Maybe you've made a mistake and the package you're looking for \ |
| 62 |
|
|
does not (or no longer) exist" |
| 63 |
hertzog |
382 |
|
| 64 |
|
|
print "</body></html>" |
| 65 |
|
|
|