mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 16:51:54 +00:00
getting the LoadPos to work better
This commit is contained in:
parent
b4c0c4d219
commit
ecf92e2079
2
.gitignore
vendored
2
.gitignore
vendored
@ -31,3 +31,5 @@ import_profile.json
|
||||
import_times.json
|
||||
ignored-files.log
|
||||
tunnel-import.log
|
||||
posnotfound
|
||||
troggle.sqlite-journal
|
||||
|
@ -10,7 +10,7 @@ from django.utils.timezone import make_aware
|
||||
|
||||
import re
|
||||
import os
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
line_leg_regex = re.compile(r"[\d\-+.]+$")
|
||||
|
||||
@ -405,19 +405,24 @@ def LoadPos():
|
||||
updtsvx = os.path.getmtime(topdata + ".svx")
|
||||
updtcache = os.path.getmtime(cachefile)
|
||||
age = updtcache - updtsvx
|
||||
print(' svx: %s cache: %s cache age: %s' % (updtsvx, updtcache, age ))
|
||||
print(' svx: %s cache: %s cache age: %s' % (updtsvx, updtcache, str(timedelta(seconds=age) )))
|
||||
if age < 0 :
|
||||
print " cache is stale."
|
||||
os.remove(cachefile)
|
||||
else:
|
||||
print " cache is fresh."
|
||||
print " cache is fresh. Reading..."
|
||||
try:
|
||||
f = open(cachefile, "r")
|
||||
with open(cachefile, "r") as f:
|
||||
for line in f:
|
||||
notfoundbefore[line] +=1 # should not be duplicates
|
||||
l = line.rstrip()
|
||||
if l in notfoundbefore:
|
||||
notfoundbefore[l] +=1 # should not be duplicates
|
||||
print " DUPLICATE ", line, notfoundbefore[l]
|
||||
else:
|
||||
notfoundbefore[l] =1
|
||||
except:
|
||||
print " FAILURE READ opening cache file %s" % (cachefile)
|
||||
f.close()
|
||||
raise
|
||||
|
||||
|
||||
notfoundnow =[]
|
||||
@ -434,7 +439,7 @@ def LoadPos():
|
||||
if r:
|
||||
x, y, z, name = r.groups() # easting, northing, altitude
|
||||
if name in notfoundbefore:
|
||||
skip[name] += 1
|
||||
skip[name] = 1
|
||||
else:
|
||||
try:
|
||||
ss = models.SurvexStation.objects.lookup(name)
|
||||
@ -446,16 +451,18 @@ def LoadPos():
|
||||
except:
|
||||
#print "%s in %s.pos not found in lookup of SurvexStation.objects" % (name, settings.SURVEX_TOPNAME)
|
||||
notfoundnow.append(name)
|
||||
print " - %s stations NOT found in lookup of SurvexStation.objects. %s found. %s skipper." % (len(notfoundnow),found, 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:
|
||||
with open(cachefile, "w") as f:
|
||||
print " cache file opened"
|
||||
c = len(notfoundnow)+len(skip)
|
||||
for i in notfoundnow:
|
||||
f.write("%s\n" % i)
|
||||
for j in skip:
|
||||
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)
|
||||
raise
|
||||
|
||||
|
@ -7,7 +7,7 @@ import django
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
# Django settings for troggle project.
|
||||
DEBUG = True
|
||||
DEBUG = False
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
ALLOWED_HOSTS = [u'expo.survex.com']
|
||||
|
Loading…
Reference in New Issue
Block a user