这里没有sys.exit。我试过,quit
,exit
等等。。
有什么建议吗
try:
print ("Cloning Git Repo")
os.system("git clone " + options.clone_url)
except Exception as e:
print ("Git Clone Failed")
sys.exit(2)
try:
print ("Building Docker Image")
os.system("docker build -t " + options.image_tag + " -f " + repo_name + "/" + DOCKERFILE)
except Exception as e:
print ("Docker Build Failed", e)
sys.exit(2)
try:
print ("Tagging Docker Image")
os.system("docker tag " + options.image_tag + " " + PORTUS_REPO_URL + "/" + options.image_tag)
except Exception as e:
print ("Docker Tag Failed", e)
sys.exit(2)
输出:
Cloning Git Repo
Cloning into 'xxx'...
git@git.hashedin.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Building Docker Image
"docker build" requires exactly 1 argument.
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
Tagging Docker Image
Error parsing reference: "http://portus.hashedin.com/nginx" is not a valid repository/tag: invalid reference format
Pushing Docker Image
我用下面的代码找到了一个修复程序
它工作得很好
从不引发异常,因为os.system未引发异常。请改用子进程Python3 subprocess
使用python3子进程使用下面的代码:https://docs.python.org/3/library/subprocess.html
相关问题 更多 >
编程相关推荐