X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/96c2c1135c7ca32771a816a0fa5b6fd169e9851b..366f2c3039f3115f856906fc19cc1fbae348fffc:/cookbooks/tile/templates/default/debug.erb diff --git a/cookbooks/tile/templates/default/debug.erb b/cookbooks/tile/templates/default/debug.erb index 03af6549f..e3e3852a0 100755 --- a/cookbooks/tile/templates/default/debug.erb +++ b/cookbooks/tile/templates/default/debug.erb @@ -1,4 +1,4 @@ -#!/usr/bin/python -u +#!/usr/bin/python3 -u # -*- coding: utf-8 -*- import cgi @@ -22,35 +22,35 @@ resource.setrlimit(resource.RLIMIT_AS,(4000000000, 4000000000)) # Routine to output HTTP headers def output_headers(content_type, filename = "", length = 0): - print "Cache-Control: no-cache, no-store, must-revalidate')" - print "Pragma: no-cache" - print "Expires: 0" - print "Content-Type: %s" % content_type + print("Cache-Control: no-cache, no-store, must-revalidate')") + print("Pragma: no-cache") + print("Expires: 0") + print("Content-Type: %s" % content_type) if filename: - print "Content-Disposition: attachment; filename=\"%s\"" % filename + print("Content-Disposition: attachment; filename=\"%s\"" % filename) if length: - print "Content-Length: %d" % length - print "" + print("Content-Length: %d" % length) + print("") # Routine to report an error def output_error(message): output_headers("text/html") - print "" - print "" - print "Error" - print "" - print "" - print "

Error

" - print "

%s

" % message - print "" - print "" + print("") + print("") + print("Error") + print("") + print("") + print("

Error

") + print("

%s

" % message) + print("") + print("") # Make sure we have a user agent -if not os.environ.has_key('HTTP_USER_AGENT'): +if 'HTTP_USER_AGENT' not in os.environ: os.environ['HTTP_USER_AGENT'] = 'NONE' # Get the cache server name -if os.environ.has_key('HTTP_VIA'): +if 'HTTP_VIA' in os.environ: cache_server = re.search('[a-z0-9-]+\.openstreetmap\.org', os.environ['HTTP_VIA']).group(0) else: cache_server = None @@ -59,35 +59,35 @@ else: loadavg = float(open("/proc/loadavg").readline().split(" ")[0]) output_headers("text/html") -print "" -print "" -print "tile.openstreetmap.org debug" -print "" -print "" -print "

tile.openstreetmap.org debug

" -print "

Server Stats

" +print("") +print("") +print("tile.openstreetmap.org debug") +print("") +print("") +print("

tile.openstreetmap.org debug

") +print("

Server Stats

") if cache_server: - print "

Cache Server: %s

" % cache_server -print "

" -print "Render Server: <%= node['fqdn'] %>
" -print "Load Average: %s

" % loadavg -print "

File Status

" -print "

" + print("

Cache Server: %s

" % cache_server) +print("

") +print("Render Server: <%= node['fqdn'] %>
") +print("Load Average: %s

" % loadavg) +print("

File Status

") +print("

") <% node[:tile][:data].each do |name,data| url = data[:url] file = "/srv/tile.openstreetmap.org/data/#{File.basename(url)}" file_basename = File.basename(url) -%> -print "%s last modified: %s
" % ("<%= file_basename %>", time.ctime(os.path.getmtime("<%= file %>"))) +print("%s last modified: %s
" % ("<%= file_basename %>", time.ctime(os.path.getmtime("<%= file %>")))) <% end -%> -print "

" -print "

Browser Request Headers

" -print "

" -for param in os.environ.keys(): - print "%20s: %s
" % (param, os.environ[param]) -print "

" -print "" -print "" +print("

") +print("

Browser Request Headers

") +print("

") +for param in sorted(os.environ): + print("%20s: %s
" % (param, os.environ[param])) +print("

") +print("") +print("")