Commit d79e3f93 authored by Kai Lautaportti's avatar Kai Lautaportti

PEP8/pyflakes cleanup.

parent 7efe6c6d
import hexagonit.recipe.download
import errno import errno
import hexagonit.recipe.download
import imp import imp
import logging import logging
import os import os
...@@ -7,6 +7,7 @@ import shutil ...@@ -7,6 +7,7 @@ import shutil
import subprocess import subprocess
import zc.buildout import zc.buildout
class Recipe(object): class Recipe(object):
"""zc.buildout recipe for compiling and installing software""" """zc.buildout recipe for compiling and installing software"""
...@@ -82,7 +83,6 @@ class Recipe(object): ...@@ -82,7 +83,6 @@ class Recipe(object):
# the third parameter # the third parameter
script(self.options, self.buildout) script(self.options, self.buildout)
def run(self, cmd): def run(self, cmd):
"""Run the given ``cmd`` in a child process.""" """Run the given ``cmd`` in a child process."""
log = logging.getLogger(self.name) log = logging.getLogger(self.name)
...@@ -99,7 +99,6 @@ class Recipe(object): ...@@ -99,7 +99,6 @@ class Recipe(object):
log.error('Command failed: %s: %s' % (e, cmd)) log.error('Command failed: %s: %s' % (e, cmd))
raise zc.buildout.UserError('System error') raise zc.buildout.UserError('System error')
def install(self): def install(self):
log = logging.getLogger(self.name) log = logging.getLogger(self.name)
parts = [] parts = []
...@@ -108,7 +107,7 @@ class Recipe(object): ...@@ -108,7 +107,7 @@ class Recipe(object):
make_options = ' '.join(self.options.get('make-options', '').split()) make_options = ' '.join(self.options.get('make-options', '').split())
make_targets = ' '.join(self.options.get('make-targets', 'install').split()) make_targets = ' '.join(self.options.get('make-targets', 'install').split())
configure_options = self.options.get('configure-options','').split() configure_options = self.options.get('configure-options', '').split()
configure_cmd = self.options.get('configure-command', '').strip() configure_cmd = self.options.get('configure-command', '').strip()
if not configure_cmd: if not configure_cmd:
......
...@@ -13,15 +13,17 @@ import zc.buildout ...@@ -13,15 +13,17 @@ import zc.buildout
import zc.buildout.testing import zc.buildout.testing
import zc.buildout.tests import zc.buildout.tests
optionflags = (doctest.ELLIPSIS | optionflags = (doctest.ELLIPSIS |
doctest.NORMALIZE_WHITESPACE | doctest.NORMALIZE_WHITESPACE |
doctest.REPORT_ONLY_FIRST_FAILURE) doctest.REPORT_ONLY_FIRST_FAILURE)
def setUp(test): def setUp(test):
zc.buildout.testing.buildoutSetUp(test) zc.buildout.testing.buildoutSetUp(test)
zc.buildout.testing.install('hexagonit.recipe.download', test) zc.buildout.testing.install('hexagonit.recipe.download', test)
zc.buildout.testing.install_develop('hexagonit.recipe.cmmi', test) zc.buildout.testing.install_develop('hexagonit.recipe.cmmi', test)
class NonInformativeTests(unittest.TestCase): class NonInformativeTests(unittest.TestCase):
def setUp(self): def setUp(self):
...@@ -33,7 +35,7 @@ class NonInformativeTests(unittest.TestCase): ...@@ -33,7 +35,7 @@ class NonInformativeTests(unittest.TestCase):
if var.startswith('HRC_'): if var.startswith('HRC_'):
del os.environ[var] del os.environ[var]
def write_file(self, filename, contents, mode=stat.S_IREAD|stat.S_IWUSR): def write_file(self, filename, contents, mode=stat.S_IREAD | stat.S_IWUSR):
path = os.path.join(self.dir, filename) path = os.path.join(self.dir, filename)
fh = open(path, 'w') fh = open(path, 'w')
fh.write(contents) fh.write(contents)
...@@ -50,9 +52,9 @@ class NonInformativeTests(unittest.TestCase): ...@@ -50,9 +52,9 @@ class NonInformativeTests(unittest.TestCase):
if e.errno != errno.EEXIST: if e.errno != errno.EEXIST:
raise raise
bo = { bo = {
'buildout' : { 'buildout': {
'parts-directory' : parts_directory_path, 'parts-directory': parts_directory_path,
'directory' : self.dir, 'directory': self.dir,
} }
} }
bo.update(buildout) bo.update(buildout)
...@@ -61,7 +63,7 @@ class NonInformativeTests(unittest.TestCase): ...@@ -61,7 +63,7 @@ class NonInformativeTests(unittest.TestCase):
def test_working_directory_restored_after_failure(self): def test_working_directory_restored_after_failure(self):
compile_directory = os.path.join(self.dir, 'compile_directory') compile_directory = os.path.join(self.dir, 'compile_directory')
os.makedirs(compile_directory) os.makedirs(compile_directory)
recipe = self.make_recipe({}, 'test', {'path' : compile_directory}) recipe = self.make_recipe({}, 'test', {'path': compile_directory})
os.chdir(self.dir) os.chdir(self.dir)
self.assertRaises(zc.buildout.UserError, recipe.install) self.assertRaises(zc.buildout.UserError, recipe.install)
...@@ -72,7 +74,7 @@ class NonInformativeTests(unittest.TestCase): ...@@ -72,7 +74,7 @@ class NonInformativeTests(unittest.TestCase):
os.makedirs(compile_directory) os.makedirs(compile_directory)
self.write_file(os.path.join(compile_directory, 'configure'), 'Dummy configure') self.write_file(os.path.join(compile_directory, 'configure'), 'Dummy configure')
recipe = self.make_recipe({}, 'test', {'path' : compile_directory}) self.make_recipe({}, 'test', {'path': compile_directory})
os.chdir(self.dir) os.chdir(self.dir)
self.assertEquals(self.dir, os.getcwd()) self.assertEquals(self.dir, os.getcwd())
...@@ -107,7 +109,7 @@ class NonInformativeTests(unittest.TestCase): ...@@ -107,7 +109,7 @@ class NonInformativeTests(unittest.TestCase):
tar.add('Makefile') tar.add('Makefile')
tar.close() tar.close()
recipe = self.make_recipe({}, 'test', {'url' : tarfile_path}) recipe = self.make_recipe({}, 'test', {'url': tarfile_path})
os.chdir(self.dir) os.chdir(self.dir)
try: try:
...@@ -137,8 +139,8 @@ class NonInformativeTests(unittest.TestCase): ...@@ -137,8 +139,8 @@ class NonInformativeTests(unittest.TestCase):
self.assertEquals(os.environ.get('HRC_SENTINEL'), 'sentinel') self.assertEquals(os.environ.get('HRC_SENTINEL'), 'sentinel')
recipe = self.make_recipe({}, 'test', { recipe = self.make_recipe({}, 'test', {
'url' : 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__), 'url': 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__),
'environment' : 'HRC_FOO=bar\nHRC_BAR=foo'}) 'environment': 'HRC_FOO=bar\nHRC_BAR=foo'})
os.chdir(self.dir) os.chdir(self.dir)
recipe.install() recipe.install()
...@@ -151,13 +153,12 @@ class NonInformativeTests(unittest.TestCase): ...@@ -151,13 +153,12 @@ class NonInformativeTests(unittest.TestCase):
def test_run__unknown_command(self): def test_run__unknown_command(self):
recipe = self.make_recipe({}, 'test', { recipe = self.make_recipe({}, 'test', {
'url' : 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__)}) 'url': 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__)})
self.assertRaises(zc.buildout.UserError, lambda:recipe.run('this-command-does-not-exist')) self.assertRaises(zc.buildout.UserError, lambda: recipe.run('this-command-does-not-exist'))
def test_call_script__bbb_for_callable_with_two_parameters(self): def test_call_script__bbb_for_callable_with_two_parameters(self):
recipe = self.make_recipe({}, 'test', { recipe = self.make_recipe({}, 'test', {
'url' : 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__), 'url': 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__),
}) })
# The hook script does not return anything so we (ab)use exceptions # The hook script does not return anything so we (ab)use exceptions
...@@ -178,8 +179,8 @@ class NonInformativeTests(unittest.TestCase): ...@@ -178,8 +179,8 @@ class NonInformativeTests(unittest.TestCase):
os.environ['HRC_TESTVAR'] = 'foo' os.environ['HRC_TESTVAR'] = 'foo'
recipe = self.make_recipe({}, 'test', { recipe = self.make_recipe({}, 'test', {
'url' : 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__), 'url': 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__),
'environment' : 'HRC_TESTVAR=bar' 'environment': 'HRC_TESTVAR=bar'
}) })
# The hook script does not return anything so we (ab)use exceptions # The hook script does not return anything so we (ab)use exceptions
......
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