from concurrent.futures import thread from pyexpat import model from time import sleep from sqlalchemy import false import Model.model_manager as model_manager import persistence from utility.app_logging import logger_name, init as init_logging import logging import View.view_manager as view import threading logger = logging.getLogger(logger_name) __is_running__ = False __stop_app__ = False condition_object = threading.Condition() def init() : init_logging() logger.debug(__name__) logger.info("") logger.info("") logger.info("") logger.info("------- welcome to Open Internet Service Provider -------") logger.info("") logger.info("") logger.info("") logger.info(" ██████  ██████  ███████ ███  ██  ██ ███████ ██████  ") logger.info(" ██    ██ ██   ██ ██      ████  ██  ██ ██      ██   ██  ") logger.info(" ██  ██ ██████  █████  ██ ██  ██  ██ ███████ ██████   ") logger.info(" ██  ██ ██      ██     ██  ██ ██  ██      ██ ██      ") logger.info("  ██████  ██  ███████ ██   ████  ██ ███████ ██  ") logger.info("") logger.info("") logger.info(" --- INITIALIZATION PHASE ---") logger.info("initializing Persistence Engine (Database)...") persistence.init() model_manager.init() logger.info("Persistence Engine initialization Done ") logger.info("initializing View Engine - Rest API") view.init() logger.info("View Engine - Rest API initialization Done ") logger.info(" --- END OF INITIALIZATION PHASE ---") import signal def keyboardInterruptHandler(signal, frame): logger.info("KeyboardInterrupt (ID: {}) has been caught. Cleaning up...".format(signal)) stop() signal.signal(signal.SIGINT, keyboardInterruptHandler) def main() : logger.info("Running View Engine - Rest API...") view.run() global __is_running__ global __stop_app__ __is_running__ = True condition_object.acquire() logger.info("Open ISP is now Running ! ") while(not __stop_app__) : condition_object.wait(0.5) logger.debug("exiting main loop") condition_object.release() __is_running__ = False def stop() : view.stop() global __stop_app__ global __is_running__ condition_object.acquire() condition_object.notify() __stop_app__ = True logger.info("Application Stopped, now exiting...") condition_object.release() def isRunning() : global __is_running__ return __is_running__