bcgov/mines-digital-trust

View on GitHub
services/ghg-orgbook-issuer-controller/app/app.py

Summary

Maintainability
D
2 days
Test Coverage
Identical blocks of code found in 2 locations. Consider refactoring.
#!/usr/bin/env python
Identical blocks of code found in 2 locations. Consider refactoring.
from flask import Flask, jsonify, abort, request, make_response
Identical blocks of code found in 2 locations. Consider refactoring.
 
Identical blocks of code found in 2 locations. Consider refactoring.
import requests
Identical blocks of code found in 2 locations. Consider refactoring.
import json
Identical blocks of code found in 2 locations. Consider refactoring.
import os
Identical blocks of code found in 2 locations. Consider refactoring.
import yaml
Identical blocks of code found in 2 locations. Consider refactoring.
 
Identical blocks of code found in 2 locations. Consider refactoring.
import signal
Identical blocks of code found in 2 locations. Consider refactoring.
import pprint
Identical blocks of code found in 2 locations. Consider refactoring.
from app import config, issuer, routes
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.
 
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 = ENV
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.
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_app
Identical blocks of code found in 2 locations. Consider refactoring.
return app
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.
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