commit github_commit.sh

This commit is contained in:
unknown
2017-12-07 13:39:33 +08:00
parent fd1b427298
commit 78f17387e4
4 changed files with 53 additions and 2 deletions
+1 -2
View File
@@ -8,6 +8,5 @@ back-end-src/tool_scripts/data/setting/remote.py
front-end-src/dist
front-end-src/node_modules
front-end-src/bower_components
switch_fabfile_env.py
github_commit.sh
fabfile_conf/production.py
*.swp
+7
View File
@@ -0,0 +1,7 @@
conf = {
'env.user': '服务器用户名',
'env.password': '对应密码',
'env.sudo_user': 'root',
'env.sudo_password': 'root用户密码',
'env.hosts': ['服务器IP']
}
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
# 获取该脚本文件本身的绝对路径(必须在cd前执行此操作,因为.和..依赖于当前工作目录,必须在没改变前获取之)
script_file_path=$(readlink -f $0)
base_dir=$(dirname ${script_file_path})
switch_fabfile_env_script_path=${base_dir}"/switch_fabfile_env.py"
switch_setting_script_path=${base_dir}"/back-end-src/tool_scripts/switch_setting.py"
python "${switch_fabfile_env_script_path}" "github"
python "${switch_setting_script_path}" "initial"
git "add" "."
git "commit" "-m" "$1"
git "push" "origin" "master"
python "${switch_fabfile_env_script_path}" "production"
python "${switch_setting_script_path}" "local"
+31
View File
@@ -0,0 +1,31 @@
import os
import sys
if __name__ == "__main__":
if len(sys.argv) != 2:
print('---本程序只接受一个参数,表示要切换到的目标配置')
exit(1)
target_file = sys.argv[1] + '.py'
setting_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'fabfile_conf')
sys.path.insert(0, setting_dir)
extra_setting = __import__(sys.argv[1])
conf_dict = getattr(extra_setting, 'conf')
fabfile_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'fabfile.py')
fabfile_lines = open(fabfile_path, encoding='utf8').readlines()
output_file = open(fabfile_path, 'w', encoding='utf8')
for line in fabfile_lines:
found = False
for variable_name, variable_value in conf_dict.items():
if line.startswith(variable_name):
found = True
if isinstance(variable_value, list):
output_file.write(variable_name + ' = [')
for value in variable_value:
output_file.write('\'' + value + '\'')
output_file.write(']\n')
else:
output_file.write(variable_name + ' = \'' + variable_value + '\'\n')
break
if not found:
output_file.write(line)
output_file.close()