summaryrefslogtreecommitdiffstats
path: root/databaseReset.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2020-04-15 23:29:59 +0100
committerPhilip Sargent <philip.sargent@gmail.com>2020-04-15 23:29:59 +0100
commite5c288c7641e5d381babb3c5a800d640df9aeb96 (patch)
tree8367de22faa193bbd71b768defcb62c564f0bf7c /databaseReset.py
parent9db7d8e5891330c1a51cc8521262164536661685 (diff)
downloadtroggle-e5c288c7641e5d381babb3c5a800d640df9aeb96.tar.gz
troggle-e5c288c7641e5d381babb3c5a800d640df9aeb96.tar.bz2
troggle-e5c288c7641e5d381babb3c5a800d640df9aeb96.zip
get the profile display working & bug fix
Diffstat (limited to 'databaseReset.py')
-rw-r--r--databaseReset.py38
1 files changed, 22 insertions, 16 deletions
diff --git a/databaseReset.py b/databaseReset.py
index dbba3a5..4b45f36 100644
--- a/databaseReset.py
+++ b/databaseReset.py
@@ -161,7 +161,7 @@ class JobQueue():
self.results = {}
self.results_order=[
"date","runlabel","reload", "caves", "people",
- "logbooks", "surveyscans", "QMs", "survex"
+ "logbooks", "scans", "QMs", "survex",
"tunnel", "surveys", "test", "makedirs", "redirect" ]
for k in self.results_order:
self.results[k]=[]
@@ -182,7 +182,7 @@ class JobQueue():
def run(self):
import json
- tfile = "import_times.json"
+ tfile = "import_profile.json"
if os.path.isfile(tfile):
try:
f = open(tfile, "r")
@@ -194,13 +194,17 @@ class JobQueue():
# Python bug: https://github.com/ShinNoNoir/twitterwebsearch/issues/12
f.close()
+ for i in self.queue:
+ print i, self.results[i[0]]
+ self.results[i[0]].append(1.0)
+
print "** Running job ", self.runlabel
for i in self.queue:
#print "*- Running \"", i[0], "\""
start = time.time()
i[1]()
duration = time.time()-start
- #print "\n*- Ended \"", i[0], "\""
+ print "\n*- Ended \"", i[0], "\" %.1f seconds" % duration
self.results[i[0]].append(duration)
self.results["date"].append(start)
self.results["runlabel"].append(self.runlabel)
@@ -210,21 +214,21 @@ class JobQueue():
with open(tfile, 'w') as f:
json.dump(self.results, f)
- for i in self.results_order:
+ for k in self.results_order:
percen=0
- if i == "runlabel":
+ if k == "runlabel":
pass
- if i =="date":
+ if k =="date":
# Calculate dates as days before present to one decimal place
pass
- elif len(self.results[i])>0:
- lst = self.results[i]
+ elif len(self.results[k])>3:
+ lst = self.results[k]
e = len(lst)-1
percen = 100* (lst[e] - lst[e-1])/lst[e-1]
if abs(percen) >0.1:
- print '%15s %8.1f%%' % (i, percen)
+ print '%15s %8.1f%%' % (k, percen)
else:
- print '%15s ' % (i)
+ print '%15s ' % (k)
return True
@@ -238,14 +242,14 @@ def importtest():
return True
def usage():
- print("""Usage is 'python databaseReset.py <command>'
+ print("""Usage is 'python databaseReset.py <command> [runlabel]'
where command is:
reset - this is normal usage, clear database and reread everything from files - time-consuming
caves - read in the caves
logbooks - read in just the logbooks
people - read in the people from folk.csv
- QMs - read in the QM files
- reload_db - clear database i.e. delete everything
+ QMs - read in the QM csv files
+ reload_db - clear database (delete everything) and make empty tables
scans - NOT the scanned surveynotes ?!
survex - read in the survex files - all the survex blocks
surveys - read in the scanned surveynotes
@@ -258,6 +262,9 @@ def usage():
autologbooks - read in autologbooks (what are these?)
dumplogbooks - write out autologbooks (not working?)
test - testing...
+
+ and [runlabel] is an optional string identifying this run of the script
+ in the stored profiling data 'import-profile.json'
""")
if __name__ == "__main__":
@@ -269,7 +276,6 @@ if __name__ == "__main__":
runlabel = sys.argv[len(sys.argv)-1]
jq = JobQueue(runlabel)
-
if "test" in sys.argv:
jq.enq("test",importtest)
jq.enq("caves",importtest)
@@ -284,13 +290,13 @@ if __name__ == "__main__":
elif "QMs" in sys.argv:
jq.enq("QMs",import_QMs)
elif "reload_db" in sys.argv:
- jq.enq("reload_db",reload_db)
+ jq.enq("reload",reload_db)
elif "reset" in sys.argv:
jq.enq("reload",reload_db)
jq.enq("makedirs",make_dirs)
jq.enq("redirect",pageredirects)
jq.enq("caves",import_caves)
- jq.enq("logbooks",import_people)
+ jq.enq("people",import_people)
jq.enq("scans",import_surveyscans)
jq.enq("logbooks",import_logbooks)
jq.enq("QMs",import_QMs)