# Path: mobsf/MobSF/init.py
# def first_run(secret_file, base_dir, mobsf_home):
#     # Based on https://gist.github.com/ndarville/3452907#file-secret-key-gen-py
#     if 'MOBSF_SECRET_KEY' in os.environ:
#         secret_key = os.environ['MOBSF_SECRET_KEY']
#     elif os.path.isfile(secret_file):
#         secret_key = open(secret_file).read().strip()
#     else:
#         try:
#             secret_key = get_random()
#             secret = open(secret_file, 'w')
#             secret.write(secret_key)
#             secret.close()
#         except IOError:
#             raise Exception('Secret file generation failed' % secret_file)
#         # Run Once
#         make_migrations(base_dir)
#         migrate(base_dir)
#         # Windows Setup
#         windows_config_local(mobsf_home)
#     return secret_key
# 
# def get_mobsf_home(use_home, base_dir):
#     try:
#         mobsf_home = ''
#         if use_home:
#             mobsf_home = os.path.join(os.path.expanduser('~'), '.MobSF')
#             # MobSF Home Directory
#             if not os.path.exists(mobsf_home):
#                 os.makedirs(mobsf_home)
#             create_user_conf(mobsf_home, base_dir)
#         else:
#             mobsf_home = base_dir
#         # Download Directory
#         dwd_dir = os.path.join(mobsf_home, 'downloads/')
#         if not os.path.exists(dwd_dir):
#             os.makedirs(dwd_dir)
#         # Screenshot Directory
#         screen_dir = os.path.join(dwd_dir, 'screen/')
#         if not os.path.exists(screen_dir):
#             os.makedirs(screen_dir)
#         # Upload Directory
#         upload_dir = os.path.join(mobsf_home, 'uploads/')
#         if not os.path.exists(upload_dir):
#             os.makedirs(upload_dir)
#         # Signature Directory
#         sig_dir = os.path.join(mobsf_home, 'signatures/')
#         if use_home:
#             src = os.path.join(base_dir, 'signatures/')
#             try:
#                 shutil.copytree(src, sig_dir)
#             except Exception:
#                 pass
#         elif not os.path.exists(sig_dir):
#             os.makedirs(sig_dir)
#         return mobsf_home
#     except Exception:
#         logger.exception('Creating MobSF Home Directory')
# 
# def get_mobsf_version():
#     return BANNER, VERSION, f'v{VERSION} Beta'


import imp
import logging
import os
from mobsf.MobSF.init import (
    first_run,
    get_mobsf_home,
    get_mobsf_version,
)
# noqa: E800
"""
Django settings for MobSF project.

MobSF and Django settings
"""



logger = logging.getLogger(__name__)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#       MOBSF CONFIGURATION
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
BANNER, VERSION, MOBSF_VER = get_mobsf_version()
USE_HOME = True
# True : All Uploads/Downloads will be stored in user's home directory
# False : All Uploads/Downloads will be stored under MobSF root directory

# MobSF Data Directory
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Path: mobsf/MobSF/init.py
# def first_run(secret_file, base_dir, mobsf_home):
#     # Based on https://gist.github.com/ndarville/3452907#file-secret-key-gen-py
#     if 'MOBSF_SECRET_KEY' in os.environ:
#         secret_key = os.environ['MOBSF_SECRET_KEY']
#     elif os.path.isfile(secret_file):
#         secret_key = open(secret_file).read().strip()
#     else:
#         try:
#             secret_key = get_random()
#             secret = open(secret_file, 'w')
#             secret.write(secret_key)
#             secret.close()
#         except IOError:
#             raise Exception('Secret file generation failed' % secret_file)
#         # Run Once
#         make_migrations(base_dir)
#         migrate(base_dir)
#         # Windows Setup
#         windows_config_local(mobsf_home)
#     return secret_key
# 
# def get_mobsf_home(use_home, base_dir):
#     try:
#         mobsf_home = ''
#         if use_home:
#             mobsf_home = os.path.join(os.path.expanduser('~'), '.MobSF')
#             # MobSF Home Directory
#             if not os.path.exists(mobsf_home):
#                 os.makedirs(mobsf_home)
#             create_user_conf(mobsf_home, base_dir)
#         else:
#             mobsf_home = base_dir
#         # Download Directory
#         dwd_dir = os.path.join(mobsf_home, 'downloads/')
#         if not os.path.exists(dwd_dir):
#             os.makedirs(dwd_dir)
#         # Screenshot Directory
#         screen_dir = os.path.join(dwd_dir, 'screen/')
#         if not os.path.exists(screen_dir):
#             os.makedirs(screen_dir)
#         # Upload Directory
#         upload_dir = os.path.join(mobsf_home, 'uploads/')
#         if not os.path.exists(upload_dir):
#             os.makedirs(upload_dir)
#         # Signature Directory
#         sig_dir = os.path.join(mobsf_home, 'signatures/')
#         if use_home:
#             src = os.path.join(base_dir, 'signatures/')
#             try:
#                 shutil.copytree(src, sig_dir)
#             except Exception:
#                 pass
#         elif not os.path.exists(sig_dir):
#             os.makedirs(sig_dir)
#         return mobsf_home
#     except Exception:
#         logger.exception('Creating MobSF Home Directory')
# 
# def get_mobsf_version():
#     return BANNER, VERSION, f'v{VERSION} Beta'


# Path: mobsf/MobSF/settings.py
import imp
import logging
import os
from mobsf.MobSF.init import (
    first_run,
    get_mobsf_home,
    get_mobsf_version,
)

# noqa: E800
"""
Django settings for MobSF project.

MobSF and Django settings
"""



logger = logging.getLogger(__name__)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#       MOBSF CONFIGURATION
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
BANNER, VERSION, MOBSF_VER = get_mobsf_version()
USE_HOME = True
# True : All Uploads/Downloads will be stored in user's home directory
# False : All Uploads/Downloads will be stored under MobSF root directory

# MobSF Data Directory
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

MobSF_HOME = get_mobsf_home(USE_HOME, BASE_DIR)