diff options
author | substantialnoninfringinguser <substantialnoninfringinguser@gmail.com> | 2009-05-13 05:13:38 +0100 |
---|---|---|
committer | substantialnoninfringinguser <substantialnoninfringinguser@gmail.com> | 2009-05-13 05:13:38 +0100 |
commit | b503d3d588474cc41bffc01eca7654bb8c6f4a42 (patch) | |
tree | 782956fc07f18a13ae24fc0c045e970c6ba03f04 /expo/views_survex.py | |
download | troggle-b503d3d588474cc41bffc01eca7654bb8c6f4a42.tar.gz troggle-b503d3d588474cc41bffc01eca7654bb8c6f4a42.tar.bz2 troggle-b503d3d588474cc41bffc01eca7654bb8c6f4a42.zip |
[svn] Initial troggle checkin
This is a development site using Django 1.0
Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8034 by julian @ 10/26/2008 9:04 PM
Diffstat (limited to 'expo/views_survex.py')
-rw-r--r-- | expo/views_survex.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/expo/views_survex.py b/expo/views_survex.py new file mode 100644 index 0000000..c356363 --- /dev/null +++ b/expo/views_survex.py @@ -0,0 +1,44 @@ +from django.shortcuts import render_to_response
+from django.http import HttpResponse, Http404
+import re
+import os
+
+import troggle.settings as settings
+
+def index(request, survex_file):
+ process(survex_file)
+ f = open(settings.SURVEX_DATA + survex_file + ".svx", "rb")
+ a = f.read()
+ return render_to_response('svxfile.html', {'settings': settings,
+ 'has_3d': os.path.isfile(settings.SURVEX_DATA + survex_file + ".3d"),
+ 'title': survex_file,
+ 'text': unicode(a, "latin1")})
+
+def svx(request, survex_file):
+ svx = open(settings.SURVEX_DATA + survex_file + ".svx", "rb")
+ return HttpResponse(svx, mimetype="text")
+
+def threed(request, survex_file):
+ process(survex_file)
+ try:
+ threed = open(settings.SURVEX_DATA + survex_file + ".3d", "rb")
+ return HttpResponse(threed, mimetype="model/3d")
+ except:
+ log = open(settings.SURVEX_DATA + survex_file + ".log", "rb")
+ return HttpResponse(log, mimetype="text")
+
+def log(request, survex_file):
+ process(survex_file)
+ log = open(settings.SURVEX_DATA + survex_file + ".log", "rb")
+ return HttpResponse(log, mimetype="text")
+
+def err(request, survex_file):
+ process(survex_file)
+ err = open(settings.SURVEX_DATA + survex_file + ".err", "rb")
+ return HttpResponse(err, mimetype="text")
+
+def process(survex_file):
+ cwd = os.getcwd()
+ os.chdir(os.path.split(settings.SURVEX_DATA + survex_file)[0])
+ os.system(settings.CAVERN + " --log " +settings.SURVEX_DATA + survex_file + ".svx")
+ os.chdir(cwd)
\ No newline at end of file |