diff --git a/parsers/survex.py b/parsers/survex.py index e9421c5..4fddf6c 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -31,23 +31,29 @@ def LoadSurvexLineLeg(survexblock, stardata, sline, comment, cave): try: survexleg.tape = float(ls[stardata["tape"]]) except ValueError: - print("Tape misread in", survexblock.survexfile.path) - print("Stardata:", stardata) - print("Line:", ls) + print("! Tape misread in", survexblock.survexfile.path) + print(" Stardata:", stardata) + 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 try: lclino = ls[stardata["clino"]] except: - print("Clino misread in", survexblock.survexfile.path) - print("Stardata:", stardata) - print("Line:", ls) + print("! Clino misread in", survexblock.survexfile.path) + print(" Stardata:", stardata) + print(" Line:", ls) + message = ' ! Value Error: line %s in %s' % (ls, survexblock.survexfile.path) + models.DataIssue.objects.create(parser='survex', message=message) lclino = error try: lcompass = ls[stardata["compass"]] except: - print("Compass misread in", survexblock.survexfile.path) - print("Stardata:", stardata) - print("Line:", ls) + print("! Compass misread in", survexblock.survexfile.path) + print(" Stardata:", stardata) + print(" Line:", ls) + message = ' ! Value Error: line %s in %s' % (ls, survexblock.survexfile.path) + models.DataIssue.objects.create(parser='survex', message=message) lcompass = error if lclino == "up": survexleg.compass = 0.0 @@ -59,9 +65,11 @@ def LoadSurvexLineLeg(survexblock, stardata, sline, comment, cave): try: survexleg.compass = float(lcompass) except ValueError: - print("Compass misread in", survexblock.survexfile.path) - print("Stardata:", stardata) - print("Line:", ls) + print("! Compass misread in", survexblock.survexfile.path) + print(" Stardata:", stardata) + 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.clino = -90.0 else: @@ -81,7 +89,7 @@ def LoadSurvexLineLeg(survexblock, stardata, sline, comment, cave): try: survexblock.totalleglength += float(ls[itape]) except ValueError: - print("Length not added") + print("! Length not added") survexblock.save() @@ -185,7 +193,9 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines): survexblock.save() # print(insp+' - Wallet ; ref - %s - found in survexscansfolders' % refscan) 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 # 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() # print(insp+' - Wallet *REF - %s - found in survexscansfolders' % refscan) 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 # detect the star command @@ -405,7 +417,10 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines): #print(insp+' - Stuff') if cmd not in ["sd", "include", "units", "entrance", "data", "flags", "title", "export", "instrument", "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() timetaken = endstamp - stamp # print(insp+' - Time to process: ' + str(timetaken)) @@ -424,6 +439,8 @@ def LoadAllSurvexBlocks(): models.SurvexStation.objects.all().delete() print(" - Data flushed") + # Clear the data issues as we are reloading + models.DataIssue.objects.filter(parser='survex').delete() print(' - Loading All Survex Blocks...') print(' - redirecting stdout to loadsurvexblks.log ...')