From 537d06f5abce0d6642b04d704c67815f081c6dee Mon Sep 17 00:00:00 2001 From: Doug Lovett Date: Thu, 12 Dec 2024 15:27:34 -0800 Subject: [PATCH] PPR API verify new CI script updates. Signed-off-by: Doug Lovett --- ppr-api/gunicorn_config.py | 8 +-- ppr-api/src/ppr_api/utils/run_version.py | 29 ----------- ppr-api/test_data/run_one_file.py | 65 ------------------------ 3 files changed, 4 insertions(+), 98 deletions(-) delete mode 100644 ppr-api/src/ppr_api/utils/run_version.py delete mode 100755 ppr-api/test_data/run_one_file.py diff --git a/ppr-api/gunicorn_config.py b/ppr-api/gunicorn_config.py index c4eb50acf..ef109bd97 100644 --- a/ppr-api/gunicorn_config.py +++ b/ppr-api/gunicorn_config.py @@ -17,8 +17,8 @@ import os -workers = int(os.environ.get('GUNICORN_PROCESSES', '1')) # pylint: disable=invalid-name -threads = int(os.environ.get('GUNICORN_THREADS', '1')) # pylint: disable=invalid-name +workers = int(os.environ.get("GUNICORN_PROCESSES", "1")) # pylint: disable=invalid-name +threads = int(os.environ.get("GUNICORN_THREADS", "1")) # pylint: disable=invalid-name -forwarded_allow_ips = '*' # pylint: disable=invalid-name -secure_scheme_headers = {'X-Forwarded-Proto': 'https'} # pylint: disable=invalid-name +forwarded_allow_ips = "*" # pylint: disable=invalid-name +secure_scheme_headers = {"X-Forwarded-Proto": "https"} # pylint: disable=invalid-name diff --git a/ppr-api/src/ppr_api/utils/run_version.py b/ppr-api/src/ppr_api/utils/run_version.py deleted file mode 100644 index 13a885235..000000000 --- a/ppr-api/src/ppr_api/utils/run_version.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright © 2019 Province of British Columbia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Supply version and commit hash info.""" -import os - -from ppr_api.version import __version__ - - -def _get_build_openshift_commit_hash(): - return os.getenv('OPENSHIFT_BUILD_COMMIT', None) - - -def get_run_version(): - """Return a formatted version string for this service.""" - commit_hash = _get_build_openshift_commit_hash() - if commit_hash: - return f'{__version__}-{commit_hash}' - return __version__ diff --git a/ppr-api/test_data/run_one_file.py b/ppr-api/test_data/run_one_file.py deleted file mode 100755 index 0736cfe9a..000000000 --- a/ppr-api/test_data/run_one_file.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright © 2019 Province of British Columbia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Create test data from a single sql script file. - -""" - -from sqlalchemy.sql import text - -from ppr_api import create_app -from ppr_api.models import db - - -def execute_file(session, file_name): - print('Executing SQL statements in file ' + file_name) - with open(file_name, 'r') as sql_file: - sql_command = '' - # Iterate over all lines in the sql file - for line in sql_file: - # Ignore commented lines - if not line.startswith('--') and line.strip('\n'): - # Append line to the command string - sql_command += line.strip('\n') - - # If the command string ends with ';', it is a full statement - if sql_command.endswith(';'): - sql_command = sql_command.replace(';', '') - # print('Executing SQL: ' + sql_command) - # Try to execute statement and commit it - try: - session.execute(text(sql_command)) - - # Assert in case of error - except Exception as ex: - print(repr(ex)) - - # Finally, clear command string - finally: - sql_command = '' - - session.commit() - sql_file.close() - - -app = create_app('testing') -with app.app_context(): - conn = db.engine.connect() - options = dict(bind=conn, binds={}) - session = db.create_scoped_session(options=options) - - execute_file(session, 'test_data/postgres_test_reset.sql') - - conn.close() - -