mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 15:21:52 +00:00
Fix survey scans
Remove the assert for folders in survey wallets, this does mean currently they will be ignored by troggle.
This commit is contained in:
parent
f16b4e3f47
commit
e6fa54d0e5
@ -23,7 +23,7 @@ def getMimeType(extension):
|
|||||||
|
|
||||||
def listdir(request, path):
|
def listdir(request, path):
|
||||||
#try:
|
#try:
|
||||||
return HttpResponse(fileAbstraction.listdir(path), mimetype = "text/plain")
|
return HttpResponse(fileAbstraction.listdir(path), content_type="text/plain")
|
||||||
#except:
|
#except:
|
||||||
# raise Http404
|
# raise Http404
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ def upload(request, path):
|
|||||||
def download(request, path):
|
def download(request, path):
|
||||||
#try:
|
#try:
|
||||||
|
|
||||||
return HttpResponse(fileAbstraction.readFile(path), mimetype=getMimeType(path.split(".")[-1]))
|
return HttpResponse(fileAbstraction.readFile(path), content_type=getMimeType(path.split(".")[-1]))
|
||||||
#except:
|
#except:
|
||||||
# raise Http404
|
# raise Http404
|
||||||
|
|
||||||
@ -46,6 +46,7 @@ extmimetypes = {".txt": "text/plain",
|
|||||||
".html": "text/html",
|
".html": "text/html",
|
||||||
".png": "image/png",
|
".png": "image/png",
|
||||||
".jpg": "image/jpeg",
|
".jpg": "image/jpeg",
|
||||||
|
".jpeg": "image/jpeg",
|
||||||
}
|
}
|
||||||
|
|
||||||
# dead
|
# dead
|
||||||
@ -93,9 +94,9 @@ def jgtfile(request, f):
|
|||||||
fin = open(fp)
|
fin = open(fp)
|
||||||
ftext = fin.read()
|
ftext = fin.read()
|
||||||
fin.close()
|
fin.close()
|
||||||
return HttpResponse(ftext, mimetype=mimetype)
|
return HttpResponse(ftext, content_type=mimetype)
|
||||||
|
|
||||||
return HttpResponse("unknown file::%s::" % f, mimetype = "text/plain")
|
return HttpResponse("unknown file::%s::" % f, content_type = "text/plain")
|
||||||
|
|
||||||
|
|
||||||
def UniqueFile(fname):
|
def UniqueFile(fname):
|
||||||
@ -171,7 +172,7 @@ def surveyscansfolder(request, path):
|
|||||||
def surveyscansingle(request, path, file):
|
def surveyscansingle(request, path, file):
|
||||||
survexscansfolder = SurvexScansFolder.objects.get(walletname=path)
|
survexscansfolder = SurvexScansFolder.objects.get(walletname=path)
|
||||||
survexscansingle = SurvexScanSingle.objects.get(survexscansfolder=survexscansfolder, name=file)
|
survexscansingle = SurvexScanSingle.objects.get(survexscansfolder=survexscansfolder, name=file)
|
||||||
return HttpResponse(content=open(survexscansingle.ffile), mimetype="image/png")
|
return HttpResponse(content=open(survexscansingle.ffile), content_type=getMimeType(path.split(".")[-1]))
|
||||||
#return render_to_response('survexscansfolder.html', { 'survexscansfolder':survexscansfolder, 'settings': settings })
|
#return render_to_response('survexscansfolder.html', { 'survexscansfolder':survexscansfolder, 'settings': settings })
|
||||||
|
|
||||||
def surveyscansfolders(request):
|
def surveyscansfolders(request):
|
||||||
@ -187,7 +188,7 @@ def tunneldata(request):
|
|||||||
def tunnelfile(request, path):
|
def tunnelfile(request, path):
|
||||||
tunnelfile = TunnelFile.objects.get(tunnelpath=path)
|
tunnelfile = TunnelFile.objects.get(tunnelpath=path)
|
||||||
tfile = os.path.join(settings.TUNNEL_DATA, tunnelfile.tunnelpath)
|
tfile = os.path.join(settings.TUNNEL_DATA, tunnelfile.tunnelpath)
|
||||||
return HttpResponse(content=open(tfile), mimetype="text/plain")
|
return HttpResponse(content=open(tfile), content_type="text/plain")
|
||||||
|
|
||||||
def tunnelfileupload(request, path):
|
def tunnelfileupload(request, path):
|
||||||
tunnelfile = TunnelFile.objects.get(tunnelpath=path)
|
tunnelfile = TunnelFile.objects.get(tunnelpath=path)
|
||||||
@ -202,13 +203,13 @@ def tunnelfileupload(request, path):
|
|||||||
uploadedfile = request.FILES.values()[0]
|
uploadedfile = request.FILES.values()[0]
|
||||||
|
|
||||||
if uploadedfile.field_name != "sketch":
|
if uploadedfile.field_name != "sketch":
|
||||||
return HttpResponse(content="Error: non-sketch file uploaded", mimetype="text/plain")
|
return HttpResponse(content="Error: non-sketch file uploaded", content_type="text/plain")
|
||||||
if uploadedfile.content_type != "text/plain":
|
if uploadedfile.content_type != "text/plain":
|
||||||
return HttpResponse(content="Error: non-plain content type", mimetype="text/plain")
|
return HttpResponse(content="Error: non-plain content type", content_type="text/plain")
|
||||||
|
|
||||||
# could use this to add new files
|
# could use this to add new files
|
||||||
if os.path.split(path)[1] != uploadedfile.name:
|
if os.path.split(path)[1] != uploadedfile.name:
|
||||||
return HttpResponse(content="Error: name disagrees", mimetype="text/plain")
|
return HttpResponse(content="Error: name disagrees", content_type="text/plain")
|
||||||
|
|
||||||
orgsize = tunnelfile.filesize # = os.stat(tfile)[stat.ST_SIZE]
|
orgsize = tunnelfile.filesize # = os.stat(tfile)[stat.ST_SIZE]
|
||||||
|
|
||||||
@ -226,7 +227,7 @@ def tunnelfileupload(request, path):
|
|||||||
|
|
||||||
uploadedfile.close()
|
uploadedfile.close()
|
||||||
message = "File size %d overwritten with size %d" % (orgsize, tunnelfile.filesize)
|
message = "File size %d overwritten with size %d" % (orgsize, tunnelfile.filesize)
|
||||||
return HttpResponse(content=message, mimetype="text/plain")
|
return HttpResponse(content=message, content_type="text/plain")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ def parseSurveys(logfile=None):
|
|||||||
except (IOError, OSError):
|
except (IOError, OSError):
|
||||||
print("Survey CSV not found..")
|
print("Survey CSV not found..")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for expedition in Expedition.objects.filter(year__gte=2000): #expos since 2000, because paths and filenames were nonstandard before then
|
for expedition in Expedition.objects.filter(year__gte=2000): #expos since 2000, because paths and filenames were nonstandard before then
|
||||||
parseSurveyScans(expedition)
|
parseSurveyScans(expedition)
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ def LoadListScansFile(survexscansfolder):
|
|||||||
gld.append((fyf, ffyf, fisdiryf))
|
gld.append((fyf, ffyf, fisdiryf))
|
||||||
|
|
||||||
for (fyf, ffyf, fisdiryf) in gld:
|
for (fyf, ffyf, fisdiryf) in gld:
|
||||||
assert not fisdiryf, ffyf
|
#assert not fisdiryf, ffyf
|
||||||
if re.search(r"\.(?:png|jpg|jpeg)(?i)$", fyf):
|
if re.search(r"\.(?:png|jpg|jpeg)(?i)$", fyf):
|
||||||
survexscansingle = SurvexScanSingle(ffile=ffyf, name=fyf, survexscansfolder=survexscansfolder)
|
survexscansingle = SurvexScanSingle(ffile=ffyf, name=fyf, survexscansfolder=survexscansfolder)
|
||||||
survexscansingle.save()
|
survexscansingle.save()
|
||||||
|
2
urls.py
2
urls.py
@ -129,7 +129,7 @@ actualurlpatterns = patterns('',
|
|||||||
#(r'^survey_scans/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.SURVEY_SCANS, 'show_indexes':True}),
|
#(r'^survey_scans/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.SURVEY_SCANS, 'show_indexes':True}),
|
||||||
url(r'^survey_scans/$', view_surveys.surveyscansfolders, name="surveyscansfolders"),
|
url(r'^survey_scans/$', view_surveys.surveyscansfolders, name="surveyscansfolders"),
|
||||||
url(r'^survey_scans/(?P<path>[^/]+)/$', view_surveys.surveyscansfolder, name="surveyscansfolder"),
|
url(r'^survey_scans/(?P<path>[^/]+)/$', view_surveys.surveyscansfolder, name="surveyscansfolder"),
|
||||||
url(r'^survey_scans/(?P<path>[^/]+)/(?P<file>[^/]+(?:png|jpg))$',
|
url(r'^survey_scans/(?P<path>[^/]+)/(?P<file>[^/]+(?:png|jpg|jpeg))$',
|
||||||
view_surveys.surveyscansingle, name="surveyscansingle"),
|
view_surveys.surveyscansingle, name="surveyscansingle"),
|
||||||
|
|
||||||
url(r'^tunneldata/$', view_surveys.tunneldata, name="tunneldata"),
|
url(r'^tunneldata/$', view_surveys.tunneldata, name="tunneldata"),
|
||||||
|
Loading…
Reference in New Issue
Block a user