summaryrefslogtreecommitdiffstats
path: root/databaseReset.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2020-07-18 16:23:54 +0100
committerPhilip Sargent <philip.sargent@klebos.com>2020-07-18 16:23:54 +0100
commitedd5a3efd901df68243372f46087d96d4fbf7715 (patch)
tree037682c9ad9a85c2de8532c5623bf750c12dee5b /databaseReset.py
parent90dfa516da857f300bd0ff483ebf7a412934bbcf (diff)
downloadtroggle-edd5a3efd901df68243372f46087d96d4fbf7715.tar.gz
troggle-edd5a3efd901df68243372f46087d96d4fbf7715.tar.bz2
troggle-edd5a3efd901df68243372f46087d96d4fbf7715.zip
Module documentation docstrings
Diffstat (limited to 'databaseReset.py')
-rw-r--r--databaseReset.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/databaseReset.py b/databaseReset.py
index fa41a51..0c5c40f 100644
--- a/databaseReset.py
+++ b/databaseReset.py
@@ -6,6 +6,17 @@ import json
import resource
import settings
+""" Command-line utility for loading cave data files into troggle's database.
+
+The command line options select which combination of classes of data will be imported,
+e.g. cave data, logbook data, cavers (people) data. The set of imports requested are put
+into a job queue in a valid order, toegether with any necessary initialisation if it is
+a complete reset, and the queue is then executed.
+
+In future all these functions may be moved to a control panel webpage running within the
+troggle application.
+"""
+
os.environ['PYTHONPATH'] = settings.PYTHON_PATH
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
@@ -132,7 +143,7 @@ def memdumpsql(fn):
class JobQueue():
"""A list of import operations to run. Always reports profile times
- in the same order.
+ of the import operations in the same order.
"""
def __init__(self,run):
@@ -154,7 +165,7 @@ class JobQueue():
return True
def loadprofiles(self):
- """Load timings for previous runs from file
+ """Load timings for previous imports for each data import type
"""
if os.path.isfile(self.tfile):
try:
@@ -171,6 +182,8 @@ class JobQueue():
return True
def saveprofiles(self):
+ """Save timings for the set of imports just completed
+ """
with open(self.tfile, 'w') as f:
json.dump(self.results, f)
return True
@@ -212,10 +225,14 @@ class JobQueue():
self.results[j].append(None) # append a placeholder
def run_now_django_tests(self,n):
+ """Runs the standard django test harness system which is in troggle/core/TESTS/tests.py
+ """
management.call_command('test', verbosity=n)
django.db.close_old_connections()
def run(self):
+ """Initialises profile timings record, initiates relational database, runs the job queue saving the imported data as an SQL image and saves the timing profile data.
+ """
self.loadprofiles()
print("-- start ", django.db.connections.databases['default']['ENGINE'], django.db.connections.databases['default']['NAME'])
self.runqonce()