Make .3d files in same dir as .svx

This commit is contained in:
Philip Sargent 2022-03-06 01:29:45 +00:00
parent 7a58aac08e
commit 3ac617431f
7 changed files with 46 additions and 19 deletions

View File

@ -108,7 +108,7 @@ class PostTests(TestCase):
def test_dwg_upload_txt(self): def test_dwg_upload_txt(self):
'''Expect .txt file to be refused upload '''Expect .pdf file to be refused upload
Need to login first. Need to login first.
''' '''
c = self.client c = self.client
@ -118,7 +118,7 @@ class PostTests(TestCase):
self.assertTrue(u.is_active, 'User \'' + u.username + '\' is INACTIVE') self.assertTrue(u.is_active, 'User \'' + u.username + '\' is INACTIVE')
logged_in = c.login(username=u.username, password='secretword') logged_in = c.login(username=u.username, password='secretword')
with open('core/fixtures/test_upload_file.txt','r') as testf: with open('core/fixtures/test_upload_file.pdf','r') as testf:
response = self.client.post('/dwgupload/uploads', data={'name': 'test_upload_file.txt', 'uploadfiles': testf }) response = self.client.post('/dwgupload/uploads', data={'name': 'test_upload_file.txt', 'uploadfiles': testf })
content = response.content.decode() content = response.content.decode()
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)

View File

@ -0,0 +1,5 @@
This file is uploaded by the integration test suite as part of the tests.
It, and any other with similar names, e.g test_upload_GPev9qN.txt can be safely deleted,
EXCEPT for the original copy which lives in troggle/core/fixtures/

View File

@ -3,7 +3,8 @@ import os
import datetime import datetime
import re import re
import json import json
from subprocess import call import subprocess
from collections import defaultdict from collections import defaultdict
from pathlib import Path from pathlib import Path
@ -56,8 +57,15 @@ def writetrogglefile(filepath, filecontent):
f.write(filecontent) f.write(filecontent)
#os.chmod(filepath, 0o664) # set file permissions to rw-rw-r-- #os.chmod(filepath, 0o664) # set file permissions to rw-rw-r--
# should replace .call with .run and capture_output=True # should replace .call with .run and capture_output=True
call([git, "add", filename], cwd=cwd) sp = subprocess.run([git, "add", filename], cwd=cwd, capture_output=True, check=True, text=True)
call([git, "commit", "-m", f'Troggle online: cave or entrance edit -{filename}'], cwd=cwd) if sp.returncode != 0:
print(f'git ADD {cwd}:\n\n' + str(sp.stderr) + '\n\n' + str(sp.stdout) + '\n\nreturn code: ' + str(sp.returncode))
sp = subprocess.run([git, "commit", "-m", f'Troggle online: cave or entrance edit -{filename}'], cwd=cwd, capture_output=True, check=True, text=True)
if sp.returncode != 0:
print(f'git COMMIT {cwd}:\n\n' + str(sp.stderr) + '\n\n' + str(sp.stdout) + '\n\nreturn code: ' + str(sp.returncode))
# not catching and re-raising any exceptions yet, inc. the stderr etc.,. We should do that.
class Area(TroggleModel): class Area(TroggleModel):

View File

@ -53,7 +53,6 @@ def pathsreport(request):
"SURVEYS" : str( settings.SURVEYS), "SURVEYS" : str( settings.SURVEYS),
"SURVEYS_URL" : str( settings.SURVEYS_URL), "SURVEYS_URL" : str( settings.SURVEYS_URL),
"SURVEXPORT" : str( settings.SURVEXPORT), "SURVEXPORT" : str( settings.SURVEXPORT),
"THREEDCACHEDIR" : str( settings.THREEDCACHEDIR),
"DRAWINGS_DATA" : str( settings.DRAWINGS_DATA), "DRAWINGS_DATA" : str( settings.DRAWINGS_DATA),
"URL_ROOT" : str( settings.URL_ROOT) "URL_ROOT" : str( settings.URL_ROOT)
} }
@ -91,7 +90,6 @@ def pathsreport(request):
"SURVEYS" : type(settings.SURVEYS), "SURVEYS" : type(settings.SURVEYS),
"SURVEYS_URL" : type(settings.SURVEYS_URL), "SURVEYS_URL" : type(settings.SURVEYS_URL),
"SURVEXPORT" : type(settings.SURVEXPORT), "SURVEXPORT" : type(settings.SURVEXPORT),
"THREEDCACHEDIR" : type(settings.THREEDCACHEDIR),
"DRAWINGS_DATA" : type(settings.DRAWINGS_DATA), "DRAWINGS_DATA" : type(settings.DRAWINGS_DATA),
"URL_ROOT" : type(settings.URL_ROOT) "URL_ROOT" : type(settings.URL_ROOT)
} }

