Skip to content

Commit

Permalink
Testing for packer and packer-io executables (fixes #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
obilodeau committed Jul 13, 2016
1 parent 2e707fc commit 0e0255f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion malboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# GNU General Public License for more details.
#
import argparse
from distutils import spawn
import glob
import json
import os
Expand Down Expand Up @@ -197,7 +198,17 @@ def run_packer(packer_config):
print("Starting packer to generate the VM")
print("----------------------------------")

cmd = ['packer', 'build', '-var-file=config.json', packer_config]
# packer or packer-io?
binary = 'packer'
# TODO starting with python 3.3 we could use shutil.which()
if spawn.find_executable(binary) == None:
binary = 'packer-io'
if spawn.find_executable(binary) == None:
print("packer not found. Install it: "
"https://www.packer.io/intro/getting-started/setup.html")
return 254

cmd = [binary, 'build', '-var-file=config.json', packer_config]
ret = run_foreground(cmd)

print("----------------------------------")
Expand Down

0 comments on commit 0e0255f

Please sign in to comment.