'Authorization': f'Bearer {access_token}', 'Content-Type': 'application/json' }, timeout=current_app.config.get('CONNECT_TIMEOUT'), data=json.dumps(post_revenue_payload) ) response.raise_for_status() print('Successfully updated for transaction', transaction_number) print(response.json()) except Exception as e: # pylint: disable=broad-except print(e) print('Failed processing of', transaction_number) if __name__ == '__main__': try: opts, args = getopt.getopt(sys.argv[1:], "ht:", ["txns="]) except getopt.GetoptError: sys.exit(2) failed_transaction_numbers: List[str] = [] for opt, arg in opts: if opt == '-h': sys.exit() elif opt in ("-t", "--txns"): failed_transaction_numbers = [x.strip() for x in arg.split(',')] with app.app_context(): create_app() update_failed_gl_codes(failed_transaction_numbers)
def app_request(): """Return a session-wide application configured in TEST mode.""" _app = create_app() return _app
""" import logging from flask import url_for from flask_migrate import Migrate, MigrateCommand from flask_script import Manager # class for handling a set of commands # models included so that migrate can build the database migrations from request_api import models # pylint: disable=unused-import from request_api import create_app from request_api.models import db ## python manage.py db migrate ## python manage.py db upgrade APP = create_app() MIGRATE = Migrate(APP, db) MANAGER = Manager(APP) MANAGER.add_command('db', MigrateCommand) @MANAGER.command def list_routes(): output = [] for rule in APP.url_map.iter_rules(): options = {} for arg in rule.arguments: options[arg] = "[{0}]".format(arg)