rename Tunnel files to Drawings files - phase 1

This commit is contained in:
Philip Sargent 2020-06-30 15:52:29 +01:00
parent 0a57ac3132
commit f76e0d3a16
3 changed files with 24 additions and 20 deletions

View File

@ -32,7 +32,7 @@ from django.contrib.auth.models import User
from troggle.core.models import get_process_memory
from troggle.core.models_caves import Cave, Entrance
from troggle.parsers.imports import import_caves, import_people, import_surveyscans, \
import_logbooks, import_QMs, import_survex, import_loadpos, import_tunnelfiles
import_logbooks, import_QMs, import_survex, import_loadpos, import_drawingsfiles
import troggle.logbooksdump
if os.geteuid() == 0:
@ -140,7 +140,7 @@ class JobQueue():
self.results_order=[
"date","runlabel","reinit", "caves", "people",
"logbooks", "QMs", "scans", "survex",
"tunnel", "test" ]
"drawings", "test" ]
for k in self.results_order:
self.results[k]=[]
self.tfile = "import_profile.json"
@ -285,7 +285,7 @@ def usage():
QMs - read in the QM csv files (older caves only)
scans - the survey scans in all the wallets (must run before survex)
survex - read in the survex files - all the survex blocks and entrances x/y/z
tunnel - read in the Tunnel files - which scans the survey scans too
drawings - read in the Tunnel & Therion files - which scans the survey scans too
autologbooks - Not used. read in autologbooks (what are these?)
dumplogbooks - Not used. write out autologbooks (not working?)
@ -334,7 +334,7 @@ if __name__ == "__main__":
jq.enq("scans",import_surveyscans)
jq.enq("logbooks",import_logbooks)
jq.enq("QMs",import_QMs)
jq.enq("tunnel",import_tunnelfiles)
jq.enq("drawings",import_drawingsfiles)
jq.enq("survex",import_survex)
elif "scans" in sys.argv:
jq.enq("scans",import_surveyscans)
@ -342,8 +342,8 @@ if __name__ == "__main__":
jq.enq("survex",import_survex)
elif "loadpos" in sys.argv:
jq.enq("survex",import_loadpos)
elif "tunnel" in sys.argv:
jq.enq("tunnel",import_tunnelfiles)
elif "drawings" in sys.argv:
jq.enq("drawings",import_drawingsfiles)
elif "autologbooks" in sys.argv: # untested in 2020
import_auto_logbooks()
elif "dumplogbooks" in sys.argv: # untested in 2020

View File

@ -52,7 +52,7 @@ def import_loadpos():
print(" - Survex entrances x/y/z Positions")
troggle.parsers.survex.LoadPos()
def import_tunnelfiles():
print("Importing Tunnel files")
troggle.parsers.surveys.LoadTunnelFiles()
def import_drawingsfiles():
print("Importing Drawings files")
troggle.parsers.surveys.LoadDrawingFiles()

View File

@ -15,6 +15,8 @@ import settings
#from troggle.core.models import *
#from troggle.core.models_caves import *
from troggle.core.models_survex import SingleScan, ScansFolder, TunnelFile
from troggle.core.models import DataIssue
def get_or_create_placeholder(year):
""" All surveys must be related to a logbookentry. We don't have a way to
@ -177,22 +179,24 @@ def SetTunnelfileInfo(tunnelfile):
tunnelfile.save()
def LoadTunnelFiles():
tunneldatadir = settings.TUNNEL_DATA
def LoadDrawingFiles():
drawdatadir = settings.TUNNEL_DATA
TunnelFile.objects.all().delete()
tunneldirs = [ "" ]
while tunneldirs:
tunneldir = tunneldirs.pop()
for f in os.listdir(os.path.join(tunneldatadir, tunneldir)):
DataIssue.objects.filter(parser='drawings').delete()
drawingsdirs = [ "" ]
while drawingsdirs:
drawdir = drawingsdirs.pop()
for f in os.listdir(os.path.join(drawdatadir, drawdir)):
if f[0] == "." or f[-1] == "~":
continue
lf = os.path.join(tunneldir, f)
ff = os.path.join(tunneldatadir, lf)
lf = os.path.join(drawdir, f)
ff = os.path.join(drawdatadir, lf)
if os.path.isdir(ff):
tunneldirs.append(lf)
drawingsdirs.append(lf)
elif f[-4:] == ".xml":
tunnelfile = TunnelFile(tunnelpath=lf, tunnelname=os.path.split(f[:-4])[1])
tunnelfile.save()
for tunnelfile in TunnelFile.objects.all():
SetTunnelfileInfo(tunnelfile)
for drawfile in TunnelFile.objects.all():
SetTunnelfileInfo(drawfile)