Indented msgs for recursive file traversal

This commit is contained in:
Philip Sargent 2020-05-15 21:45:23 +01:00
parent d4ac28af18
commit e017c6effc

View File

@ -31,23 +31,29 @@ def LoadSurvexLineLeg(survexblock, stardata, sline, comment, cave):
try: try:
survexleg.tape = float(ls[stardata["tape"]]) survexleg.tape = float(ls[stardata["tape"]])
except ValueError: except ValueError:
print("Tape misread in", survexblock.survexfile.path) print("! Tape misread in", survexblock.survexfile.path)
print("Stardata:", stardata) print(" Stardata:", stardata)
print("Line:", ls) print(" Line:", ls)
message = ' ! Value Error: line %s in %s' % (ls, survexblock.survexfile.path)
models.DataIssue.objects.create(parser='survex', message=message)
survexleg.tape = 1000 survexleg.tape = 1000
try: try:
lclino = ls[stardata["clino"]] lclino = ls[stardata["clino"]]
except: except:
print("Clino misread in", survexblock.survexfile.path) print("! Clino misread in", survexblock.survexfile.path)
print("Stardata:", stardata) print(" Stardata:", stardata)
print("Line:", ls) print(" Line:", ls)
message = ' ! Value Error: line %s in %s' % (ls, survexblock.survexfile.path)
models.DataIssue.objects.create(parser='survex', message=message)
lclino = error lclino = error
try: try:
lcompass = ls[stardata["compass"]] lcompass = ls[stardata["compass"]]
except: except:
print("Compass misread in", survexblock.survexfile.path) print("! Compass misread in", survexblock.survexfile.path)
print("Stardata:", stardata) print(" Stardata:", stardata)
print("Line:", ls) print(" Line:", ls)
message = ' ! Value Error: line %s in %s' % (ls, survexblock.survexfile.path)
models.DataIssue.objects.create(parser='survex', message=message)
lcompass = error lcompass = error
if lclino == "up": if lclino == "up":
survexleg.compass = 0.0 survexleg.compass = 0.0
@ -59,9 +65,11 @@ def LoadSurvexLineLeg(survexblock, stardata, sline, comment, cave):
try: try:
survexleg.compass = float(lcompass) survexleg.compass = float(lcompass)
except ValueError: except ValueError:
print("Compass misread in", survexblock.survexfile.path) print("! Compass misread in", survexblock.survexfile.path)
print("Stardata:", stardata) print(" Stardata:", stardata)
print("Line:", ls) print(" Line:", ls)
message = ' ! Value Error: line %s in %s' % (ls, survexblock.survexfile.path)
models.DataIssue.objects.create(parser='survex', message=message)
survexleg.compass = 1000 survexleg.compass = 1000
survexleg.clino = -90.0 survexleg.clino = -90.0
else: else:
@ -81,7 +89,7 @@ def LoadSurvexLineLeg(survexblock, stardata, sline, comment, cave):
try: try:
survexblock.totalleglength += float(ls[itape]) survexblock.totalleglength += float(ls[itape])
except ValueError: except ValueError:
print("Length not added") print("! Length not added")
survexblock.save() survexblock.save()
@ -185,7 +193,9 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines):
survexblock.save() survexblock.save()
# print(insp+' - Wallet ; ref - %s - found in survexscansfolders' % refscan) # print(insp+' - Wallet ; ref - %s - found in survexscansfolders' % refscan)
else: else:
print(insp+' - Wallet ; ref - %s - NOT found in survexscansfolders %s-%s-%s' % (refscan,yr,letterx,wallet)) message = ' ! Wallet ; ref - %s - NOT found in survexscansfolders %s-%s-%s' % (refscan,yr,letterx,wallet)
print(insp+message)
models.DataIssue.objects.create(parser='survex', message=message)
# This whole section should be moved if we can have *QM become a proper survex command # This whole section should be moved if we can have *QM become a proper survex command
# Spec of QM in SVX files, currently commented out need to add to survex # Spec of QM in SVX files, currently commented out need to add to survex
@ -255,7 +265,9 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines):
survexblock.save() survexblock.save()
# print(insp+' - Wallet *REF - %s - found in survexscansfolders' % refscan) # print(insp+' - Wallet *REF - %s - found in survexscansfolders' % refscan)
else: else:
print(insp+' - Wallet *REF - %s - NOT found in survexscansfolders %s-%s-%s' % (refscan,yr,letterx,wallet)) message = ' ! Wallet *REF - %s - NOT found in survexscansfolders %s-%s-%s' % (refscan,yr,letterx,wallet)
print(insp+message)
models.DataIssue.objects.create(parser='survex', message=message)
continue continue
# detect the star command # detect the star command
@ -405,7 +417,10 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines):
#print(insp+' - Stuff') #print(insp+' - Stuff')
if cmd not in ["sd", "include", "units", "entrance", "data", "flags", "title", "export", "instrument", if cmd not in ["sd", "include", "units", "entrance", "data", "flags", "title", "export", "instrument",
"calibrate", "set", "infer", "alias", "cs", "declination", "case"]: "calibrate", "set", "infer", "alias", "cs", "declination", "case"]:
print(insp+"Unrecognised command in line:", cmd, line, survexblock, survexblock.survexfile.path) message = "! Bad svx command in line:%s %s %s %s" % (cmd, line, survexblock, survexblock.survexfile.path)
print(insp+message)
models.DataIssue.objects.create(parser='survex', message=message)
endstamp = datetime.now() endstamp = datetime.now()
timetaken = endstamp - stamp timetaken = endstamp - stamp
# print(insp+' - Time to process: ' + str(timetaken)) # print(insp+' - Time to process: ' + str(timetaken))
@ -424,6 +439,8 @@ def LoadAllSurvexBlocks():
models.SurvexStation.objects.all().delete() models.SurvexStation.objects.all().delete()
print(" - Data flushed") print(" - Data flushed")
# Clear the data issues as we are reloading
models.DataIssue.objects.filter(parser='survex').delete()
print(' - Loading All Survex Blocks...') print(' - Loading All Survex Blocks...')
print(' - redirecting stdout to loadsurvexblks.log ...') print(' - redirecting stdout to loadsurvexblks.log ...')