# Path: pogom/utils.py
# def get_args():
#     parser = argparse.ArgumentParser()
#     parser.add_argument('-H', '--host', help='Set web server listening host', default='127.0.0.1')
#     parser.add_argument('-P', '--port', type=int, help='Set web server listening port', default=5000)
#     parser.add_argument('--db', help='Connection String to be used. (default: sqlite)',
#                         default='sqlite')
#     parser.add_argument('-d', '--debug', type=str.lower, help='Debug Level [info|debug]', default=None)
# 
#     return parser.parse_args()
# 
# def get_encryption_lib_path():
#     # win32 doesn't mean necessarily 32 bits
#     if sys.platform == "win32" or sys.platform == "cygwin":
#         if platform.architecture()[0] == '64bit':
#             lib_name = "encrypt64bit.dll"
#         else:
#             lib_name = "encrypt32bit.dll"
# 
#     elif sys.platform == "darwin":
#         lib_name = "libencrypt-osx-64.so"
# 
#     elif os.uname()[4].startswith("arm") and platform.architecture()[0] == '32bit':
#         lib_name = "libencrypt-linux-arm-32.so"
# 
#     elif os.uname()[4].startswith("aarch64") and platform.architecture()[0] == '64bit':
#         lib_name = "libencrypt-linux-arm-64.so"
# 
#     elif sys.platform.startswith('linux'):
#         if "centos" in platform.platform():
#             if platform.architecture()[0] == '64bit':
#                 lib_name = "libencrypt-centos-x86-64.so"
#             else:
#                 lib_name = "libencrypt-linux-x86-32.so"
#         else:
#             if platform.architecture()[0] == '64bit':
#                 lib_name = "libencrypt-linux-x86-64.so"
#             else:
#                 lib_name = "libencrypt-linux-x86-32.so"
# 
#     elif sys.platform.startswith('freebsd'):
#         lib_name = "libencrypt-freebsd-64.so"
# 
#     else:
#         err = "Unexpected/unsupported platform '{}'".format(sys.platform)
#         log.error(err)
#         raise Exception(err)
# 
#     lib_path = os.path.join(os.path.dirname(__file__), "libencrypt", lib_name)
# 
#     if not os.path.isfile(lib_path):
#         err = "Could not find {} encryption library {}".format(sys.platform, lib_path)
#         log.error(err)
#         raise Exception(err)
# 
#     return lib_path


import logging
import sys
import json
import random
import string
import os
from threading import Thread
from pogom import config
from pogom.app import Pogom
from pogom.models import create_tables
from pogom.scan import Scanner, ScanConfig
from pogom.utils import get_args, get_encryption_lib_path
    if config.get('CONFIG_PASSWORD', None):
        config['AUTH_KEY'] = ''.join(random.choice(string.lowercase) for _ in range(32))


if __name__ == '__main__':
    args = get_args()

    logging.basicConfig(stream=sys.stdout, level=logging.INFO,
                        format='%(asctime)s [%(module)11s] [%(levelname)7s] %(message)s')
    if not args.debug:
        logging.getLogger("peewee").setLevel(logging.INFO)
        logging.getLogger("requests").setLevel(logging.WARNING)
        logging.getLogger("pogom.pgoapi.pgoapi").setLevel(logging.INFO)
        logging.getLogger("pogom.pgoapi.rpc_api").setLevel(logging.WARNING)
        logging.getLogger("pogom.pgoapi.auth").setLevel(logging.WARNING)
        logging.getLogger("pogom.models").setLevel(logging.WARNING)
        logging.getLogger("werkzeug").setLevel(logging.WARNING)
    elif args.debug == "info":
        logging.getLogger("pogom.pgoapi.pgoapi").setLevel(logging.INFO)
        logging.getLogger("pogom.models").setLevel(logging.INFO)
        logging.getLogger("werkzeug").setLevel(logging.INFO)
    elif args.debug == "debug":
        logging.getLogger("pogom.pgoapi.pgoapi").setLevel(logging.DEBUG)
        logging.getLogger("pogom.pgoapi.pgoapi").setLevel(logging.DEBUG)
        logging.getLogger("pogom.models").setLevel(logging.DEBUG)
        logging.getLogger("werkzeug").setLevel(logging.INFO)

    create_tables()
    scan_config = ScanConfig()
    read_config(scan_config)