View File

@ -1205,9 +1205,13 @@ class LoadingSurvex():
# see design docum in troggle/templates/cave.html # see design docum in troggle/templates/cave.html
# and views/caves.py rendercave() # and views/caves.py rendercave()
''' '''
print(" - Regenerating stale (or chaos-monkeyed) cavern .log and .3d for '{}'\n at '{}'\n days svx old: {:.1f} cav:{:.1f} log old: {:.1f}".format(fullpath, logpath, (svx_t - log_t)/(24*3600), (cav_t - log_t)/(24*3600), (now - log_t)/(24*3600))) print(f" - Regenerating stale (or chaos-monkeyed) cavern .log and .3d for '{fullpath}'\n at '{logpath}'\n")
#print(f' - cav_t: {cav_t/(24*3600)} - log_t: {log_t/(24*3600)} - svx_t: {svx_t/(24*3600)} - now: {now}') print(f"days svx old: {(svx_t - log_t)/(24*3600):.1f} cav:{(cav_t - log_t)/(24*3600):.1f} log old: { (now - log_t)/(24*3600):.1f}")
subprocess.call([settings.CAVERN, "--log", "--output={}".format(settings.THREEDCACHEDIR), "{}.svx".format(fullpath)])
outputdir = Path(str(f'{fullpath}.svx')).parent
sp = subprocess.run([settings.CAVERN, "--log", f'--output={outputdir}', f'{fullpath}.svx'])
if sp.returncode != 0:
print(f'fullpath: {fullpath}:\n\n' + str(sp.stderr) + '\n\n' + str(sp.stdout) + '\n\nreturn code: ' + str(sp.returncode))
self.caverncount += 1 self.caverncount += 1
# should also collect all the .err files too and create a DataIssue for each one which # should also collect all the .err files too and create a DataIssue for each one which
@ -1215,7 +1219,8 @@ class LoadingSurvex():
# - has Error greater than 5% anywhere, or some other more serious error # - has Error greater than 5% anywhere, or some other more serious error
svxpath = fullpath + ".svx" svxpath = fullpath + ".svx"
logpath = Path(settings.THREEDCACHEDIR) / str(Path(fullpath).name + ".log") logpath = fullpath + ".log"
outputdir = Path(svxpath).parent
if not os.path.isfile(logpath): if not os.path.isfile(logpath):
runcavern() runcavern()
@ -1412,15 +1417,28 @@ def LoadPositions():
svx_t = 0 svx_t = 0
d3d_t = 0 d3d_t = 0
def runcavern3d(): def runcavern3d():
outputdir = Path(str(f'{topdata}.svx')).parent
# print(" - Regenerating stale cavern .log and .3d for '{}'\n days old: {:.1f} {:.1f} {:.1f}". # 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))) # format(topdata, (svx_t - d3d_t)/(24*3600), (cav_t - d3d_t)/(24*3600), (now - d3d_t)/(24*3600)))
subprocess.call([settings.CAVERN, "--log", "--output={}".format(topdata), "{}.svx".format(topdata)]) # subprocess.call([settings.CAVERN, "--log", f"--output={topdata}", f"{topdata}.svx"])
try:
# print(" - Regenerating {} {}.3d in {}".format(settings.SURVEXPORT, topdata, settings.SURVEX_DATA)) sp = subprocess.run([settings.CAVERN, "--log", f"--output={outputdir}", f"{topdata}.svx"],
subprocess.call([settings.SURVEXPORT, '--pos', '{}.3d'.format(topdata)], cwd = settings.SURVEX_DATA) capture_output=True, check=True, text=True)
if sp.returncode != 0:
print(f'topdata: {topdata}:\n\n' + str(sp.stderr) + '\n\n' + str(sp.stdout) + '\n\nreturn code: ' + str(sp.returncode))
# print(" - Regenerating {} {}.3d in {}".format(settings.SURVEXPORT, topdata, settings.SURVEX_DATA))
sp = subprocess.run([settings.SURVEXPORT, '--pos', f'{topdata}.3d'], cwd = settings.SURVEX_DATA,
capture_output=True, check=True, text=True)
if sp.returncode != 0:
print(f'topdata: {topdata}:\n\n' + str(sp.stderr) + '\n\n' + str(sp.stdout) + '\n\nreturn code: ' + str(sp.returncode))
except:
print(f'topdata: {topdata}:\n\n' + str(sp.stderr) + '\n\n' + str(sp.stdout) + '\n\nreturn code: ' + str(sp.returncode))
topdata = os.fspath(Path(settings.SURVEX_DATA) / settings.SURVEX_TOPNAME) topdata = os.fspath(Path(settings.SURVEX_DATA) / settings.SURVEX_TOPNAME)
print((' - Generating a list of Pos from %s.svx and then loading...' % (topdata))) print(' - Generating a list of Pos from %s.svx and then loading...' % (topdata))
found = 0 found = 0
skip = {} skip = {}

