mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-16 14:17:08 +00:00
creating core/utils.py
This commit is contained in:
@@ -22,6 +22,7 @@ from django.urls import reverse
|
||||
from django.template import Context, loader
|
||||
|
||||
import troggle.core.models_survex
|
||||
from troggle.core.utils import get_process_memory
|
||||
|
||||
"""This file declares TroggleModel which inherits from django.db.models.Model
|
||||
All TroggleModel subclasses inherit persistence in the django relational database. This is known as
|
||||
@@ -29,43 +30,6 @@ the django Object Relational Mapping (ORM).
|
||||
There are more subclasses define in models_caves.py models_survex.py etc.
|
||||
"""
|
||||
|
||||
# This variable is a dictionary holding gloablly visible indexes and cache functions.
|
||||
# It is a Global Object, see https://python-patterns.guide/python/module-globals/
|
||||
# troggle.models.TROG
|
||||
TROG = {
|
||||
'pagecache' : {
|
||||
'expedition' : {}
|
||||
}
|
||||
}
|
||||
|
||||
def get_process_memory():
|
||||
usage=resource.getrusage(resource.RUSAGE_SELF)
|
||||
return usage[2]/1024.0
|
||||
|
||||
|
||||
# def get_related_by_wikilinks(wiki_text):
|
||||
# found=re.findall(settings.QM_PATTERN,wiki_text)
|
||||
# res=[]
|
||||
# for wikilink in found:
|
||||
# qmdict={'urlroot':settings.URL_ROOT,'cave':wikilink[2],'year':wikilink[1],'number':wikilink[3]}
|
||||
# try:
|
||||
# cave_slugs = models_caves.CaveSlug.objects.filter(cave__kataster_number = qmdict['cave'])
|
||||
# qm=QM.objects.get(found_by__cave_slug__in = cave_slugs,
|
||||
# found_by__date__year = qmdict['year'],
|
||||
# number = qmdict['number'])
|
||||
# res.append(qm)
|
||||
# except QM.DoesNotExist:
|
||||
# print(('fail on '+str(wikilink)))
|
||||
|
||||
# return res
|
||||
|
||||
try:
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
filename=settings.LOGFILE,
|
||||
filemode='w')
|
||||
except:
|
||||
# Opening of file for writing is going to fail currently, so decide it doesn't matter for now
|
||||
pass
|
||||
|
||||
#This class is for adding fields and methods which all of our models will have.
|
||||
class TroggleModel(models.Model):
|
||||
|
||||
Reference in New Issue
Block a user