2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-14 02:07:07 +00:00

Module documentation docstrings

This commit is contained in:
Philip Sargent
2020-07-18 16:23:54 +01:00
parent 90dfa516da
commit edd5a3efd9
10 changed files with 100 additions and 17 deletions

View File

@@ -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()