From a4c36185e0ff351e1b785e68a9aba0ea3a3f31b9 Mon Sep 17 00:00:00 2001 From: Dominic Cerquetti Date: Sun, 26 Jun 2022 20:46:00 -0400 Subject: [PATCH 1/6] fix import for Mapping in later python versions > 3.6ish - change from 'collections' to 'collections.abc' - later python versions changed where this was imported from --- uber/models/types.py | 3 ++- uber/site_sections/statistics.py | 2 +- uber/tasks/email.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/uber/models/types.py b/uber/models/types.py index fb759aeae..6df4c6cf4 100644 --- a/uber/models/types.py +++ b/uber/models/types.py @@ -1,4 +1,5 @@ -from collections import Mapping, OrderedDict +from collections.abc import Mapping +from collections import OrderedDict from datetime import datetime, time, timedelta from dateutil.parser import parse import re diff --git a/uber/site_sections/statistics.py b/uber/site_sections/statistics.py index e5725439d..4cd8c1ef3 100644 --- a/uber/site_sections/statistics.py +++ b/uber/site_sections/statistics.py @@ -1,6 +1,6 @@ from collections import Counter, defaultdict, OrderedDict -from geopy.distance import VincentyDistance +from geopy.distance import geodesic from pockets.autolog import log from pytz import UTC import six diff --git a/uber/tasks/email.py b/uber/tasks/email.py index a20434760..e00a1b9c2 100644 --- a/uber/tasks/email.py +++ b/uber/tasks/email.py @@ -1,4 +1,4 @@ -from collections import Mapping +from collections.abc import Mapping from datetime import timedelta from time import sleep From 1bbbb25ed4cb13fc54d0507d4e1b98cc22748e77 Mon Sep 17 00:00:00 2001 From: Dominic Cerquetti Date: Sun, 26 Jun 2022 20:51:39 -0400 Subject: [PATCH 2/6] bump uber version# --- uber/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uber/_version.py b/uber/_version.py index c62c24eb9..c975b3685 100644 --- a/uber/_version.py +++ b/uber/_version.py @@ -1 +1 @@ -__version__ = '2017.07' +__version__ = '2022.01' From f27d063925a2f9de6e9a5b50281e8985fb0c2758 Mon Sep 17 00:00:00 2001 From: Dominic Cerquetti Date: Sun, 26 Jun 2022 20:52:30 -0400 Subject: [PATCH 3/6] wrap attribute access in safe functions ended up not needing these as the errors I was working around were config issues, but, not a bad idea to keep them anyway. --- uber/decorators.py | 14 ++++++++++++-- uber/errors.py | 11 ++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/uber/decorators.py b/uber/decorators.py index b0e9a4542..70d84de67 100644 --- a/uber/decorators.py +++ b/uber/decorators.py @@ -670,15 +670,25 @@ def with_check(*args, **kwargs): return func(*args, **kwargs) return with_check + +def cherrypy_session_get(key): + try: + session = cherrypy.session + except AttributeError: + return None + + return session.get(key) + + def restricted(func): @wraps(func) def with_restrictions(*args, **kwargs): if not func.public: if c.PATH == 'staffing': - if not cherrypy.session.get('staffer_id'): + if not cherrypy_session_get('staffer_id'): raise HTTPRedirect('../staffing/login?message=You+are+not+logged+in', save_location=True) - elif cherrypy.session.get('account_id') is None: + elif cherrypy_session_get('account_id') is None: raise HTTPRedirect('../accounts/login?message=You+are+not+logged+in', save_location=True) elif c.PATH == 'mivs_judging': diff --git a/uber/errors.py b/uber/errors.py index fe8b3a127..52fc5d39f 100644 --- a/uber/errors.py +++ b/uber/errors.py @@ -41,7 +41,7 @@ def __init__(self, page, *args, **kwargs): # useful if we want to redirect the user back to the same # page after they complete an action, such as logging in # example URI: '/uber/registration/form?id=786534' - original_location = cherrypy.request.wsgi_environ['REQUEST_URI'] + original_location = self.get_cherrypy_wsgi_environ() # Note: python does have utility functions for this. if this # gets any more complex, use the urllib module @@ -51,5 +51,14 @@ def __init__(self, page, *args, **kwargs): cherrypy.HTTPRedirect.__init__(self, query) + @staticmethod + def get_cherrypy_wsgi_environ(): + original_location = '' + try: + original_location = cherrypy.request.wsgi_environ['REQUEST_URI'] + except AttributeError: + pass + return original_location + def quote(self, s): return quote(s) if isinstance(s, str) else str(s) From d772a94315588544ccf3b8d2ff188ced14e2743a Mon Sep 17 00:00:00 2001 From: Dominic Cerquetti Date: Sun, 26 Jun 2022 20:54:06 -0400 Subject: [PATCH 4/6] check for /srv existence on startup - improves confusion on first connection attempt - all this code here can use a rethink --- uber/site_sections/statistics.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/uber/site_sections/statistics.py b/uber/site_sections/statistics.py index 4cd8c1ef3..55479cf5a 100644 --- a/uber/site_sections/statistics.py +++ b/uber/site_sections/statistics.py @@ -1,4 +1,5 @@ from collections import Counter, defaultdict, OrderedDict +from os.path import exists from geopy.distance import geodesic from pockets.autolog import log @@ -260,8 +261,13 @@ def badges_sold(self, session): zips_counter = Counter() zips = {} + center = None + + # TODO: use lazy loading instead of doing this here so it's only accessed on the first try. + # if /srv/reggie/data/ doesn't exist, this will barf loudly at startup. try: - center = SearchEngine(db_file_dir="/srv/reggie/data").by_zipcode(20745) + if exists("/srv/reggie/data"): + center = SearchEngine(db_file_dir="/srv/reggie/data").by_zipcode(20745) except Exception as e: log.error("Error calling SearchEngine: " + e) From e1fe646ff3007f8fa43f04439e2e945c35acb353 Mon Sep 17 00:00:00 2001 From: Dominic Cerquetti Date: Sun, 26 Jun 2022 20:54:26 -0400 Subject: [PATCH 5/6] update project version#s and metadata info --- setup.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index c3a3643f6..e1b1f5d8f 100644 --- a/setup.py +++ b/setup.py @@ -6,9 +6,8 @@ name='uber', packages=['uber'], version=__version__, - author='Eli Courtwright', - author_email='eli@courtwright.org', - description='The MAGFest Ubersystem', - url='https://github.com/EliAndrewC/magfest', - install_requires=open('requirements.txt').readlines() + author='Eli Courtwright and others', + author_email='code@magfest.org', + description='The MAGFest Ubersystem - Ticket/Management platform', + url='https://github.com/magfest/ubersystem', ) From aac6661559ce7183098f8e76c8662637183cb6ed Mon Sep 17 00:00:00 2001 From: Dominic Cerquetti Date: Sun, 26 Jun 2022 20:58:05 -0400 Subject: [PATCH 6/6] WIP fix Docker support - upgrade to python 3.10 - update many packages for python 3.10 compatibility - rip apart setup.py for uber and ubersystem. I for SURE broke stuff here. - change pavement.py to explicitly install plugin dependencies - remove NPM install stuff from Dockerfile - implement multi-stage dockerfile support for dev vs prod (to mount your own code in the container for easier dev support) - this doesn't quite get a running app, but, it gets as far as cherrypy starting - DO NOT USE THIS without a TON more testing - does allow debugging in PyCharm :) --- Dockerfile | 2 +- requirements.txt | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index be1dec086..23c1e08d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,6 @@ MAINTAINER RAMS Project "code@magfest.org" LABEL version.rams-core ="0.1" # add our code -COPY . plugins/uber/ +COPY . /app/sideboard/plugins/uber/ # go ahead and install base dependencies RUN /app/env/bin/paver install_deps diff --git a/requirements.txt b/requirements.txt index 9b45c4161..edacab0ea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,19 +1,23 @@ cherrypy==17.3.0 -celery==4.1.1 +celery==5.2.7 python-dateutil==2.6.0 -psycopg2 +psycopg2-binary>=2.7.3.2 py3k-bcrypt==0.3 stripe==2.42.0 -pytz==2017.2 +pytz==2022.1 alembic==0.9.1 treepoem==1.0.1 email_validator==1.0.2 phonenumbers==8.8.1 -pockets==0.6.2 -residue==0.2.8 +pockets==0.9.1 + +# hotfix +# residue==0.2.8 +git+https://github.com/magfest/residue@update_to_latest_python#egg=residue + XlsxWriter==1.0.2 uszipcode==0.2.6 -geopy==1.11.0 +geopy==2.2.0 twilio==6.10.0 cherrys==0.4 redis==2.10.6 @@ -22,4 +26,4 @@ Pillow==8.3.2 fpdf==1.7.2 boto3==1.14.45 SQLAlchemy==1.3.0 -Jinja2==2.11.3 \ No newline at end of file +Jinja2==3.0.3 \ No newline at end of file