1 Star 0 Fork 25

zhangshun/osroom

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
osr-tool.py 2.03 KB
一键复制 编辑 原始数据 按行查看 历史
HiWoo 提交于 2018-05-10 02:23 . dev1
# -*-coding:utf-8-*-
import getopt
import sys
from apps.configs.sys_config import PROJECT_PATH
__author__ = "Allen Woo"
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)
if __name__ == '__main__':
main()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/zhangshun/osroom.git
git@gitee.com:zhangshun/osroom.git
zhangshun
osroom
osroom
dev

搜索帮助