Commit 48f71cb6 authored by eric pellegrini's avatar eric pellegrini

bug fixed when setting up templates base dir to cleanup function

parent f59f64b4
...@@ -14,12 +14,14 @@ import sys ...@@ -14,12 +14,14 @@ import sys
from packme import Packman from packme import Packman
def clean_templates_dir(templates_dir): def clean_templates_dir(templates_base_dir):
"""Removes all manifest.json files, packer_cache and builds directories found in """Removes all manifest.json files, packer_cache and builds directories found in
templates directory templates directory
""" """
for template_dir in templates_dir: template_dirs = glob.glob(os.path.join(templates_base_dir,"*"))
for template_dir in template_dirs:
try: try:
os.remove(os.path.join(template_dir,"manifest.json")) os.remove(os.path.join(template_dir,"manifest.json"))
...@@ -45,7 +47,7 @@ def parse_args(): ...@@ -45,7 +47,7 @@ def parse_args():
parser.add_argument("--clean", "-c", dest="clean", action="store_true", help="clean up templates directories") parser.add_argument("--clean", "-c", dest="clean", action="store_true", help="clean up templates directories")
parser.add_argument("--debug", "-d", dest="debug", action="store_true", help="debug mode (keep temporary files)") parser.add_argument("--debug", "-d", dest="debug", action="store_true", help="debug mode (keep temporary files)")
parser.add_argument("--run", "-r", dest="run", action="store_true", help="run packer after json manifest(s) generation") parser.add_argument("--run", "-r", dest="run", action="store_true", help="run packer after json manifest(s) generation")
parser.add_argument("--templates-dir", "-t", dest="templates_dir", required=True, help="Templates base directory") parser.add_argument("--templates-base-dir", "-t", dest="templates_base_dir", required=True, help="Templates base directory")
parser.add_argument("--selected-templates", "-s", dest="selected_templates", nargs="*", default=["*"], help="run packman on selected template(s)") parser.add_argument("--selected-templates", "-s", dest="selected_templates", nargs="*", default=["*"], help="run packman on selected template(s)")
parser.add_argument("--input", "-i", dest="input_file", help="YAML input file") parser.add_argument("--input", "-i", dest="input_file", help="YAML input file")
...@@ -59,7 +61,7 @@ if __name__ == "__main__": ...@@ -59,7 +61,7 @@ if __name__ == "__main__":
args = parse_args() args = parse_args()
input_file = args.input_file input_file = args.input_file
run = args.run run = args.run
templates_dir = args.templates_dir templates_base_dir = args.templates_base_dir
selected_templates = args.selected_templates selected_templates = args.selected_templates
clean = args.clean clean = args.clean
debug = args.debug debug = args.debug
...@@ -67,12 +69,12 @@ if __name__ == "__main__": ...@@ -67,12 +69,12 @@ if __name__ == "__main__":
# If --clean option is set, cleanup the templates dir (builds, packer_cache, manifest.json files and directories) # If --clean option is set, cleanup the templates dir (builds, packer_cache, manifest.json files and directories)
if clean: if clean:
clean_templates_dir(templates_dir) clean_templates_dir(templates_base_dir)
if not input_file: if not input_file:
sys.exit(0) sys.exit(0)
t = Packman.Packman(input_file, templates_dir) t = Packman.Packman(input_file, templates_base_dir)
t.build(selected_templates=selected_templates, indent=4, separators=(',', ': ')) t.build(selected_templates=selected_templates, indent=4, separators=(',', ': '))
...@@ -81,6 +83,6 @@ if __name__ == "__main__": ...@@ -81,6 +83,6 @@ if __name__ == "__main__":
# If --debug option is set, keep temporary files and directories in templates dir (builds, packer_cache, manifest.json) # If --debug option is set, keep temporary files and directories in templates dir (builds, packer_cache, manifest.json)
if not debug: if not debug:
clean_templates_dir(templates_dir) clean_templates_dir(templates_base_dir)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment