2020-05-27 01:04:37 +01:00
|
|
|
Troggle is an application for caving expedition data management,
|
|
|
|
originally created for use on Cambridge University Caving Club (CUCC)expeditions
|
|
|
|
and licensed under the GNU Lesser General Public License.
|
2014-09-10 23:46:05 +01:00
|
|
|
|
2020-05-27 01:04:37 +01:00
|
|
|
Troggle has been forked into two projects. The original one is maintained by Aron Curtis
|
2021-03-24 20:38:43 +00:00
|
|
|
and was used for Erebus caves. The CUCC variant uses files as the definitive data,
|
2020-05-27 01:04:37 +01:00
|
|
|
not the database and lives at http://expo.survex.com/repositories/troggle/.git/
|
2011-07-11 02:10:22 +01:00
|
|
|
|
2020-07-26 02:26:04 +01:00
|
|
|
See copyright notices in
|
|
|
|
http://expo.survex.com/handbook/computing/contribute.html
|
|
|
|
|
2021-03-22 02:26:11 +00:00
|
|
|
See online documentation at http://expo.survex.com/handbook/troggle/serverconfig.html
|
|
|
|
and at troggle/debian/serversetup .
|
|
|
|
|
2011-07-11 02:10:22 +01:00
|
|
|
Troggle setup
|
2020-05-27 01:04:37 +01:00
|
|
|
=============
|
|
|
|
1. git clone troggle into correct directory structure
|
|
|
|
2. install pip, django & patch django
|
|
|
|
3. configure django to recognise troggle
|
|
|
|
|
|
|
|
Setting up directories
|
|
|
|
----------------------
|
|
|
|
- create a directory in which you also have the loser/, expoweb/ and drawings/ repositories
|
|
|
|
- git clone (see below) the current latest troggle from the 'python3' git branch into
|
|
|
|
a folder called 'troggle'
|
2021-03-24 00:55:36 +00:00
|
|
|
- all the 4 repos should now be siblings, and also siblings with expofiles/ and expowebcache/
|
2020-05-27 01:04:37 +01:00
|
|
|
- if you have those repos elsewhere, set up symlinks in the directory above troggle
|
|
|
|
so that troggle thinks they are siblings
|
2011-07-11 02:10:22 +01:00
|
|
|
|
2020-05-27 01:04:37 +01:00
|
|
|
Troggle itself
|
|
|
|
-------------
|
|
|
|
Choose the directory where you will keep troggle, (which must be named "troggle")
|
|
|
|
and git clone troggle into it using the following command:
|
|
|
|
|
|
|
|
git clone git://expo.survex.com/troggle
|
|
|
|
or more reliably
|
|
|
|
git clone ssh://expo@expo.survex.com/home/expo/troggle
|
|
|
|
but you will have to set up the ssh key-exchange with the server to make that work.
|
|
|
|
Key-exchange instructions: http://expo.survex.com/handbook/computing/keyexchange.html
|
|
|
|
|
|
|
|
If you want to work on the source code and be able to commit, your account will need to be
|
|
|
|
added to the troggle project members list. Contact wookey at wookware dot org to get this set up.
|
|
|
|
|
|
|
|
Next, you need to fill in your local settings. Copy localsettingsWSL.py
|
|
|
|
to a new file called localsettings.py and edit it and settings.py to match
|
|
|
|
your machine's file locations.
|
|
|
|
Follow the instructions contained in the file to fill out your settings.
|
|
|
|
|
|
|
|
{ *TO BE FIXED*
|
|
|
|
The localsettings-expo-live.py is the python2.7 settings for the server.
|
|
|
|
These are all very out of date and need fixing:
|
|
|
|
localsettingsubuntu.py
|
|
|
|
localsettingsdocker.py
|
|
|
|
localsettingswindows.py
|
|
|
|
localsettingspotatohut.py
|
|
|
|
}
|
|
|
|
|
|
|
|
Python3, Django, and Database setup
|
2011-07-11 02:10:22 +01:00
|
|
|
-----------------------------------
|
2021-03-24 20:38:43 +00:00
|
|
|
First version of troggle using python3 required Django 1.8.19 (16 June 2019)
|
2020-07-28 01:46:00 +01:00
|
|
|
We are now using Django 1.11.29
|
2020-04-26 00:49:29 +01:00
|
|
|
|
2020-05-27 01:04:37 +01:00
|
|
|
Read this: https://docs.djangoproject.com/en/3.0/topics/install/
|
2020-04-26 00:49:29 +01:00
|
|
|
|
2020-07-28 01:46:00 +01:00
|
|
|
We are installing with python3.7.5
|
2020-05-27 01:04:37 +01:00
|
|
|
Also : https://linuxize.com/post/how-to-install-pip-on-ubuntu-20.04/ ]
|
|
|
|
|
2021-03-24 20:38:43 +00:00
|
|
|
Install Django using pip, not with apt, on your test system.
|
2020-05-27 01:04:37 +01:00
|
|
|
Your Linux installation almost certainly already includes python3 and pip3 but
|
|
|
|
in case it doesn't install those like this:
|
|
|
|
|
|
|
|
$ sudo apt update
|
|
|
|
$ sudo apt dist-upgrade
|
|
|
|
$ sudo apt install python3
|
|
|
|
$ sudo apt install python3-pip
|
|
|
|
|
|
|
|
Now install django etc.
|
|
|
|
$ sudo pip3 install -r requirements.txt
|
|
|
|
|
2020-07-28 01:46:00 +01:00
|
|
|
where requirements.txt is:
|
|
|
|
confusable-homoglyphs==3.2.0
|
|
|
|
Django==1.11.29
|
|
|
|
django-registration==2.5.2
|
|
|
|
docutils==0.16
|
2020-05-27 01:04:37 +01:00
|
|
|
Pillow==7.1.2
|
2020-07-28 01:46:00 +01:00
|
|
|
pytz==2020.1
|
2020-06-17 01:00:50 +01:00
|
|
|
sqlparse==0.3.1
|
2020-05-27 01:04:37 +01:00
|
|
|
Unidecode==1.1.1
|
|
|
|
|
|
|
|
if you don't use sudo it will install them all in ~/.local/
|
|
|
|
and so will only be available for you, not everyone; and
|
|
|
|
the paths won't work to find troggle properly.
|
2011-07-11 02:10:22 +01:00
|
|
|
|
2020-07-28 01:46:00 +01:00
|
|
|
Unidecode handle some of the python2-3 conversions
|
2020-05-27 01:04:37 +01:00
|
|
|
and Pillow is an image handling package used to make
|
|
|
|
the prospecting map. tinymce is the wysiwyg in-browser
|
2020-07-28 01:46:00 +01:00
|
|
|
editor (disabled pending reinstatement)
|
2020-05-27 01:04:37 +01:00
|
|
|
|
2020-06-17 01:00:50 +01:00
|
|
|
$ pip3 list -o
|
2020-05-27 01:04:37 +01:00
|
|
|
will list all the pip python packages installed.
|
|
|
|
|
|
|
|
[NB we should test whether later verisons of tinymce work.]
|
|
|
|
|
|
|
|
venv option
|
|
|
|
-----------
|
2020-05-24 13:35:47 +01:00
|
|
|
Or use a python3 virtual environment: (python3.5 not later)
|
2020-05-22 01:28:45 +01:00
|
|
|
$ cd troggle
|
|
|
|
$ cd ..
|
2020-05-24 13:35:47 +01:00
|
|
|
$ python3.5 -m venv pyth35d2
|
2020-05-22 01:28:45 +01:00
|
|
|
(creates folder with virtual env)
|
2020-05-27 01:04:37 +01:00
|
|
|
$ cd pyth35d2
|
|
|
|
$ source bin/activate
|
|
|
|
(now install everything )
|
2020-05-22 01:28:45 +01:00
|
|
|
$ pip install -r requirements.txt
|
|
|
|
|
2020-05-27 01:04:37 +01:00
|
|
|
This works if you need a specific version of python3
|
|
|
|
but doesn't really work with python2.7 as you also need to obtain
|
|
|
|
an elderly version of pip that will work and use and older virtual
|
|
|
|
environment utility
|
|
|
|
|
|
|
|
Testing the django installation
|
|
|
|
-------------------------------
|
|
|
|
Test things by running these commands:
|
|
|
|
$ django-admin --version
|
|
|
|
$ django-admin
|
|
|
|
It should show a list of commands and complain:
|
|
|
|
"..only Django core commands are listed as settings are not properly configured"
|
|
|
|
|
|
|
|
If you get an error when running
|
|
|
|
$ django-admin
|
|
|
|
Then run django-admin like this:
|
|
|
|
python /usr/local/lib/python3.8/dist-packages/django/bin/django-admin.py
|
|
|
|
which should fix the paths. From now on you should be able to run
|
|
|
|
$ django-admin
|
|
|
|
from within any folder on your machine.
|
|
|
|
|
|
|
|
Now do
|
|
|
|
$ cd troggle
|
|
|
|
$ python manage.py
|
2021-03-17 21:09:44 +00:00
|
|
|
$ python manage.py check -v 3 --traceback
|
2020-05-27 01:04:37 +01:00
|
|
|
|
|
|
|
You should see the same list of commands that you saw with django-admin but wth
|
|
|
|
a lot of extra ones and no complaints. This means it is reading at least some of your
|
|
|
|
settings correctly.
|
|
|
|
|
|
|
|
If you get an error your python sys.path is probably not set correctly yet. Do
|
|
|
|
$ python -m site
|
|
|
|
when you are in your troggle directory to see the list of paths python looks
|
|
|
|
for when it is searching for packages (both django and troggle).
|
|
|
|
Ensure that the path to the troggle/ directory is in the list.
|
|
|
|
It should be at the top, which is where the current working directory is.
|
|
|
|
|
2020-06-18 12:10:42 +01:00
|
|
|
Now:
|
|
|
|
python manage.py check -v 3 --deploy
|
|
|
|
which will give security warnings for deployment.
|
|
|
|
|
|
|
|
python manage.py check -Wall
|
2020-06-18 21:50:16 +01:00
|
|
|
Gives warnings of deprecated Django which should be fixed asap.
|
2020-06-18 12:10:42 +01:00
|
|
|
|
2021-03-24 00:55:36 +00:00
|
|
|
python manage.py test core
|
|
|
|
Runs our test suite
|
|
|
|
|
|
|
|
python manage.py test
|
|
|
|
Runs tests for all the django plugins ("apps")
|
|
|
|
|
2020-05-27 01:04:37 +01:00
|
|
|
Registering troggle as a django application
|
|
|
|
-------------------------------------------
|
|
|
|
In your troggle directory run
|
|
|
|
$ django-admin
|
|
|
|
and check you got the same output as before.
|
|
|
|
|
|
|
|
Then try
|
|
|
|
$ python manage.py
|
|
|
|
It may not work. But if it does it will
|
|
|
|
now show a superset of the previous output: the [django] commands
|
|
|
|
available but also other options. Run
|
|
|
|
$ python manage.py check
|
|
|
|
$ python manage.py diffsettings
|
|
|
|
This last one shows everything set in global settings, settings and localsettings.
|
|
|
|
Anything different from global settings (django built-in) has '###' appended.
|
|
|
|
|
|
|
|
$ python manage.py test -v 2
|
|
|
|
Tests that it can create a database from all the model files.
|
|
|
|
|
|
|
|
$ python manage.py migrate
|
|
|
|
Tests the uptodateness of your sqlite database.
|
|
|
|
$ python manage.py help migrate
|
|
|
|
explains what this does and gives extra command line options.
|
|
|
|
|
|
|
|
If you got an error traceback with
|
|
|
|
$ python manage.py
|
|
|
|
then the settings registration of troggle with django is incomplete.
|
|
|
|
Delete all your cached .pyc files and try again.
|
|
|
|
You probably have a mistake in your settings.py or localsettings.py files.
|
|
|
|
|
2020-06-18 21:50:16 +01:00
|
|
|
CSS and media files
|
|
|
|
-------------------
|
|
|
|
Temporarily we are not using the STATICFILES capability but are instead
|
|
|
|
serving css files from troggle/media/.. (see urls.py) using
|
|
|
|
view_surveys.cssfilessingle
|
|
|
|
i.e.
|
|
|
|
cssfilessingle() in core/view_surveys.py
|
2020-06-17 01:00:50 +01:00
|
|
|
|
2020-05-27 01:04:37 +01:00
|
|
|
Setting up survex
|
|
|
|
-----------------
|
2020-07-28 01:46:00 +01:00
|
|
|
You need to have survex installed as the command line tools 'cavern' is
|
2020-05-27 01:04:37 +01:00
|
|
|
used as part of the survex import process.
|
|
|
|
$ sudo apt install survex
|
|
|
|
|
|
|
|
Setting up tables and importing survey data
|
|
|
|
-------------------------------------------
|
|
|
|
Run
|
|
|
|
$ sudo python databaseReset.py
|
|
|
|
from the troggle directory will give you instructions.
|
|
|
|
|
|
|
|
[ NB Adding a new year/expedition requires adding a column to the
|
|
|
|
folk/folk.csv table - a year doesn't exist until that is done.]
|
|
|
|
|
|
|
|
Database
|
|
|
|
--------
|
|
|
|
If you want to use MySQL or Postgresql, download and install them.
|
|
|
|
However, you can also use Django with sqlite3, which is included in Python and thus requires no extra installation.
|
|
|
|
|
2020-05-14 19:37:46 +01:00
|
|
|
MariaDB database
|
|
|
|
----------------
|
|
|
|
Start it up with
|
|
|
|
$ sudo mysql -u -p
|
|
|
|
when it will prompt you to type in the password. Get this by reading the settings.py file in use on the server.
|
|
|
|
then
|
|
|
|
> CREATE DATABASE troggle;
|
|
|
|
> use troggle;
|
|
|
|
> exit;
|
2011-07-11 02:10:22 +01:00
|
|
|
|
2020-05-14 19:37:46 +01:00
|
|
|
Note the semicolons.
|
|
|
|
|
|
|
|
You can check the status of the db service:
|
|
|
|
$ sudo systemctl status mysql
|
|
|
|
|
|
|
|
You can start and stop the db service with
|
|
|
|
$ sudo systemctl restart mysql.service
|
|
|
|
$ sudo systemctl stop mysql.service
|
|
|
|
$ sudo systemctl start mysql.service
|
2011-07-11 02:10:22 +01:00
|
|
|
|
|
|
|
Running a Troggle server
|
|
|
|
------------------------
|
2020-05-27 01:04:37 +01:00
|
|
|
For high volume use, Troggle should be run using a web server like apache.
|
|
|
|
However, a quick way to get started is to use the development server built into Django.
|
|
|
|
This is limited though: directory redirection needs apache.
|
2011-07-11 02:10:22 +01:00
|
|
|
|
2020-05-27 01:04:37 +01:00
|
|
|
To do this, run
|
|
|
|
$ python manage.py runserver 8000 -v 3
|
|
|
|
from the troggle directory. This runs it on port 8000 so you see the website
|
|
|
|
at http://localhost:8000/
|
2020-03-12 17:40:03 +00:00
|
|
|
|
2020-07-28 01:46:00 +01:00
|
|
|
EXTRAS
|
|
|
|
------
|
|
|
|
cgit - https://git.zx2c4.com/cgit/about/
|
|
|
|
search - https://www.ibm.com/developerworks/opensource/library/os-xapianomega/index.html
|
|
|
|
|
2020-03-12 17:40:03 +00:00
|
|
|
Running a Troggle server with Apache
|
|
|
|
------------------------------------
|
|
|
|
Troggle also needs these aliases to be configured. These are set in
|
|
|
|
/home/expo/config/apache/expo.conf
|
|
|
|
on the expo server.
|
|
|
|
|
|
|
|
At least these need setting:
|
|
|
|
DocumentRoot /home/expo/expoweb
|
|
|
|
WSGIScriptAlias / /home/expo/troggle/wsgi.py
|
2020-03-14 20:08:44 +00:00
|
|
|
<Directory /home/expo/troggle>
|
|
|
|
<Files wsgi.py>
|
|
|
|
Require all granted
|
|
|
|
</Files>
|
|
|
|
</Directory>
|
|
|
|
|
2020-03-12 17:40:03 +00:00
|
|
|
Alias /expofiles /home/expo/expofiles
|
|
|
|
Alias /photos /home/expo/webphotos
|
|
|
|
Alias /map /home/expo/expoweb/map
|
|
|
|
Alias /javascript /usr/share/javascript
|
|
|
|
Alias /static/ /home/expo/static/
|
|
|
|
ScriptAlias /repositories /home/expo/config/apache/services/hgweb/hgweb.cgi
|
|
|
|
|
|
|
|
(The last is just for mercurial which will be remoived during 2020).
|
|
|
|
|
2020-06-06 23:03:37 +01:00
|
|
|
These two are not necessary as Django will serve these (see urls.py), but
|
2021-03-24 20:38:43 +00:00
|
|
|
it may be faster for apache to serve them first:
|
2020-06-06 23:03:37 +01:00
|
|
|
Alias /expofiles /home/expo/expofiles
|
|
|
|
Alias /static/ /home/expo/static/
|
|
|
|
|
|
|
|
|
2020-03-12 17:40:03 +00:00
|
|
|
Unlike the "runserver" method, apache requires a restart before it will use
|
|
|
|
any changed files:
|
|
|
|
|
2020-07-21 02:48:41 +01:00
|
|
|
sudo service apache2 restart
|
|
|
|
|
|
|
|
Olly's comments 20 July 2020:
|
|
|
|
olly: looking at /lib/systemd/system/apache2.service suggests so
|
|
|
|
|
|
|
|
olly: ExecStart=/usr/sbin/apachectl start
|
|
|
|
olly: ExecStop=/usr/sbin/apachectl stop
|
|
|
|
olly: ExecReload=/usr/sbin/apachectl graceful
|
2020-05-27 01:04:37 +01:00
|
|
|
|
|
|
|
Experimental additions
|
|
|
|
----------------------
|
|
|
|
These are modern tools which help us document how troggle works.
|
|
|
|
|
|
|
|
pip install pygraphviz
|
|
|
|
pip install pyparsing pydot # installs fine
|
|
|
|
django extension graph_models # https://django-extensions.readthedocs.io/en/latest/graph_models.html
|