forked from expo/troggle
bugfixes done using _future_
This commit is contained in:
@@ -1,21 +1,17 @@
|
|||||||
from __future__ import (absolute_import, division,
|
from __future__ import absolute_import, division, print_function
|
||||||
print_function)
|
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
from datetime import datetime, timedelta
|
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 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 'survex block' is a *begin...*end set of cave data.
|
||||||
A 'survexscansfolder' is what we today call a "survey scans folder" or a "wallet".
|
A 'survexscansfolder' is what we today call a "survey scans folder" or a "wallet".
|
||||||
@@ -516,35 +512,35 @@ def LoadPos():
|
|||||||
|
|
||||||
now = time.time()
|
now = time.time()
|
||||||
if now - updtcache > 3*24*60*60:
|
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)
|
os.remove(cachefile)
|
||||||
elif age < 0 :
|
elif age < 0 :
|
||||||
print " cache is stale. Deleting."
|
print(" cache is stale. Deleting.")
|
||||||
os.remove(cachefile)
|
os.remove(cachefile)
|
||||||
else:
|
else:
|
||||||
print " cache is fresh. Reading..."
|
print(" cache is fresh. Reading...")
|
||||||
try:
|
try:
|
||||||
with open(cachefile, "r") as f:
|
with open(cachefile, "r") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
l = line.rstrip()
|
l = line.rstrip()
|
||||||
if l in notfoundbefore:
|
if l in notfoundbefore:
|
||||||
notfoundbefore[l] +=1 # should not be duplicates
|
notfoundbefore[l] +=1 # should not be duplicates
|
||||||
print " DUPLICATE ", line, notfoundbefore[l]
|
print(" DUPLICATE ", line, notfoundbefore[l])
|
||||||
else:
|
else:
|
||||||
notfoundbefore[l] =1
|
notfoundbefore[l] =1
|
||||||
except:
|
except:
|
||||||
print " FAILURE READ opening cache file %s" % (cachefile)
|
print(" FAILURE READ opening cache file %s" % (cachefile))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
notfoundnow =[]
|
notfoundnow =[]
|
||||||
found = 0
|
found = 0
|
||||||
skip = {}
|
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
|
# cavern defaults to using same cwd as supplied input file
|
||||||
call([settings.CAVERN, "--output=%s.3d" % (topdata), "%s.svx" % (topdata)])
|
call([settings.CAVERN, "--output=%s.3d" % (topdata), "%s.svx" % (topdata)])
|
||||||
call([settings.THREEDTOPOS, '%s.3d' % (topdata)], cwd = settings.SURVEX_DATA)
|
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 = open("%s.pos" % (topdata))
|
||||||
posfile.readline() #Drop header
|
posfile.readline() #Drop header
|
||||||
@@ -564,7 +560,7 @@ def LoadPos():
|
|||||||
found += 1
|
found += 1
|
||||||
except:
|
except:
|
||||||
notfoundnow.append(name)
|
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
|
if found > 10: # i.e. a previous cave import has been done
|
||||||
try:
|
try:
|
||||||
@@ -576,6 +572,5 @@ def LoadPos():
|
|||||||
f.write("%s\n" % j) # NB skip not notfoundbefore
|
f.write("%s\n" % j) # NB skip not notfoundbefore
|
||||||
print(' Not-found cache file written: %s entries' % c)
|
print(' Not-found cache file written: %s entries' % c)
|
||||||
except:
|
except:
|
||||||
print " FAILURE WRITE opening cache file %s" % (cachefile)
|
print(" FAILURE WRITE opening cache file %s" % (cachefile))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user