示例#1
0
def main():
    """
    脚本主函数
    :return:
    """
    from tools.usage import usage_help
    s_ops = "h"
    s_opexplain = ["help"]
    l_ops = ["up-pylib=", "latest", "up-conf-sample", "add-user"]
    l_opexplain = [
        "<value>, Update the python third-party packages.\n\t\t"
        "Version update of the default installation requirements file)\n\t\t"
        "Optional parameters: 'input-venv' or 'no-input-venv'",
        "Update to the latest package",
        "Update the system configuration sample file. Automatically remove sensitive data (eg passwords)\n\t\t"
        "Mainly the following configuration files:\n\t\t"
        "{}/apps/config_sample.py; {}/apps/db_config_sample.py".format(
            PROJECT_PATH, PROJECT_PATH),
        "Add a Root user, generally only used to initialize the user when the site was just created"
    ]

    action = [
        "Update python lib: python {} --up-pylib no-input-venv".format(
            __file__),
        "Update config sample: python {} --up-conf-sample".format(__file__),
        "Add user: python {} --add-user".format(__file__)
    ]

    opts, args = getopt.getopt(sys.argv[1:], s_ops, l_ops)
    is_up_pylib = False
    input_venv_path = False
    latest = False
    for op, value in opts:
        if op == "--up-pylib":
            from apps.core.utils.sys_tool import update_pylib
            if value == "input-venv":
                input_venv_path = True
            is_up_pylib = True

        elif op == "--latest":
            latest = True

        elif op == "--up-conf-sample":
            from apps.core.utils.sys_tool import copy_config_to_sample
            copy_config_to_sample()

        elif op == "--add-user":
            from start import mdbs
            from apps.core.utils.sys_tool import add_user
            add_user(mdbs=mdbs)

        elif op == "-h" or op == "--help":

            usage_help(s_ops, s_opexplain, l_ops, l_opexplain, action=action)

    if is_up_pylib:
        update_pylib(input_venv_path=input_venv_path, latest=latest)
    if not opts:

        usage_help(s_ops, s_opexplain, l_ops, l_opexplain, action=action)
示例#2
0
def main():
    """
    脚本主函数
    :return:
    """
    from tools.usage import usage_help
    s_ops = "h"
    s_opexplain = ["help"]
    l_ops = ["up-pylib", "venv-path=", "latest", "up-conf-sample", "add-user"]
    l_opexplain = [
        "<value>, Update python package (dependent package)",
        "<value>, up-pylib input venv path: <venv-path> or null",
        "up-pylib Update to the latest version",
        "Update to the latest package",
        "Update the system configuration sample file. Automatically remove sensitive data (eg passwords)\n"
        "Mainly the following configuration files:\n"
        " {}/apps/config_sample.py;\n"
        " {}/apps/db_config_sample.py".format(PROJECT_PATH, PROJECT_PATH),
        "Add a Root user, generally only used to initialize the user when the site was just created"
    ]

    action = [
        "Update python lib: python {} --up-pylib".format(__file__),
        "Update config sample: python {} --up-conf-sample".format(__file__),
        "Add user: python {} --add-user".format(__file__)
    ]

    opts, args = getopt.getopt(sys.argv[1:], s_ops, l_ops)
    is_up_pylib = False
    venv_path = "default"
    latest = False
    for op, value in opts:
        if op == "--up-pylib":
            is_up_pylib = True
        elif op == "--venv-path":
            venv_path = value
        elif op == "--latest":
            latest = True

        elif op == "--up-conf-sample":
            from apps.core.utils.sys_tool import copy_config_to_sample
            copy_config_to_sample()

        elif op == "--add-user":
            from start import mdbs
            from apps.core.utils.sys_tool import add_user
            add_user(mdbs=mdbs)

        elif op == "-h" or op == "--help":
            usage_help(s_ops, s_opexplain, l_ops, l_opexplain, action=action)

    if is_up_pylib:
        from apps.core.utils.sys_tool import update_pylib
        update_pylib(venv_path=venv_path, latest=latest)
    if not opts:
        usage_help(s_ops, s_opexplain, l_ops, l_opexplain, action=action)
