source: subversion/sites/other/tilesAtHome_tahngo/tah_intern/views.py @ 8877

Last change on this file since 8877 was 8877, checked in by spaetz, 10 years ago

adapt path to new location

File size: 1.1 KB
Line 
1from django.http import HttpResponse
2from tah.tah_intern.models import Blank, Layer
3from django.core.exceptions import ObjectDoesNotExist
4
5def show_log(request):
6  read_size=1024
7  #TODO use a setting for the log file location?
8  f = open('/var/www/tah/tah_intern/tah.log', 'rU')
9  offset = read_size
10  f.seek(0, 2)
11  file_size = f.tell()
12  if file_size < offset:
13    offset = file_size
14  f.seek(-1*offset, 2)
15  read_str = f.read(offset)
16  # Remove newline at the end
17  if read_str[offset - 1] == '\n':
18    read_str = read_str[:-1]
19  lines = read_str.split('\n')
20  f.close()
21  return HttpResponse("\n".join(lines[-10:]), mimetype="text/plain")
22
23def index(request):
24  return HttpResponse('')
25
26def show(request,layer,x,y,z):
27  retcode = 0
28  file=("/var/www/osm/Tiles/Gfx/unknown.png","/var/www/osm/Tiles/Gfx/sea.png","/var/www/osm/Tiles/Gfx/sea.png","/var/www/osm/Tiles/Gfx/error.png")
29  try:
30    l = Layer.objects.get(name=layer)
31  except ObjectDoesNotExist:
32    retcode = 3
33
34  if retcode == 0:
35    retcode = int(Blank(layer=l,z=z,x=x,y=y))
36
37  image_data = open(file[retcode], "rb").read()
38  return HttpResponse(image_data, mimetype="image/png")
Note: See TracBrowser for help on using the repository browser.