summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2022-02-25 18:33:34 +0000
committerPhilip Sargent <philip.sargent@klebos.com>2022-02-25 18:33:34 +0000
commit7f542b8936c6690f82b807fb81b3f87213ea96bf (patch)
tree4a7e3e95749d0b0dc6a2796a2fb3fa34875d163a
parent2c13c1b5f3d765017468e762082bc693df800278 (diff)
downloadtroggle-7f542b8936c6690f82b807fb81b3f87213ea96bf.tar.gz
troggle-7f542b8936c6690f82b807fb81b3f87213ea96bf.tar.bz2
troggle-7f542b8936c6690f82b807fb81b3f87213ea96bf.zip
LIBDIR automatically gets right python version
-rw-r--r--_deploy/wsl/localsettingsWSL.py25
-rw-r--r--core/views/statistics.py4
-rw-r--r--templates/pathsreport.html4
3 files changed, 20 insertions, 13 deletions
diff --git a/_deploy/wsl/localsettingsWSL.py b/_deploy/wsl/localsettingsWSL.py
index ac2fa2d..a74561c 100644
--- a/_deploy/wsl/localsettingsWSL.py
+++ b/_deploy/wsl/localsettingsWSL.py
@@ -15,6 +15,7 @@ a system-wide location rather than just a local directory.
This file is included at the end of the main troggle/settings.py file so that
it overwrites defaults in that file.
+Read https://realpython.com/python-pathlib/
Read https://adamj.eu/tech/2020/03/16/use-pathlib-in-your-django-project/
"""
@@ -37,19 +38,24 @@ EXPOFILESREMOTE = False # if True, then re-routes urls in expofiles to remote se
SERVERPORT = '8000' # not needed
+PV = "python" + str(sys.version_info.major) + "." + str(sys.version_info.minor)
+
+# Troggle does a lot of file-handling. This is very error-prone when using primitive methods,
+# so we use pathlib which has been standard since python 3.4
+# If oathlib is new to you, you will need to read https://realpython.com/python-pathlib/
+
# --------------------- MEDIA redirections BEGIN ---------------------
-#REPOS_ROOT_PATH = '/mnt/d/CUCC-Expo/t37/'
-REPOS_ROOT_PATH = Path(__file__).parent.parent # We are assuming all 4 repos are siblings.
-version = sys.version_info
-#LIBDIR = REPOS_ROOT_PATH / 'lib' / 'python{}.{}'.format(version.major, version.minor) # eg python 3.7
+REPOS_ROOT_PATH = Path(__file__).parent.parent
+LIBDIR = REPOS_ROOT_PATH / 'lib' / PV
+#LIBDIR = REPOS_ROOT_PATH / 'lib' / 'python3.7' # should be finding this automatically: python --version etc.
TROGGLE_PATH = Path(__file__).parent
TEMPLATE_PATH = TROGGLE_PATH / 'templates'
MEDIA_ROOT = TROGGLE_PATH / 'media'
JSLIB_ROOT = TROGGLE_PATH / 'media' / 'jslib' # used for CaveViewer JS utility
-FILES = Path('/mnt/c/EXPO/expofiles/')
-EXPOFILES = Path('/mnt/c/EXPO/expofiles/')
+FILES = Path('/mnt/f/expofiles/')
+EXPOFILES = Path('/mnt/f/expofiles/')
SURVEY_SCANS = EXPOFILES / 'surveyscans'
PHOTOS_ROOT = EXPOFILES / 'photos'
@@ -117,7 +123,7 @@ TEMPLATES = [
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media', # includes a variable MEDIA_URL
- 'django.template.context_processors.static', # includes a variable STATIC_URL
+ 'django.template.context_processors.static', # includes a variable STATIC_URL used by admin pages
'django.template.context_processors.tz',
'django.template.context_processors.request', # must be enabled in DjangoTemplates (TEMPLATES) in order to use the admin navigation sidebar.
'django.contrib.messages.context_processors.messages',
@@ -144,7 +150,6 @@ EMAIL_HOST_USER = "django-test@klebos.net" # Philip Sargent really
EMAIL_PORT=587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'django-test@klebos.net'
-EMAIL_SUBJECT_PREFIX = "[troggle]"
SURVEX_DATA = REPOS_ROOT_PATH / "loser"
DRAWINGS_DATA = REPOS_ROOT_PATH / "drawings"
@@ -165,12 +170,10 @@ LOGFILE = os.fspath(LOGFILE)
SURVEYS = os.fspath(SURVEYS)
EXPOWEB = os.fspath(EXPOWEB)
THREEDCACHEDIR = os.fspath(THREEDCACHEDIR)
-DRAWINGS_DATA = os.fspath(DRAWINGS_DATA)
+DRAWINGS_DATA = os.fspath(DRAWINGS_DATA)
SURVEX_DATA = os.fspath(SURVEX_DATA)
REPOS_ROOT_PATH = os.fspath(REPOS_ROOT_PATH)
TEMPLATE_PATH = os.fspath(TROGGLE_PATH)
MEDIA_ROOT = os.fspath(MEDIA_ROOT)
JSLIB_ROOT = os.fspath(JSLIB_ROOT)
-JSLIB_ROOT = os.fspath(JSLIB_ROOT)
-JSLIB_ROOT = os.fspath(JSLIB_ROOT)
SURVEY_SCANS = os.fspath(SURVEY_SCANS)
diff --git a/core/views/statistics.py b/core/views/statistics.py
index f4209c3..054c3a4 100644
--- a/core/views/statistics.py
+++ b/core/views/statistics.py
@@ -38,7 +38,7 @@ def pathsreport(request):
"EXPOWEB" : str( settings.EXPOWEB),
"EXPOWEB_URL" : str( settings.EXPOWEB_URL),
"FILES" : str( settings.FILES),
-# "LIBDIR" : str( settings.LIBDIR),
+ "LIBDIR" : str( settings.LIBDIR),
"LOGFILE" : str( settings.LOGFILE),
"LOGIN_REDIRECT_URL" : str( settings.LOGIN_REDIRECT_URL),
"MEDIA_ROOT" : str( settings.MEDIA_ROOT),
@@ -76,7 +76,7 @@ def pathsreport(request):
"EXPOWEB" : type(settings.EXPOWEB),
"EXPOWEB_URL" : type(settings.EXPOWEB_URL),
"FILES" : type(settings.FILES),
-# "LIBDIR" : type( settings.LIBDIR),
+ "LIBDIR" : type( settings.LIBDIR),
"LOGFILE" : type(settings.LOGFILE),
"LOGIN_REDIRECT_URL" : type(settings.LOGIN_REDIRECT_URL),
"MEDIA_ROOT" : type(settings.MEDIA_ROOT),
diff --git a/templates/pathsreport.html b/templates/pathsreport.html
index d977c6b..300b284 100644
--- a/templates/pathsreport.html
+++ b/templates/pathsreport.html
@@ -40,5 +40,9 @@
</table>
<p>
There are {{ ncodes }} different path codes defined.
+<p>This report is generated from <code>templates/pathsreport.html</code> and
+by <code>pathsreport(request)</code> in <code>core/views/statistics.py </code>
+<hr>
+<p>Go to <a href="/handbook/troggle/trogmanual.html">Troggle maintenance manuals</a>
{% endblock %}