Skip to content

Commit

Permalink
added default container and added check for printed components
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagofilipe12 committed Nov 8, 2018
1 parent 235a529 commit 001a4f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
20 changes: 18 additions & 2 deletions flowcraft/generator/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1533,6 +1533,10 @@ def fetch_docker_tags(self):
the -t flag.
"""

# list to store the already parsed components (useful when forks are
# given to the pipeline string via -t flag
list_of_parsed = []

# fetches terminal width and subtracts 3 because we always add a
# new line character and we want a space at the beggining and at the end
# of each line
Expand Down Expand Up @@ -1562,12 +1566,20 @@ def fetch_docker_tags(self):
# Skip first init process and iterate through the others
for p in self.processes[1:]:
template = p.template
# if component has already been printed then skip and don't print
# again
if template in list_of_parsed:
continue

list_of_parsed.append(template)

# fetch repo name from directives of the template. Since some
# components like integrity_coverage doesn't have a directives with
# container, thus if no directive there the script will skip this
# template
try:
repo = p.directives[template]["container"]
default_version = p.directives[template]["version"]
except KeyError:
continue
# make the request to docker hub
Expand All @@ -1581,7 +1593,10 @@ def fetch_docker_tags(self):
# parse response content to dict and fetch results key
r_content = json.loads(r.content)["results"]
for version in r_content:
tags_list.append([template, repo, version["name"]])
printed_version = (version["name"] + "*") \
if version["name"] == default_version \
else version["name"]
tags_list.append([template, repo, printed_version])
else:
tags_list.append([template, repo, "No DockerHub tags"])

Expand All @@ -1607,7 +1622,8 @@ def fetch_docker_tags(self):
*entry, *final_width), color)
)
# assures that the entire line gets the same color
sys.stdout.write("\n")
sys.stdout.write("\n{0: >{1}}\n".format("(* = default)",
terminal_width + 3))

def build(self):
"""Main pipeline builder
Expand Down
1 change: 1 addition & 0 deletions flowcraft/templates/mashdist2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def main(mash_output, hash_cutoff, sample_id, assembly_file):
# assures that file is closed in last iteration of the loop
send_to_output(master_dict, mash_output, sample_id, assembly_file)


if __name__ == "__main__":

main(MASH_TXT, HASH_CUTOFF, SAMPLE_ID, ASSEMBLY_IN)

0 comments on commit 001a4f6

Please sign in to comment.