caves, scans, survex work in databaseRest

This commit is contained in:
Philip Sargent 2020-06-19 00:26:15 +01:00
parent 4a51de95c4
commit 2c469718f6
2 changed files with 14 additions and 2 deletions

View File

@ -25,6 +25,8 @@ rx_line_length = re.compile(r"[\d\-+.]+$")
survexlegsalllength = 0.0
survexlegsnumber = 0
survexblockroot = None
ROOTBLOCK = "rootblock"
def LoadSurvexLineLeg(survexblock, stardata, sline, comment, cave):
global survexlegsalllength
@ -460,7 +462,7 @@ def LoadAllSurvexBlocks():
#Load all
# this is the first so id=1
survexblockroot = models_survex.SurvexBlock(name="rootblock", survexpath="", cave=None, survexfile=survexfile,
survexblockroot = models_survex.SurvexBlock(name=ROOTBLOCK, survexpath="", cave=None, survexfile=survexfile,
legsall=0, legssplay=0, legssurfc=0, totalleglength=0.0)
survexblockroot.save()
fin = survexfile.OpenFile()
@ -556,7 +558,16 @@ def LoadPos():
posfile = open("%s.pos" % (topdata))
posfile.readline() #Drop header
survexblockroot = models_survex.SurvexBlock.objects.get(id=1)
try:
survexblockroot = models_survex.SurvexBlock.objects.get(name=ROOTBLOCK)
except:
try:
survexblockroot = models_survex.SurvexBlock.objects.get(id=1)
except:
message = ' ! FAILED to find root SurvexBlock'
print(message)
models.DataIssue.objects.create(parser='survex', message=message)
raise
for line in posfile.readlines():
r = poslineregex.match(line)
if r:

View File

@ -45,6 +45,7 @@ def save_carefully(objectType, lookupAttribs={}, nonLookupAttribs={}):
defined in core.models.TroggleModel.
"""
print(" !! - SAVE CAREFULLY Django 1.11.29 ", objectType)
instance, created = objectType.objects.get_or_create(defaults=nonLookupAttribs, **lookupAttribs)
if not created and not instance.new_since_parsing: