forked from openSUSE/salt-toaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
27 lines (21 loc) · 769 Bytes
/
build.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
import re
import argparse
from utils import build_docker_image
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--nocache', action='store_true', default=False)
parser.add_argument('--nopull', action='store_true', default=False)
args = parser.parse_args()
content = ''
stream = build_docker_image(nocache=args.nocache, pull=not args.nopull)
for item in stream:
if 'error' in item:
raise Exception(item['error'])
buff = item.get('stream', item.get('status', ''))
if not content or re.search('.+\[[. ]*$', content):
content += buff
if not re.search('.+\[[. ]*$', content):
print(content)
content = ''
if __name__ == '__main__':
main()