mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-16 03:27:10 +00:00
Imports in control panel work again
This commit is contained in:
@@ -15,7 +15,8 @@ import troggle.parsers.surveys
|
||||
import troggle.parsers.logbooks
|
||||
import troggle.parsers.QMs
|
||||
|
||||
'''Master data importUsed only by databaseReset.py currently
|
||||
'''Master data import.
|
||||
Used only by databaseReset.py and online controlpanel.
|
||||
'''
|
||||
|
||||
def import_caves():
|
||||
@@ -46,9 +47,9 @@ def import_QMs():
|
||||
|
||||
def import_survex():
|
||||
# when this import is moved to the top with the rest it all crashes horribly
|
||||
print("-- Importing Survex and Entrance Positions")
|
||||
with transaction.atomic():
|
||||
import troggle.parsers.survex
|
||||
print("-- Importing Survex and Entrance Positions")
|
||||
print(" - Survex Blocks")
|
||||
with transaction.atomic():
|
||||
troggle.parsers.survex.LoadSurvexBlocks()
|
||||
|
||||
@@ -124,6 +124,7 @@ def load_people_expos():
|
||||
lookupAttribs = {'person':person, 'expedition':expedition}
|
||||
nonLookupAttribs = {'nickname':nickname, 'is_guest':(personline[header["Guest"]] == "1")}
|
||||
save_carefully(PersonExpedition, lookupAttribs, nonLookupAttribs)
|
||||
print("", flush=True)
|
||||
|
||||
|
||||
# used in other referencing parser functions
|
||||
|
||||
@@ -14,8 +14,10 @@ from troggle.core.models.survex import SingleScan, Wallet, DrawingFile
|
||||
from troggle.core.models.troggle import DataIssue
|
||||
from troggle.core.utils import save_carefully
|
||||
|
||||
'''Scans through all the :drawings: repository looking
|
||||
'''Searches through all the :drawings: repository looking
|
||||
for tunnel and therion files
|
||||
|
||||
Searches through all the survey scans directories in expofiles, looking for images to be referenced.
|
||||
'''
|
||||
|
||||
|
||||
@@ -41,7 +43,7 @@ def listdir(*directories):
|
||||
return [folder.rstrip(r"/") for folder in folders]
|
||||
|
||||
|
||||
# handles url or file, so we can refer to a set of scans on another server
|
||||
# handles url or file, so we can refer to a set of scans (not drawings) on another server
|
||||
def GetListDir(sdir):
|
||||
res = [ ]
|
||||
if sdir[:7] == "http://":
|
||||
@@ -80,7 +82,7 @@ def LoadListScansFile(wallet):
|
||||
|
||||
# this iterates through the scans directories (either here or on the remote server)
|
||||
# and builds up the models we can access later
|
||||
def LoadListScans():
|
||||
def load_all_scans():
|
||||
|
||||
print(' - Loading Survey Scans')
|
||||
|
||||
@@ -116,17 +118,18 @@ def LoadListScans():
|
||||
wallet = Wallet(fpath=ff, walletname=f)
|
||||
wallet.save()
|
||||
LoadListScansFile(wallet)
|
||||
|
||||
|
||||
def find_tunnel_scan(dwgfile, path):
|
||||
print("", flush=True)
|
||||
|
||||
def find_tunnel_file(dwgfile, path):
|
||||
'''Is given a line of text 'path' which may or may not contain a recognisable name of a scanned file
|
||||
which we have already seen when we imported all the files we could find in the surveyscans direstories
|
||||
'''
|
||||
wallet, scansfile = None, None
|
||||
mscansdir = re.search(r"(\d\d\d\d#X?\d+\w?|1995-96kh|92-94Surveybookkh|1991surveybook|smkhs)/(.*?(?:png|jpg|pdf|jpeg))$", path)
|
||||
mscansdir = re.search(r"(\d\d\d\d#X?\d+\w?|1995-96kh|92-94Surveybookkh|1991surveybook|smkhs)/(.*?(?:png|jpg|pdf|jpeg|gif))$", path)
|
||||
if mscansdir:
|
||||
scanswalletl = Wallet.objects.filter(walletname=mscansdir.group(1))
|
||||
# This should properly detect if a list of folders is returned and do something sensible, not just pick the first.
|
||||
# This should be chnaged to properly detect if a list of folders is returned and do something sensible, not just pick the first.
|
||||
if len(scanswalletl):
|
||||
wallet = scanswalletl[0]
|
||||
if len(scanswalletl) > 1:
|
||||
@@ -148,7 +151,7 @@ def find_tunnel_scan(dwgfile, path):
|
||||
if scansfile:
|
||||
dwgfile.scans.add(scansfile)
|
||||
|
||||
elif path and not re.search(r"\.(?:png|jpg|pdf|jpeg|gif|pdf)$(?i)", path):
|
||||
elif path and not re.search(r"\.(?:png|jpg|pdf|jpeg|gif)$(?i)", path):
|
||||
name = os.path.split(path)[1]
|
||||
rdwgfilel = DrawingFile.objects.filter(dwgname=name)
|
||||
if len(rdwgfilel):
|
||||
@@ -248,7 +251,7 @@ def setdwgfileinfo(dwgfile):
|
||||
# <pcarea area_signal="frame" sfscaledown="12.282584" sfrotatedeg="-90.76982" sfxtrans="11.676667377221136" sfytrans="-15.677173422877454" sfsketch="204description/scans/plan(38).png" sfstyle="" nodeconnzsetrelative="0.0">
|
||||
|
||||
for path, style in rx_pcpath.findall(ttext):
|
||||
find_tunnel_scan(dwgfile, path.decode())
|
||||
find_tunnel_file(dwgfile, path.decode())
|
||||
|
||||
# should also scan and look for survex blocks that might have been included, and image scans
|
||||
# which would populate dwgfile.survexfile
|
||||
|
||||
Reference in New Issue
Block a user