示例#3
0
def main():
    '''
    脚本主函数
    :return:
    '''
    from tools.usage import usage_help
    s_ops = "h"
    s_opexplain = ["help"]
    l_ops = ["up-pylib=", "up-conf-sample", "add-user"]
    l_opexplain = [
        "<value>, Check the python package needed to update the system.\n\t\t"
        "Optional parameters: 'input-venv' or 'no-input-venv'",
        "Update the system configuration sample file. Automatically remove sensitive data (eg passwords)\n\t\t"
        "Mainly the following configuration files:\n\t\t"
        "{}/apps/config_sample.py; {}/apps/db_config_sample.py".format(
            PROJECT_PATH, PROJECT_PATH),
        "Add a Root user, generally only used to initialize the user when the site was just created"
    ]

    action = [
        "Update python lib: python {} --up-pylib no-input-venv".format(
            __file__),
        "Update config sample: python {} --up-conf-sample".format(__file__),
        "Add user: python {} --add-user".format(__file__)
    ]

    opts, args = getopt.getopt(sys.argv[1:], s_ops, l_ops)
    for op, value in opts:
        if op == "--up-pylib":
            from apps.core.utils.sys_tool import update_pylib
            if value == "input-venv":
                update_pylib()
            else:
                update_pylib(input_venv_path=False)

        elif op == "--up-conf-sample":
            from apps.core.utils.sys_tool import copy_config_to_sample
            copy_config_to_sample()

        elif op == "--add-user":
            from start import mdb_user
            from apps.core.utils.sys_tool import add_user
            add_user(mdb_user)

        elif op == "-h" or op == "--help":

            usage_help(s_ops, s_opexplain, l_ops, l_opexplain, action=action)
    if not opts:

        usage_help(s_ops, s_opexplain, l_ops, l_opexplain, action=action)
示例#4
0
文件: start.py 项目: txf626/osroom
from signal import signal, SIGCHLD, SIG_IGN

from pymongo.errors import OperationFailure

from apps.configs.config import CONFIG
from apps.core.db.config_mdb import DatabaseConfig
from apps.core.utils.sys_tool import update_pylib, add_user as add_user_process

__author__ = 'all.woo'
'''
manage
'''
# 更新python第三方库
print(" * Check or update Python third-party libraries")
CONFIG["py_venv"]["VENV_PATH"]["value"] = sys.prefix
update_pylib(input_venv_path=False)

# 网站还未启动的时候, 连接数据库, 更新collection
from apps.core.utils.update_db_collection import update_mdb_collections, init_datas
from apps.core.db.mongodb import PyMongo
print(" * Check or update the database collection")
database = DatabaseConfig()
mdb_web = PyMongo()
mdb_sys = PyMongo()
mdb_user = PyMongo()
db_init = 2
while db_init:
    try:
        mdb_web.init_app(config_prefix='MONGO_WEB',
                         db_config=database.MONGO_WEB_URI)
        mdb_sys.init_app(config_prefix='MONGO_SYS',
示例#5
0
@manager.command
def add_user():
    update_mdb_collections(mdbs=mdbs)
    init_datas(mdbs=mdbs)
    add_user_process(mdbs=mdbs)


@manager.command
def dbcoll_to_file():
    """
    更新mdb collections到json文件中
    :return:
    """
    update_mdbcolls_json_file(mdbs=mdbs)


if __name__ == '__main__':
    """
    使用Flask 自带 server启动网站
    """
    print(" * Use the Web service that comes with Flask")
    if "--debug" not in sys.argv and "-D" not in sys.argv:
        # 更新python第三方类库
        print(" * Check or update Python third-party libraries")
        update_pylib()
    else:
        print(" * Using --debug, the system will not check Python dependencies")

    manager.run()