-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathsync_image.py
39 lines (35 loc) · 1.45 KB
/
sync_image.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# coding:utf-8
import subprocess, os
def get_filename():
with open("images.txt", "r") as f:
lines = f.read().split('\n')
# print(lines)
return lines
# def rename():
# name_list= get_filename()
# for name in name_list:
# new_name = "kenwood/" + name.split("/")[-1]
# print(new_name)
def pull_image():
name_list= get_filename()
for name in name_list:
if 'sha256' in name:
print(name)
sha256_name = name.split("@")
new_name = sha256_name[0].split("/")[-1]
tag = sha256_name[-1].split(":")[-1][0:6]
image = "kenwood/" + new_name + ":"+ tag
cmd = "docker tag {0} {1}".format(name, image)
subprocess.call("docker pull {}".format(name), shell=True)
subprocess.run(["docker", "tag", name, image])
subprocess.call("docker login -u kenwood -p qwer1234", shell=True)
subprocess.call("docker push {}".format(image), shell=True)
else:
new_name = "kenwood/" + name.split("/")[-1]
cmd = "docker tag {0} {1}".format(name, new_name)
subprocess.call("docker pull {}".format(name), shell=True)
subprocess.run(["docker", "tag", name, new_name])
subprocess.call("docker login -u kenwood -p qwer1234", shell=True)
subprocess.call("docker push {}".format(new_name), shell=True)
if __name__ == "__main__":
pull_image()