# Path: pogom/utils.py
# def get_args():
#     parser = argparse.ArgumentParser()
#     parser.add_argument('-H', '--host', help='Set web server listening host', default='127.0.0.1')
#     parser.add_argument('-P', '--port', type=int, help='Set web server listening port', default=5000)
#     parser.add_argument('--db', help='Connection String to be used. (default: sqlite)',
#                         default='sqlite')
#     parser.add_argument('-d', '--debug', type=str.lower, help='Debug Level [info|debug]', default=None)
# 
#     return parser.parse_args()
# 
# def get_encryption_lib_path():
#     # win32 doesn't mean necessarily 32 bits
#     if sys.platform == "win32" or sys.platform == "cygwin":
#         if platform.architecture()[0] == '64bit':
#             lib_name = "encrypt64bit.dll"
#         else:
#             lib_name = "encrypt32bit.dll"
# 
#     elif sys.platform == "darwin":
#         lib_name = "libencrypt-osx-64.so"
# 
#     elif os.uname()[4].startswith("arm") and platform.architecture()[0] == '32bit':
#         lib_name = "libencrypt-linux-arm-32.so"
# 
#     elif os.uname()[4].startswith("aarch64") and platform.architecture()[0] == '64bit':
#         lib_name = "libencrypt-linux-arm-64.so"
# 
#     elif sys.platform.startswith('linux'):
#         if "centos" in platform.platform():
#             if platform.architecture()[0] == '64bit':
#                 lib_name = "libencrypt-centos-x86-64.so"
#             else:
#                 lib_name = "libencrypt-linux-x86-32.so"
#         else:
#             if platform.architecture()[0] == '64bit':
#                 lib_name = "libencrypt-linux-x86-64.so"
#             else:
#                 lib_name = "libencrypt-linux-x86-32.so"
# 
#     elif sys.platform.startswith('freebsd'):
#         lib_name = "libencrypt-freebsd-64.so"
# 
#     else:
#         err = "Unexpected/unsupported platform '{}'".format(sys.platform)
#         log.error(err)
#         raise Exception(err)
# 
#     lib_path = os.path.join(os.path.dirname(__file__), "libencrypt", lib_name)
# 
#     if not os.path.isfile(lib_path):
#         err = "Could not find {} encryption library {}".format(sys.platform, lib_path)
#         log.error(err)
#         raise Exception(err)
# 
#     return lib_path


# Path: runserver.py
import logging
import sys
import json
import random
import string
import os
from threading import Thread
from pogom import config
from pogom.app import Pogom
from pogom.models import create_tables
from pogom.scan import Scanner, ScanConfig
from pogom.utils import get_args, get_encryption_lib_path

    if config.get('CONFIG_PASSWORD', None):
        config['AUTH_KEY'] = ''.join(random.choice(string.lowercase) for _ in range(32))


if __name__ == '__main__':
    args = get_args()

    logging.basicConfig(stream=sys.stdout, level=logging.INFO,
                        format='%(asctime)s [%(module)11s] [%(levelname)7s] %(message)s')
    if not args.debug:
        logging.getLogger("peewee").setLevel(logging.INFO)
        logging.getLogger("requests").setLevel(logging.WARNING)
        logging.getLogger("pogom.pgoapi.pgoapi").setLevel(logging.INFO)
        logging.getLogger("pogom.pgoapi.rpc_api").setLevel(logging.WARNING)
        logging.getLogger("pogom.pgoapi.auth").setLevel(logging.WARNING)
        logging.getLogger("pogom.models").setLevel(logging.WARNING)
        logging.getLogger("werkzeug").setLevel(logging.WARNING)
    elif args.debug == "info":
        logging.getLogger("pogom.pgoapi.pgoapi").setLevel(logging.INFO)
        logging.getLogger("pogom.models").setLevel(logging.INFO)
        logging.getLogger("werkzeug").setLevel(logging.INFO)
    elif args.debug == "debug":
        logging.getLogger("pogom.pgoapi.pgoapi").setLevel(logging.DEBUG)
        logging.getLogger("pogom.pgoapi.pgoapi").setLevel(logging.DEBUG)
        logging.getLogger("pogom.models").setLevel(logging.DEBUG)
        logging.getLogger("werkzeug").setLevel(logging.INFO)

    create_tables()
    scan_config = ScanConfig()
    read_config(scan_config)

    config['SIGNATURE_LIB_PATH'] = get_encryption_lib_path()