From 7349d9d4cfd932f215c620c50e9e863938514f94 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Sun, 2 Nov 2014 14:05:27 -0500 Subject: [PATCH] Add a new tool for parsing build packs and make sure reparsedockerfile writes it out as well --- tools/parsebuildpack.py | 19 +++++++++++++++++++ tools/reparsedockerfile.py | 3 +++ 2 files changed, 22 insertions(+) create mode 100644 tools/parsebuildpack.py diff --git a/tools/parsebuildpack.py b/tools/parsebuildpack.py new file mode 100644 index 000000000..d253c02fb --- /dev/null +++ b/tools/parsebuildpack.py @@ -0,0 +1,19 @@ +from app import userfiles as user_files + +import workers.dockerfilebuild +import requests + +w = workers.dockerfilebuild.DockerfileBuildWorker(100, None) + +resource_key = '5c0a985c-405d-4161-b0ac-603c3757b5f9' +resource_url = user_files.get_file_url(resource_key, requires_cors=False) +print resource_url + +docker_resource = requests.get(resource_url, stream=True) +c_type = docker_resource.headers['content-type'] + +if ';' in c_type: + c_type = c_type.split(';')[0] + +build_dir = w._mime_processors[c_type](docker_resource) +print build_dir \ No newline at end of file diff --git a/tools/reparsedockerfile.py b/tools/reparsedockerfile.py index 09ac3955f..69c6251a0 100644 --- a/tools/reparsedockerfile.py +++ b/tools/reparsedockerfile.py @@ -21,3 +21,6 @@ if image_and_tag_tuple is None or image_and_tag_tuple[0] is None: raise Exception('Missing FROM command in Dockerfile') print serialize_dockerfile(parsed_dockerfile) + +with open('Dockerfile.test.out', 'w') as dockerfileobj: + dockerfileobj.write(serialize_dockerfile(parsed_dockerfile))