summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parsers/caves.py16
-rw-r--r--parsers/survex.py12
2 files changed, 20 insertions, 8 deletions
diff --git a/parsers/caves.py b/parsers/caves.py
index e66b46a..ced0aea 100644
--- a/parsers/caves.py
+++ b/parsers/caves.py
@@ -24,13 +24,14 @@ def readcaves():
print (" - Setting pending caves")
# Do this first, so that these empty entries are overwritten as they get properly created.
+
# For those caves which do not have XML files even though they exist and have surveys
# also needs to be done *before* entrances so that the entrance-cave links work properly.
- forgotten = ["2007-04", "2007-05", "2007-06", "2007-07", "2007-12", "2009-01", "2009-02",
+ pending = ["2007-04", "2007-05", "2007-06", "2007-07", "2007-12", "2009-01", "2009-02",
"2010-06", "2010-07", "2012-ns-01", "2012-ns-02", "2010-04", "2012-ns-05", "2012-ns-06",
"2012-ns-07", "2012-ns-08", "2012-ns-12", "2012-ns-14", "2012-ns-15", "2014-bl888",
"2018-pf-01", "2018-pf-02", "haldenloch", "gruenstein"]
- for k in forgotten:
+ for k in pending:
try:
cave = models_caves.Cave(
unofficial_number = k,
@@ -44,8 +45,19 @@ def readcaves():
message = " ! {:11s} {}".format(cave.unofficial_number, cave.underground_description)
DataIssue.objects.create(parser='caves', message=message)
print(message)
+
+ try: # Now create a slug ID
+ cs = models_caves.CaveSlug.objects.update_or_create(cave = cave,
+ slug = "PENDING-" + k,
+ primary = False)
+ except:
+ message = " ! {:11s} {} PENDING cave slug create failure".format(k)
+ DataIssue.objects.create(parser='caves', message=message)
+ print(message)
else:
print("Failed to create cave {} ".format(k))
+
+
except:
message = " ! Error. Cannot create pending cave, pending-id:{}".format(k)
DataIssue.objects.create(parser='caves', message=message)
diff --git a/parsers/survex.py b/parsers/survex.py
index 19b8466..a8eb401 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -3,10 +3,10 @@ import os
import re
import time
import copy
+import subprocess
from pathlib import Path
from datetime import datetime, timedelta
-from subprocess import call, run
from django.utils.timezone import get_current_timezone
from django.utils.timezone import make_aware
@@ -1076,7 +1076,7 @@ class LoadingSurvex():
def runcavern():
print(" - Regenerating stale (or chaos-monkeyed) cavern .log and .3d for '{}'\n days svx old: {:.1f} cav:{:.1f} log old: {:.1f}".
format(fullpath, (svx_t - log_t)/(24*3600), (cav_t - log_t)/(24*3600), (now - log_t)/(24*3600)))
- call([settings.CAVERN, "--log", "--output={}".format(fullpath), "{}.svx".format(fullpath)])
+ subprocess.call([settings.CAVERN, "--log", "--output={}".format(settings.THREEDCACHEDIR), "{}.svx".format(fullpath)])
svxpath = fullpath + ".svx"
logpath = fullpath + ".log"
@@ -1086,7 +1086,7 @@ class LoadingSurvex():
return
if not self.caverndate:
- completed_process = run(["which", "{}".format(settings.CAVERN)],
+ completed_process = subprocess.run(["which", "{}".format(settings.CAVERN)],
capture_output=True, check=True, text=True)
self.caverndate = os.path.getmtime(completed_process.stdout.strip())
cav_t = self.caverndate
@@ -1252,10 +1252,10 @@ def LoadPositions():
def runcavern3d():
print(" - Regenerating stale cavern .log and .3d for '{}'\n days old: {:.1f} {:.1f} {:.1f}".
format(topdata, (svx_t - d3d_t)/(24*3600), (cav_t - d3d_t)/(24*3600), (now - d3d_t)/(24*3600)))
- call([settings.CAVERN, "--log", "--output={}".format(topdata), "{}.svx".format(topdata)])
+ subprocess.call([settings.CAVERN, "--log", "--output={}".format(topdata), "{}.svx".format(topdata)])
print(" - Regenerating {} {}.3d in {}".format(settings.SURVEXPORT, topdata, settings.SURVEX_DATA))
- call([settings.SURVEXPORT, '--pos', '{}.3d'.format(topdata)], cwd = settings.SURVEX_DATA)
+ subprocess.call([settings.SURVEXPORT, '--pos', '{}.3d'.format(topdata)], cwd = settings.SURVEX_DATA)
topdata = os.fspath(Path(settings.SURVEX_DATA) / settings.SURVEX_TOPNAME)
print((' - Generating a list of Pos from %s.svx and then loading...' % (topdata)))
@@ -1265,7 +1265,7 @@ def LoadPositions():
print("\n") # extra line because cavern overwrites the text buffer somehow
# cavern defaults to using same cwd as supplied input file
- completed_process = run(["which", "{}".format(settings.CAVERN)],
+ completed_process = subprocess.run(["which", "{}".format(settings.CAVERN)],
capture_output=True, check=True, text=True)
cav_t = os.path.getmtime(completed_process.stdout.strip())