Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage==3.7.1
coverage
nose
nose-cov
testtools
testtools
12 changes: 6 additions & 6 deletions packer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ def __init__(self, packerfile, exc=None, only=None, vars=None,
self.packer = sh.Command(exec_path)
self.packer = self.packer.bake(**kwargs)

def build(
self, parallel=True, debug=False, force=False,
machine_readable=False):
def build(self, parallel=True, debug=False, force=False,
machine_readable=False):
"""Executes a `packer build`

:param bool parallel: Run builders in parallel
Expand Down Expand Up @@ -74,8 +73,8 @@ def fix(self, to_file=None):
result = self.packer_cmd()
if to_file:
with open(to_file, 'w') as f:
f.write(result.stdout)
result.fixed = json.loads(result.stdout)
f.write(result.stdout.decode())
result.fixed = json.loads(result.stdout.decode())
return result

def inspect(self, mrf=True):
Expand Down Expand Up @@ -115,7 +114,8 @@ def inspect(self, mrf=True):

result = self.packer_cmd()
if mrf:
result.parsed_output = self._parse_inspection_output(result.stdout)
result.parsed_output = self._parse_inspection_output(
result.stdout.decode())
else:
result.parsed_output = None
return result
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def read(*parts):
description='A Python interface for Hashicorp\'s Packer',
long_description=read('README.rst'),
py_modules=['packer'],
install_requires=["sh==1.11"],
install_requires=["sh"],
classifiers=[
'Programming Language :: Python',
'Natural Language :: English',
Expand Down
10 changes: 10 additions & 0 deletions tests/resources/simple-test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"builders": [
{
"type": "null",
"ssh_host": "127.0.0.1",
"ssh_username": "root",
"ssh_password": "password"
}
]
}
2 changes: 1 addition & 1 deletion tests/test_packer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

PACKER_PATH = '/usr/bin/packer'
TEST_RESOURCES_DIR = 'tests/resources'
TEST_PACKERFILE = os.path.join(TEST_RESOURCES_DIR, 'packerfile.json')
TEST_PACKERFILE = os.path.join(TEST_RESOURCES_DIR, 'simple-test.json')
TEST_BAD_PACKERFILE = os.path.join(TEST_RESOURCES_DIR, 'badpackerfile.json')


Expand Down
9 changes: 2 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
# content of: tox.ini , put in same dir as setup.py
[tox]
envlist=flake8,py27,py26
envlist=flake8,py27,py26,py35

[testenv:py26]
deps =
-rdev-requirements.txt
commands=nosetests --with-cov --cov-report term-missing --cov packer tests -v

[testenv:py27]
[testenv]
deps =
-rdev-requirements.txt
commands=nosetests --with-cov --cov-report term-missing --cov packer tests -v
Expand Down