bugfixes done using _future_

This commit is contained in:
Philip Sargent 2020-06-01 02:18:25 +01:00
parent a0c5a34b3f
commit e873dedcf2

View File

@ -1,21 +1,17 @@
from __future__ import (absolute_import, division,
print_function)
import sys
from __future__ import absolute_import, division, print_function
import os
import re
import sys
import time
from datetime import datetime, timedelta
from subprocess import call, Popen, PIPE
from subprocess import PIPE, Popen, call
from django.utils.timezone import get_current_timezone, make_aware
import troggle.settings as settings
import troggle.core.models as models
from troggle.parsers.people import GetPersonExpeditionNameLookup
from django.utils.timezone import get_current_timezone
from django.utils.timezone import make_aware
import re
import os
import time
from datetime import datetime, timedelta
import sys
"""A 'survex block' is a *begin...*end set of cave data.
A 'survexscansfolder' is what we today call a "survey scans folder" or a "wallet".
@ -516,35 +512,35 @@ def LoadPos():
now = time.time()
if now - updtcache > 3*24*60*60:
print " cache is more than 3 days old. Deleting."
print( " cache is more than 3 days old. Deleting.")
os.remove(cachefile)
elif age < 0 :
print " cache is stale. Deleting."
print(" cache is stale. Deleting.")
os.remove(cachefile)
else:
print " cache is fresh. Reading..."
print(" cache is fresh. Reading...")
try:
with open(cachefile, "r") as f:
for line in f:
l = line.rstrip()
if l in notfoundbefore:
notfoundbefore[l] +=1 # should not be duplicates
print " DUPLICATE ", line, notfoundbefore[l]
print(" DUPLICATE ", line, notfoundbefore[l])
else:
notfoundbefore[l] =1
except:
print " FAILURE READ opening cache file %s" % (cachefile)
print(" FAILURE READ opening cache file %s" % (cachefile))
raise
notfoundnow =[]
found = 0
skip = {}
print "\n" # extra line because cavern overwrites the text buffer somehow
print("\n") # extra line because cavern overwrites the text buffer somehow
# cavern defaults to using same cwd as supplied input file
call([settings.CAVERN, "--output=%s.3d" % (topdata), "%s.svx" % (topdata)])
call([settings.THREEDTOPOS, '%s.3d' % (topdata)], cwd = settings.SURVEX_DATA)
print " - This next bit takes a while. Matching ~32,000 survey positions. Be patient..."
print(" - This next bit takes a while. Matching ~32,000 survey positions. Be patient...")
posfile = open("%s.pos" % (topdata))
posfile.readline() #Drop header
@ -564,7 +560,7 @@ def LoadPos():
found += 1
except:
notfoundnow.append(name)
print " - %s stations not found in lookup of SurvexStation.objects. %s found. %s skipped." % (len(notfoundnow),found, len(skip))
print(" - %s stations not found in lookup of SurvexStation.objects. %s found. %s skipped." % (len(notfoundnow),found, len(skip)))
if found > 10: # i.e. a previous cave import has been done
try:
@ -576,6 +572,5 @@ def LoadPos():
f.write("%s\n" % j) # NB skip not notfoundbefore
print(' Not-found cache file written: %s entries' % c)
except:
print " FAILURE WRITE opening cache file %s" % (cachefile)
print(" FAILURE WRITE opening cache file %s" % (cachefile))
raise