services/ghg-orgbook-issuer-controller/app/app.py
Identical blocks of code found in 2 locations. Consider refactoring.#!/usr/bin/env pythonIdentical blocks of code found in 2 locations. Consider refactoring.from flask import Flask, jsonify, abort, request, make_responseIdentical blocks of code found in 2 locations. Consider refactoring. Identical blocks of code found in 2 locations. Consider refactoring.import requestsIdentical blocks of code found in 2 locations. Consider refactoring.import jsonIdentical blocks of code found in 2 locations. Consider refactoring.import osIdentical blocks of code found in 2 locations. Consider refactoring.import yamlIdentical blocks of code found in 2 locations. Consider refactoring. Identical blocks of code found in 2 locations. Consider refactoring.import signalIdentical blocks of code found in 2 locations. Consider refactoring.import pprintIdentical blocks of code found in 2 locations. Consider refactoring.from app import config, issuer, routesIdentical blocks of code found in 2 locations. Consider refactoring. Identical blocks of code found in 2 locations. Consider refactoring. Identical blocks of code found in 2 locations. Consider refactoring. Identical blocks of code found in 2 locations. Consider refactoring.class Controller(Flask):Identical blocks of code found in 2 locations. Consider refactoring. def __init__(self, ENV):Identical blocks of code found in 2 locations. Consider refactoring. print("Initializing " + __name__ + " ...")Identical blocks of code found in 2 locations. Consider refactoring. super().__init__(__name__)Identical blocks of code found in 2 locations. Consider refactoring. if ENV.get('mode','') == 'TEST':Identical blocks of code found in 2 locations. Consider refactoring. issuer.app_config = ENV['test_issuer_app_config']Identical blocks of code found in 2 locations. Consider refactoring. issuer.synced = ENV['test_issuer_synced']Identical blocks of code found in 2 locations. Consider refactoring. else: Identical blocks of code found in 2 locations. Consider refactoring. self.startup_thread = issuer.startup_init(ENV)Identical blocks of code found in 2 locations. Consider refactoring. self.ENV = ENVIdentical blocks of code found in 2 locations. Consider refactoring. Identical blocks of code found in 2 locations. Consider refactoring. Identical blocks of code found in 2 locations. Consider refactoring.def init_app(ENV):Identical blocks of code found in 2 locations. Consider refactoring. app = Controller(ENV)Identical blocks of code found in 2 locations. Consider refactoring. routes.register_routes(app)Identical blocks of code found in 2 locations. Consider refactoring. wsgi_app = app.wsgi_appIdentical blocks of code found in 2 locations. Consider refactoring. return appIdentical blocks of code found in 2 locations. Consider refactoring. Identical blocks of code found in 2 locations. Consider refactoring. Identical blocks of code found in 2 locations. Consider refactoring.def create_app():Identical blocks of code found in 2 locations. Consider refactoring. signal.signal(signal.SIGINT, issuer.signal_issuer_shutdown)Identical blocks of code found in 2 locations. Consider refactoring. signal.signal(signal.SIGTERM, issuer.signal_issuer_shutdown)Identical blocks of code found in 2 locations. Consider refactoring. Identical blocks of code found in 2 locations. Consider refactoring. # Load application settings (environment)Identical blocks of code found in 2 locations. Consider refactoring. config_root = os.environ.get('CONFIG_ROOT', './config/local')Identical blocks of code found in 2 locations. Consider refactoring. ENV = config.load_settings(config_root=config_root)Identical blocks of code found in 2 locations. Consider refactoring. app = init_app(ENV)Identical blocks of code found in 2 locations. Consider refactoring. return app