creating core/utils.py

This commit is contained in:
Philip Sargent
2021-04-12 23:58:48 +01:00
parent 5024abc812
commit b602f3ae13
6 changed files with 99 additions and 57 deletions

View File

@@ -15,7 +15,7 @@ import troggle.settings as settings
import troggle.core.models as models
import troggle.core.models_caves as models_caves
import troggle.core.models_survex as models_survex
from troggle.utils import ChaosMonkey
from troggle.core.utils import get_process_memory, chaosmonkey
from troggle.parsers.people import GetPersonExpeditionNameLookup
from troggle.parsers.logbooks import GetCaveLookup
from troggle.core.views.caves import MapLocations
@@ -716,7 +716,7 @@ class LoadingSurvex():
self.depthbegin = 0
self.datastar = self.datastardefault
blocklegs = self.legsnumber
print(self.insp+" - MEM:{:.3f} Reading. parent:{} <> {} ".format(models.get_process_memory(),survexblock.survexfile.path, survexfile.path))
print(self.insp+" - MEM:{:.3f} Reading. parent:{} <> {} ".format(get_process_memory(),survexblock.survexfile.path, survexfile.path))
self.lineno = 0
sys.stderr.flush();
self.callcount +=1
@@ -761,7 +761,7 @@ class LoadingSurvex():
print(".", file=sys.stderr,end='')
if blockcount % 200 ==0 :
print("\n", file=sys.stderr,end='')
print(" - MEM:{:7.3f} MB in use".format(models.get_process_memory()),file=sys.stderr)
print(" - MEM:{:7.3f} MB in use".format(get_process_memory()),file=sys.stderr)
print(" ", file=sys.stderr,end='')
sys.stderr.flush()
@@ -1104,7 +1104,7 @@ class LoadingSurvex():
if cav_t - log_t > 0: # new version of cavern
runcavern()
return
if ChaosMonkey(200):
if chaosmonkey(200):
runcavern()
def FindAndLoadSurvex(survexblockroot):
@@ -1128,7 +1128,7 @@ def FindAndLoadSurvex(survexblockroot):
indent=""
fcollate = open(collatefilename, 'w')
mem0 = models.get_process_memory()
mem0 = get_process_memory()
print(" - MEM:{:7.2f} MB START".format(mem0),file=sys.stderr)
flinear = open('svxlinear.log', 'w')
flinear.write(" - MEM:{:7.2f} MB START {}\n".format(mem0,survexfileroot.path))
@@ -1142,7 +1142,7 @@ def FindAndLoadSurvex(survexblockroot):
#----------------------------------------------------------------
flinear.write("{:2} {} *edulcni {}\n".format(svx_scan.depthinclude, indent, survexfileroot.path))
fcollate.write(";*edulcni {}\n".format(survexfileroot.path))
mem1 = models.get_process_memory()
mem1 = get_process_memory()
flinear.write("\n - MEM:{:.2f} MB STOP {}\n".format(mem1,survexfileroot.path))
flinear.write(" - MEM:{:.3f} MB USED\n".format(mem1-mem0))
svxfileslist = svx_scan.svxfileslist
@@ -1152,7 +1152,7 @@ def FindAndLoadSurvex(survexblockroot):
svx_scan = None # Hmm. Does this actually delete all the instance variables if they are lists, dicts etc.?
print("\n - {:,} survex files in linear include list \n".format(len(svxfileslist)),file=sys.stderr)
mem1 = models.get_process_memory()
mem1 = get_process_memory()
print(" - MEM:{:7.2f} MB END ".format(mem0),file=sys.stderr)
print(" - MEM:{:7.3f} MB USED".format(mem1-mem0),file=sys.stderr)
svxfileslist = [] # free memory
@@ -1180,7 +1180,7 @@ def FindAndLoadSurvex(survexblockroot):
print(" - MEM:{:7.3f} MB USED".format(mem1-mem0),file=sys.stderr)
legsnumber = svx_load.legsnumber
mem1 = models.get_process_memory()
mem1 = get_process_memory()
print(" - Number of SurvexDirectories: {}".format(len(svx_load.survexdict)))
tf=0
@@ -1227,11 +1227,11 @@ def LoadSurvexBlocks():
survexblockroot.save()
print(' - Loading Survex Blocks...')
memstart = models.get_process_memory()
memstart = get_process_memory()
#----------------------------------------------------------------
legsnumber = FindAndLoadSurvex(survexblockroot)
#----------------------------------------------------------------
memend = models.get_process_memory()
memend = get_process_memory()
print(" - MEMORY start:{:.3f} MB end:{:.3f} MB increase={:.3f} MB".format(memstart,memend, memend-memstart))
survexblockroot.save()