forked from expo/troggle
indent recursion and update comments
This commit is contained in:
@@ -108,6 +108,7 @@ def import_tunnelfiles():
|
||||
parsers.surveys.LoadTunnelFiles()
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# These functions moved to a different file - not used currently.
|
||||
#import logbooksdump
|
||||
#def import_auto_logbooks():
|
||||
#def dumplogbooks():
|
||||
@@ -172,7 +173,7 @@ class JobQueue():
|
||||
return True
|
||||
|
||||
def runqonce(self):
|
||||
"""Run all the jobs in the queue provided once
|
||||
"""Run all the jobs in the queue provided - once
|
||||
"""
|
||||
|
||||
print "** Running job ", self.runlabel
|
||||
@@ -199,6 +200,12 @@ class JobQueue():
|
||||
|
||||
|
||||
def run(self):
|
||||
"""First runs all the jobs in the queue against a scratch in-memory db
|
||||
then re-runs the import against the db specified in settings.py
|
||||
Default behaviour is to skip the in-memory phase.
|
||||
When MySQL is the db the in-memory phase crashes as MySQL does not properly
|
||||
relinquish some kind of db connection (not fixed yet)
|
||||
"""
|
||||
self.loadprofiles()
|
||||
# save db settings for later
|
||||
dbengine = settings.DATABASES['default']['ENGINE']
|
||||
@@ -214,15 +221,15 @@ class JobQueue():
|
||||
else:
|
||||
skipmem = True
|
||||
|
||||
print "-- ", settings.DATABASES['default']['NAME'], settings.DATABASES['default']['ENGINE']
|
||||
#print "-- DATABASES.default", settings.DATABASES['default']
|
||||
|
||||
if dbname ==":memory:":
|
||||
# just run, and save the sql file
|
||||
print "-- ", settings.DATABASES['default']['NAME'], settings.DATABASES['default']['ENGINE']
|
||||
print "-- DATABASES.default", settings.DATABASES['default']
|
||||
self.runqonce()
|
||||
self.memdumpsql()
|
||||
self.memdumpsql() # saved contents of scratch db, could be imported later..
|
||||
self.saveprofiles()
|
||||
elif skipmem:
|
||||
print "-- DATABASES.default", settings.DATABASES['default']
|
||||
self.runqonce()
|
||||
self.saveprofiles()
|
||||
else:
|
||||
@@ -248,9 +255,9 @@ class JobQueue():
|
||||
print "-- DATABASES.default", settings.DATABASES['default']
|
||||
|
||||
# but because the user may be expecting to add this to a db with lots of tables already there,
|
||||
# the jobque may not start from scratch so we need to initialise the db properly first
|
||||
# the jobqueue may not start from scratch so we need to initialise the db properly first
|
||||
# because we are using an empty :memory: database
|
||||
# But initiating twice crashes, so be sure to do it once only.
|
||||
# But initiating twice crashes it; so be sure to do it once only.
|
||||
|
||||
|
||||
# Damn. syncdb() is still calling MySQL somehow **conn_params not sqlite3. So crashes on expo server.
|
||||
@@ -259,9 +266,9 @@ class JobQueue():
|
||||
if ("dirsredirect",dirsredirect) not in self.queue:
|
||||
dirsredirect()
|
||||
if ("caves",import_caves) not in self.queue:
|
||||
import_caves() # sometime extract the initialising code from this and put in reinit
|
||||
import_caves() # sometime extract the initialising code from this and put in reinit...
|
||||
if ("people",import_people) not in self.queue:
|
||||
import_people() # sometime extract the initialising code from this and put in reinit
|
||||
import_people() # sometime extract the initialising code from this and put in reinit...
|
||||
|
||||
django.db.close_old_connections() # maybe not needed here
|
||||
|
||||
@@ -284,7 +291,6 @@ class JobQueue():
|
||||
|
||||
django.db.close_old_connections() # magic rune. works. found by looking in django.db__init__.py
|
||||
#django.setup() # should this be needed?
|
||||
|
||||
|
||||
self.runqonce() # crashes because it thinks it has no migrations to apply, when it does.
|
||||
self.saveprofiles()
|
||||
@@ -292,7 +298,8 @@ class JobQueue():
|
||||
return True
|
||||
|
||||
def showprofile(self):
|
||||
"""Prints out the time it took to run the jobqueue"""
|
||||
"""Prints out the time it took to run the jobqueue
|
||||
"""
|
||||
for k in self.results_order:
|
||||
if k =="dirsredirect":
|
||||
break
|
||||
@@ -306,7 +313,6 @@ class JobQueue():
|
||||
print '%10s (s)' % k,
|
||||
percen=0
|
||||
r = self.results[k]
|
||||
#print "min=",min
|
||||
|
||||
for i in range(len(r)):
|
||||
if k == "runlabel":
|
||||
@@ -432,9 +438,9 @@ if __name__ == "__main__":
|
||||
#parse_descriptions() # no longer present
|
||||
# elif "writeCaves" in sys.argv:
|
||||
# writeCaves() # no longer present
|
||||
elif "autologbooks" in sys.argv:
|
||||
elif "autologbooks" in sys.argv: # untested in 2020
|
||||
import_auto_logbooks()
|
||||
elif "dumplogbooks" in sys.argv:
|
||||
elif "dumplogbooks" in sys.argv: # untested in 2020
|
||||
dumplogbooks()
|
||||
else:
|
||||
usage()
|
||||
|
||||
Reference in New Issue
Block a user