代码拉取完成,页面将自动刷新
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time : 2022/6/17
# @Author : cy
# @Site :
# @File : upload.py
# @Software: PyCharm
import os
import subprocess
import time
import datetime
def upload():
commitMsg = input('请输入提交信息: ')
if len(commitMsg) <= 0:
print('未输入提交信息,load失败')
return
commitTag = input('请输入提交版本号: ')
if len(commitTag) <= 0:
print('未输入版本号,load失败')
return
gitaddCode = execute_command('git add .')
if gitaddCode != 200:
return
gitcommitCode = execute_command('git commit -m ' + commitMsg)
if gitcommitCode != 200:
return
gitpushCode = execute_command('git push')
if gitpushCode != 200:
return
gittagCode = execute_command('git tag ' + commitTag)
if gittagCode != 200:
return
gittagpushCode = execute_command('git push --tags')
if gittagpushCode != 200:
return
agenCode = addagent()
if agenCode != 200:
return
os.system('pod trunk push --verbose --allow-warnings')
print('pod库上传成功')
def addagent():
agentString = 'export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890'
result = execute_command(agentString)
return result
def podtrunk():
print('开始上传pod')
trunkString = 'pod trunk push --verbose --allow-warnings'
result = execute_command(trunkString)
return result
def execute_command(cmdstring=''):
if len(cmdstring) <= 0:
print('请输入命令')
return 0
#超时180秒
end_time = datetime.datetime.now() + datetime.timedelta(seconds=180)
sub = subprocess.Popen(cmdstring, shell=True, stdout=subprocess.PIPE, bufsize=4096)
while True:
if sub.poll() is not None:
break
time.sleep(0.1)
if end_time <= datetime.datetime.now():
sub.kill()
print('执行命令超时')
return 0
if sub.returncode == 0:
print("执行成功 " + cmdstring)
return 200
else:
print("执行失败 " + cmdstring)
return 0
if __name__=='__main__':
upload()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。