Setup Mariadb

This commit is contained in:
Johannes Randerath 2024-05-31 22:32:30 +02:00
parent 1b0d8a2ce9
commit a18927bad1
19 changed files with 233 additions and 3 deletions

75
bin/get_gprof Executable file
View File

@ -0,0 +1,75 @@
#!/home/johannes/code/transport-accessibility/bin/python3
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2008-2016 California Institute of Technology.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/dill/blob/master/LICENSE
'''
build profile graph for the given instance
running:
$ get_gprof <args> <instance>
executes:
gprof2dot -f pstats <args> <type>.prof | dot -Tpng -o <type>.call.png
where:
<args> are arguments for gprof2dot, such as "-n 5 -e 5"
<instance> is code to create the instance to profile
<type> is the class of the instance (i.e. type(instance))
For example:
$ get_gprof -n 5 -e 1 "import numpy; numpy.array([1,2])"
will create 'ndarray.call.png' with the profile graph for numpy.array([1,2]),
where '-n 5' eliminates nodes below 5% threshold, similarly '-e 1' eliminates
edges below 1% threshold
'''
if __name__ == "__main__":
import sys
if len(sys.argv) < 2:
print ("Please provide an object instance (e.g. 'import math; math.pi')")
sys.exit()
# grab args for gprof2dot
args = sys.argv[1:-1]
args = ' '.join(args)
# last arg builds the object
obj = sys.argv[-1]
obj = obj.split(';')
# multi-line prep for generating an instance
for line in obj[:-1]:
exec(line)
# one-line generation of an instance
try:
obj = eval(obj[-1])
except Exception:
print ("Error processing object instance")
sys.exit()
# get object 'name'
objtype = type(obj)
name = getattr(objtype, '__name__', getattr(objtype, '__class__', objtype))
# profile dumping an object
import dill
import os
import cProfile
#name = os.path.splitext(os.path.basename(__file__))[0]
cProfile.run("dill.dumps(obj)", filename="%s.prof" % name)
msg = "gprof2dot -f pstats %s %s.prof | dot -Tpng -o %s.call.png" % (args, name, name)
try:
res = os.system(msg)
except Exception:
print ("Please verify install of 'gprof2dot' to view profile graphs")
if res:
print ("Please verify install of 'gprof2dot' to view profile graphs")
# get stats
f_prof = "%s.prof" % name
import pstats
stats = pstats.Stats(f_prof, stream=sys.stdout)
stats.strip_dirs().sort_stats('cumtime')
stats.print_stats(20) #XXX: save to file instead of print top 20?
os.remove(f_prof)

54
bin/get_objgraph Executable file
View File

@ -0,0 +1,54 @@
#!/home/johannes/code/transport-accessibility/bin/python3
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2008-2016 California Institute of Technology.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/dill/blob/master/LICENSE
"""
display the reference paths for objects in ``dill.types`` or a .pkl file
Notes:
the generated image is useful in showing the pointer references in
objects that are or can be pickled. Any object in ``dill.objects``
listed in ``dill.load_types(picklable=True, unpicklable=True)`` works.
Examples::
$ get_objgraph ArrayType
Image generated as ArrayType.png
"""
import dill as pickle
#pickle.debug.trace(True)
#import pickle
# get all objects for testing
from dill import load_types
load_types(pickleable=True,unpickleable=True)
from dill import objects
if __name__ == "__main__":
import sys
if len(sys.argv) != 2:
print ("Please provide exactly one file or type name (e.g. 'IntType')")
msg = "\n"
for objtype in list(objects.keys())[:40]:
msg += objtype + ', '
print (msg + "...")
else:
objtype = str(sys.argv[-1])
try:
obj = objects[objtype]
except KeyError:
obj = pickle.load(open(objtype,'rb'))
import os
objtype = os.path.splitext(objtype)[0]
try:
import objgraph
objgraph.show_refs(obj, filename=objtype+'.png')
except ImportError:
print ("Please install 'objgraph' to view object graphs")
# EOF

8
bin/isort Executable file
View File

@ -0,0 +1,8 @@
#!/home/johannes/code/transport-accessibility/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from isort.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

8
bin/isort-identify-imports Executable file
View File

@ -0,0 +1,8 @@
#!/home/johannes/code/transport-accessibility/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from isort.main import identify_imports_main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(identify_imports_main())

8
bin/pylint Executable file
View File

@ -0,0 +1,8 @@
#!/home/johannes/code/transport-accessibility/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pylint import run_pylint
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(run_pylint())

8
bin/pylint-config Executable file
View File

@ -0,0 +1,8 @@
#!/home/johannes/code/transport-accessibility/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pylint import _run_pylint_config
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(_run_pylint_config())

8
bin/pyreverse Executable file
View File

@ -0,0 +1,8 @@
#!/home/johannes/code/transport-accessibility/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pylint import run_pyreverse
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(run_pyreverse())

8
bin/symilar Executable file
View File

@ -0,0 +1,8 @@
#!/home/johannes/code/transport-accessibility/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pylint import run_symilar
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(run_symilar())

22
bin/undill Executable file
View File

@ -0,0 +1,22 @@
#!/home/johannes/code/transport-accessibility/bin/python3
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2008-2016 California Institute of Technology.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/dill/blob/master/LICENSE
"""
unpickle the contents of a pickled object file
Examples::
$ undill hello.pkl
['hello', 'world']
"""
if __name__ == '__main__':
import sys
import dill
for file in sys.argv[1:]:
print (dill.load(open(file,'rb')))

View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

View File

@ -0,0 +1,6 @@
from django.apps import AppConfig
class PtMapConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'pt_map'

View File

@ -0,0 +1,3 @@
from django.db import models

View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View File

@ -0,0 +1,6 @@
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="index"),
]

View File

@ -0,0 +1,6 @@
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return HttpResponse("Test")

View File

@ -75,8 +75,11 @@ WSGI_APPLICATION = 'transport_accessibility.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'ENGINE': 'django.db.backends.mysql',
'NAME': 'transport_accessibility',
'HOST': 'localhost',
'USER': 'transport_accessibility',
'PASSWORD': 'L8AClYIsC55SEAWTgYopD',
}
}

View File

@ -15,8 +15,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include("pt_map.urls"))
]