From be2b17ea8561f7b5678cbba5e5933c603b276dd9 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Tue, 30 Jun 2020 15:24:42 +0100 Subject: [PATCH] More debugging and warnings --- core/views_caves.py | 30 +++++++++++++++--------------- parsers/imports.py | 6 ++++++ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/core/views_caves.py b/core/views_caves.py index c2759e1..dfcbf39 100644 --- a/core/views_caves.py +++ b/core/views_caves.py @@ -8,7 +8,6 @@ import urllib.parse from PIL import Image, ImageDraw, ImageFont from django import forms from django.conf import settings -#from django.forms.models import modelformset_factory from django.urls import reverse from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import get_object_or_404, render @@ -38,7 +37,20 @@ class MapLocations(object): def points(self): for ent in Entrance.objects.all(): if ent.best_station(): - areaName = ent.caveandentrance_set.all()[0].cave.getArea().short_name + try: + k = ent.caveandentrance_set.all()[0].cave + except: + message = " ! Failed to get Cave linked to Entrance:{} from:{} best:{}".format(ent.name, ent.filename, ent.best_station()) + models.DataIssue.objects.create(parser='entrances', message=message) + print(message) + raise + try: + areaName = k.getArea().short_name + except: + message = " ! Failed to get Area on cave '{}' linked to Entrance:{} from:{} best:{}".format(cave, ent.name, ent.filename, ent.best_station()) + models.DataIssue.objects.create(parser='entrances', message=message) + print(message) + raise self.p.append((ent.best_station(), "%s-%s" % (areaName, str(ent)[5:]), ent.needs_surface_work(), str(ent))) return self.p @@ -47,6 +59,7 @@ class MapLocations(object): def getCave(cave_id): """Returns a cave object when given a cave name or number. It is used by views including cavehref, ent, and qm.""" + # REPLACE OR MERGE this with other functions that do exactly th same thing! try: cave = Cave.objects.get(kataster_number=cave_id) except Cave.DoesNotExist: @@ -276,19 +289,6 @@ def surveyindex(request): expeditions=Expedition.objects.order_by("-year") return render(request,'survey.html',locals()) -# def survey(request,year,wallet_number): - # surveys=Survey.objects.all() - # expeditions=Expedition.objects.order_by("-year") - # current_expedition=Expedition.objects.filter(year=year)[0] - - # if wallet_number!='': - # current_survey=Survey.objects.filter(expedition=current_expedition,wallet_number=wallet_number)[0] - # # notes=current_survey.scannedimage_set.filter(contents='notes') - # planSketches=current_survey.scannedimage_set.filter(contents='plan') - # elevationSketches=current_survey.scannedimage_set.filter(contents='elevation') - - return render(request,'survey.html', locals()) - def cave_description(request, cavedescription_name): cave_description = get_object_or_404(CaveDescription, short_name = cavedescription_name) return render(request,'cave_description.html', locals()) diff --git a/parsers/imports.py b/parsers/imports.py index 9dcbb17..dcd064d 100644 --- a/parsers/imports.py +++ b/parsers/imports.py @@ -46,6 +46,12 @@ def import_survex(): print(" - Survex entrances x/y/z Positions") troggle.parsers.survex.LoadPos() +def import_loadpos(): + # when this import is moved to the top with the rest it all crashes horribly + import troggle.parsers.survex + print(" - Survex entrances x/y/z Positions") + troggle.parsers.survex.LoadPos() + def import_tunnelfiles(): print("Importing Tunnel files") troggle.parsers.surveys.LoadTunnelFiles()