diff --git a/bin/get_gprof b/bin/get_gprof new file mode 100755 index 0000000..24f2a43 --- /dev/null +++ b/bin/get_gprof @@ -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 + +executes: + gprof2dot -f pstats .prof | dot -Tpng -o .call.png + +where: + are arguments for gprof2dot, such as "-n 5 -e 5" + is code to create the instance to profile + 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) diff --git a/bin/get_objgraph b/bin/get_objgraph new file mode 100755 index 0000000..03c220d --- /dev/null +++ b/bin/get_objgraph @@ -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 diff --git a/bin/isort b/bin/isort new file mode 100755 index 0000000..6569e08 --- /dev/null +++ b/bin/isort @@ -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()) diff --git a/bin/isort-identify-imports b/bin/isort-identify-imports new file mode 100755 index 0000000..8477bc5 --- /dev/null +++ b/bin/isort-identify-imports @@ -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()) diff --git a/bin/pylint b/bin/pylint new file mode 100755 index 0000000..af368c8 --- /dev/null +++ b/bin/pylint @@ -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()) diff --git a/bin/pylint-config b/bin/pylint-config new file mode 100755 index 0000000..2ad1036 --- /dev/null +++ b/bin/pylint-config @@ -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()) diff --git a/bin/pyreverse b/bin/pyreverse new file mode 100755 index 0000000..bd2d9e6 --- /dev/null +++ b/bin/pyreverse @@ -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()) diff --git a/bin/symilar b/bin/symilar new file mode 100755 index 0000000..99797ca --- /dev/null +++ b/bin/symilar @@ -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()) diff --git a/bin/undill b/bin/undill new file mode 100755 index 0000000..f4f26bb --- /dev/null +++ b/bin/undill @@ -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'))) + diff --git a/transport_accessibility/pt_map/__init__.py b/transport_accessibility/pt_map/__init__.py new file mode 100644 index 0000000..473a0f4 diff --git a/transport_accessibility/pt_map/admin.py b/transport_accessibility/pt_map/admin.py new file mode 100644 index 0000000..97e651b --- /dev/null +++ b/transport_accessibility/pt_map/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/transport_accessibility/pt_map/apps.py b/transport_accessibility/pt_map/apps.py new file mode 100644 index 0000000..12d9c7a --- /dev/null +++ b/transport_accessibility/pt_map/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class PtMapConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'pt_map' diff --git a/transport_accessibility/pt_map/migrations/__init__.py b/transport_accessibility/pt_map/migrations/__init__.py new file mode 100644 index 0000000..473a0f4 diff --git a/transport_accessibility/pt_map/models.py b/transport_accessibility/pt_map/models.py new file mode 100644 index 0000000..3072a78 --- /dev/null +++ b/transport_accessibility/pt_map/models.py @@ -0,0 +1,3 @@ +from django.db import models + + diff --git a/transport_accessibility/pt_map/tests.py b/transport_accessibility/pt_map/tests.py new file mode 100644 index 0000000..bccdb2f --- /dev/null +++ b/transport_accessibility/pt_map/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/transport_accessibility/pt_map/urls.py b/transport_accessibility/pt_map/urls.py new file mode 100644 index 0000000..568710b --- /dev/null +++ b/transport_accessibility/pt_map/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path("", views.index, name="index"), +] diff --git a/transport_accessibility/pt_map/views.py b/transport_accessibility/pt_map/views.py new file mode 100644 index 0000000..8d4d802 --- /dev/null +++ b/transport_accessibility/pt_map/views.py @@ -0,0 +1,6 @@ +from django.shortcuts import render +from django.http import HttpResponse + +def index(request): + return HttpResponse("Test") + diff --git a/transport_accessibility/transport_accessibility/settings.py b/transport_accessibility/transport_accessibility/settings.py index f723f5c..1929a0b 100644 --- a/transport_accessibility/transport_accessibility/settings.py +++ b/transport_accessibility/transport_accessibility/settings.py @@ -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', } } diff --git a/transport_accessibility/transport_accessibility/urls.py b/transport_accessibility/transport_accessibility/urls.py index 228e7dd..93b7cdc 100644 --- a/transport_accessibility/transport_accessibility/urls.py +++ b/transport_accessibility/transport_accessibility/urls.py @@ -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")) ]