import os, traceback, sys # noqa F401 def check_api(original_function): pass def make_default_dir(path_data): try: if not os.path.exists(path_data): os.mkdir(path_data) tmp = os.path.join(path_data, "tmp") try: import shutil if os.path.exists(tmp): shutil.rmtree(tmp) except Exception: pass sub = ["db", "log", "download", "command", "custom", "output", "tmp"] for item in sub: tmp = os.path.join(path_data, item) if not os.path.exists(tmp): os.mkdir(tmp) except Exception as exception: print("Exception:%s", exception) print(traceback.format_exc()) def config_initialize(action): from . import logger, app if action == "start": logger.debug("=========== action: strart ===========================") # sjva server 초기에 필요한 정보 불러오는 루틴 init_define() app.config["config"]["run_by_real"] = ( True if sys.argv[0] == "sjva.py" or sys.argv[0] == "sjva3.py" else False ) # app.config['config']['run_by_migration'] = True if sys.argv[-2] == 'db' else False app.config["config"]["run_by_worker"] = ( True if sys.argv[0].find("celery") != -1 else False ) app.config["config"]["run_by_init_db"] = ( True if sys.argv[-1] == "init_db" else False ) if sys.version_info[0] == 2: app.config["config"]["pip"] = "pip" app.config["config"]["is_py2"] = True app.config["config"]["is_py3"] = False else: app.config["config"]["is_py2"] = False app.config["config"]["is_py3"] = True app.config["config"]["pip"] = "pip3" app.config["config"]["is_debug"] = False app.config["config"]["repeat"] = -1 if app.config["config"]["run_by_real"]: try: if len(sys.argv) > 2: app.config["config"]["repeat"] = int(sys.argv[2]) except: app.config["config"]["repeat"] = 0 if len(sys.argv) > 3: try: app.config["config"]["is_debug"] = sys.argv[-1] == "debug" except: app.config["config"]["is_debug"] = False app.config["config"]["use_celery"] = True for tmp in sys.argv: if tmp == "no_celery": app.config["config"]["use_celery"] = False break # logger.debug('use_celery : %s', app.config['config']['use_celery']) logger.debug("======================================") elif action == "auth": from system.logic_auth import SystemLogicAuth # 2021-08-11 로딩시 인증 실행 여부 # SystemLogicAuth.do_auth() tmp = SystemLogicAuth.get_auth_status() app.config["config"]["auth_status"] = tmp["ret"] app.config["config"]["auth_desc"] = tmp["desc"] app.config["config"]["level"] = tmp["level"] app.config["config"]["point"] = tmp["point"] # app.config['config']['auth_status'] = True elif action == "system_loading_after": from . import SystemModelSetting try: app.config["config"]["is_server"] = ( SystemModelSetting.get("ddns") == app.config["DEFINE"]["MAIN_SERVER_URL"] ) except Exception: app.config["config"]["is_server"] = False if ( app.config["config"]["is_server"] or app.config["config"]["is_debug"] ): app.config["config"]["server"] = True app.config["config"]["is_admin"] = True else: app.config["config"]["server"] = False app.config["config"]["is_admin"] = False app.config["config"]["running_type"] = "native" # print(f"os.environ:: {os.environ}") if "SJVA_RUNNING_TYPE" in os.environ: app.config["config"]["running_type"] = os.environ[ "SJVA_RUNNING_TYPE" ] else: import platform if platform.system() == "Windows": app.config["config"]["running_type"] = "windows" def init_define(): from . import logger, app app.config["DEFINE"] = {}