View File

@ -11,8 +11,7 @@
<li><form name=P method=get action="/search" target="_top"> <li><form name=P method=get action="/search" target="_top">
<input id="omega-autofocus" type=search name=P size=8 autofocus> <input id="omega-autofocus" type=search name=P size=8 autofocus>
<input type=submit value="Search"></li> <input type=submit value="Search"></li>
{% if editable %}<li><a href="{% url "editexpopage" path %}" class="editlink"><strong>Edit this page</strong></a></li> {% if editable %}<li><a href="{% url "editexpopage" path %}" class="editlink"><strong>Edit this page</strong></a></li>{% endif %}
{% else %}<a href="/handbook/computing/hbmanual1.html#auto">This page not editable</a></li>{% endif %}
{% if cave_editable %}<li><a href="{% url "edit_cave" cave.slug %}" class="editlink"><strong>Edit this cave</strong></a></li>{% endif %} {% if cave_editable %}<li><a href="{% url "edit_cave" cave.slug %}" class="editlink"><strong>Edit this cave</strong></a></li>{% endif %}
</ul> </ul>
{% endif %} {% endif %}

View File

@ -181,7 +181,6 @@ trogglepatterns = [
re_path(r'^site_media/(?P<subpath>.*)$', mediapage, {'doc_root': settings.MEDIA_ROOT}, name="mediapage"), # MEDIA_ROOT: CSS and JS re_path(r'^site_media/(?P<subpath>.*)$', mediapage, {'doc_root': settings.MEDIA_ROOT}, name="mediapage"), # MEDIA_ROOT: CSS and JS
re_path(r'^static/(?P<subpath>.*)$', mediapage, {'doc_root': settings.MEDIA_ROOT}, name="mediapage"), # STATIC only used by admin pages re_path(r'^static/(?P<subpath>.*)$', mediapage, {'doc_root': settings.MEDIA_ROOT}, name="mediapage"), # STATIC only used by admin pages
path('javascript/<path:subpath>', mediapage, {'doc_root': settings.JSLIB_ROOT}, name="mediapage"), # JSLIB_URL path('javascript/<path:subpath>', mediapage, {'doc_root': settings.JSLIB_ROOT}, name="mediapage"), # JSLIB_URL
re_path(r'^expowebcache/3d/(?P<subpath>.*)$', mediapage, {'doc_root': settings.THREEDCACHEDIR}, name="mediapage"),
re_path(r'^/loser/(?P<subpath>.*)$', mediapage, {'doc_root': settings.SURVEX_DATA}, name="mediapage"), # Oddly not working !? re_path(r'^/loser/(?P<subpath>.*)$', mediapage, {'doc_root': settings.SURVEX_DATA}, name="mediapage"), # Oddly not working !?
re_path(r'^map/map.html', map, name="map"), # Redirects to OpenStreetMap JavaScript re_path(r'^map/map.html', map, name="map"), # Redirects to OpenStreetMap JavaScript