]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/planet/files/default/cgi/HEADER.cgi
Convert planet HEADER scripts to python 3
[chef.git] / cookbooks / planet / files / default / cgi / HEADER.cgi
index 874c9c28da1a6143ccb10bafeeef0e2ba616a31b..d71c3c5aa2c1ce8b88c5fa1b3b8baf40b630809c 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 from time import time
 from os import stat, environ
@@ -43,18 +43,19 @@ def nice_time(time):
 
     return '%d months' % (time / 2592000.)
 
-def file_info(file, name):
+def file_info(file, rss_file, name):
+    torrent_file = file + '.torrent'
     size = nice_size(file)
     hash = search(r'\w{32}', open(file+'.md5', 'r').read()).group(0)
     date = nice_time(time() - stat(file).st_mtime)
 
-    return '<b><a href="%(file)s">%(name)s</a></b><br><b>%(size)s</b>, created %(date)s ago.<br><small>md5: %(hash)s</small>.' % locals()
+    return '<b><a href="%(file)s">%(name)s</a> (<a href="%(torrent_file)s">torrent</a>) (<a href="%(rss_file)s">RSS</a>)</b><br><b>%(size)s</b>, created %(date)s ago.<br><small>md5: %(hash)s</small>.' % locals()
 
-planet_link = file_info('planet/planet-latest.osm.bz2', 'Latest Weekly Planet XML File')
-changesets_link = file_info('planet/changesets-latest.osm.bz2', 'Latest Weekly Changesets')
-planet_pbf_link = file_info('pbf/planet-latest.osm.pbf', 'Latest Weekly Planet PBF File')
+planet_link = file_info('planet/planet-latest.osm.bz2', 'planet/planet-bz2-rss.xml', 'Latest Weekly Planet XML File')
+changesets_link = file_info('planet/changesets-latest.osm.bz2', 'planet/changesets-bz2-rss.xml', 'Latest Weekly Changesets')
+planet_pbf_link = file_info('pbf/planet-latest.osm.pbf', 'pbf/planet-pbf-rss.xml', 'Latest Weekly Planet PBF File')
 
-print """
+print("""
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
 <html>
  <head>
@@ -132,4 +133,4 @@ database, and those published before the 12 September 2012 are distributed under
 <p>
 If you find data within OpenStreetMap that you believe is an infringement of someone else's copyright, then please make contact with the <a href="https://wiki.openstreetmap.org/wiki/Data_working_group">OpenStreetMap Data Working Group</a>.
 </p>
-""" % locals()
+""" % locals())