From 152787f6d61c34d3cccd8fa5f7b6474ffa915647 Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Fri, 19 Mar 2021 00:47:37 +0000 Subject: [PATCH] Fix error on startup caused by incorrect types and new SqlAlchemy. --- bemani/data/mysql/base.py | 6 +++--- bemani/frontend/account/account.py | 5 ++--- bemani/utils/read.py | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/bemani/data/mysql/base.py b/bemani/data/mysql/base.py index 1798aea..fc9a54d 100644 --- a/bemani/data/mysql/base.py +++ b/bemani/data/mysql/base.py @@ -5,7 +5,7 @@ from typing import Dict, Any, Optional from bemani.common import Time from sqlalchemy.engine.base import Connection # type: ignore -from sqlalchemy.engine.result import ResultProxy # type: ignore +from sqlalchemy.engine import CursorResult # type: ignore from sqlalchemy.sql import text # type: ignore from sqlalchemy.types import String, Integer # type: ignore from sqlalchemy import Table, Column, MetaData # type: ignore @@ -54,7 +54,7 @@ class BaseData: self.__config = config self.__conn = conn - def execute(self, sql: str, params: Optional[Dict[str, Any]]=None, safe_write_operation: bool=False) -> ResultProxy: + def execute(self, sql: str, params: Optional[Dict[str, Any]]=None, safe_write_operation: bool=False) -> CursorResult: """ Given a SQL string and some parameters, execute the query and return the result. @@ -63,7 +63,7 @@ class BaseData: params - Dictionary of parameters which will be substituted into the sql string. Returns: - A SQLAlchemy ResultProxy object. + A SQLAlchemy CursorResult object. """ if self.__config['database'].get('read_only', False): # See if this is an insert/update/delete diff --git a/bemani/frontend/account/account.py b/bemani/frontend/account/account.py index 21c39b3..9ecea40 100644 --- a/bemani/frontend/account/account.py +++ b/bemani/frontend/account/account.py @@ -1,8 +1,7 @@ -import datetime from typing import Dict, Any from flask import Blueprint, request, redirect, Response, url_for, make_response, render_template, g # type: ignore -from bemani.common import CardCipher, CardCipherException, AESCipher +from bemani.common import CardCipher, CardCipherException, AESCipher, Time from bemani.frontend.app import loginrequired, loginprohibited, success, error, jsonify, valid_email, valid_username, valid_pin, render_react from bemani.frontend.templates import templates_location from bemani.frontend.static import static_location @@ -33,7 +32,7 @@ def login() -> Response: response.set_cookie( 'SessionID', aes.encrypt(sessionID), - expires=datetime.datetime.now() + datetime.timedelta(days=90) + expires=Time.now() + (90 * Time.SECONDS_IN_DAY), ) return response else: diff --git a/bemani/utils/read.py b/bemani/utils/read.py index 4393380..6a1c95d 100644 --- a/bemani/utils/read.py +++ b/bemani/utils/read.py @@ -12,7 +12,7 @@ import struct import yaml # type: ignore import xml.etree.ElementTree as ET from sqlalchemy import create_engine # type: ignore -from sqlalchemy.engine.result import ResultProxy # type: ignore +from sqlalchemy.engine import CursorResult # type: ignore from sqlalchemy.orm import sessionmaker # type: ignore from sqlalchemy.sql import text # type: ignore from sqlalchemy.exc import IntegrityError # type: ignore @@ -75,7 +75,7 @@ class ImportBase: self.__session.commit() self.__batch = False - def execute(self, sql: str, params: Optional[Dict[str, Any]]=None) -> ResultProxy: + def execute(self, sql: str, params: Optional[Dict[str, Any]]=None) -> CursorResult: if not self.__batch: raise Exception('Logic error, cannot execute outside of a batch!')