Add hacking requirement + fix violations.

Fixes bug 1208288

Change-Id: If6c9ae76402ef0a4d264fed5c02d746d3e9fb832
This commit is contained in:
Joshua Harlow
2013-07-30 22:21:50 -07:00
parent 7de7b9c63c
commit b6a57fbeeb
27 changed files with 84 additions and 93 deletions

View File

@@ -69,9 +69,6 @@ class DependencyHandler(object):
"""Basic class for handler of OpenStack dependencies.
"""
MAX_PIP_DOWNLOAD_ATTEMPTS = 4
multipip_executable = sh.which("multipip", ["tools/"])
pip_executable = sh.which_first(['pip-python', 'pip'])
pipdownload_executable = sh.which("pip-download", ["tools"])
def __init__(self, distro, root_dir, instances, opts=None):
self.distro = distro
@@ -86,7 +83,11 @@ class DependencyHandler(object):
self.gathered_requires_filename = sh.joinpths(self.deps_dir, "pip-requires")
self.forced_requires_filename = sh.joinpths(self.deps_dir, "forced-requires")
self.download_requires_filename = sh.joinpths(self.deps_dir, "download-requires")
# List of requirement strings
# Executables we require to operate
self.multipip_executable = sh.which("multipip", ["tools/"])
self.pip_executable = sh.which_first(['pip-python', 'pip'])
self.pipdownload_executable = sh.which("pip-download", ["tools/"])
# List of requirements
self.pips_to_install = []
self.forced_packages = []
# Instances to there app directory (with a setup.py inside)
@@ -184,7 +185,7 @@ class DependencyHandler(object):
try:
req = pip_helper.extract_requirement(line)
new_lines.append(str(forced_by_key[req.key]))
except:
except Exception:
# we don't force the package or it has a bad format
new_lines.append(line)
contents = "# Cleaned on %s\n\n%s\n" % (utils.iso8601(), "\n".join(new_lines))
@@ -241,7 +242,8 @@ class DependencyHandler(object):
"\n".join(str(req) for req in self.forced_packages))
def filter_download_requires(self):
"""
"""Shrinks the pips that were downloaded into a smaller set.
:returns: a list of all requirements that must be downloaded
:rtype: list of str
"""

View File

@@ -14,12 +14,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import re
import copy
import pkg_resources
from pip import util as pip_util
import re
from pip import req as pip_req
from pip import util as pip_util
from anvil import log as logging
from anvil import shell as sh

View File

@@ -23,12 +23,15 @@ LOG = logging.getLogger(__name__)
class Helper(object):
yyoom_executable = sh.which("yyoom", ["tools/"])
def __init__(self, log_dir):
# Executables we require to operate
self.yyoom_executable = sh.which("yyoom", ["tools/"])
# Executable logs will go into this directory
self._log_dir = log_dir
# Caches of installed and available packages
self._installed = None
self._available = None
self._log_dir = log_dir
def _yyoom(self, arglist, cmd_type):
cmdline = [self.yyoom_executable, '--verbose']

View File

@@ -88,11 +88,7 @@ class YumDependencyHandler(base.DependencyHandler):
" --config-file=/etc/quantum/quantum.conf'"),
}
REPOS = ["anvil-deps", "anvil"]
py2rpm_executable = sh.which("py2rpm", ["tools/"])
rpmbuild_executable = sh.which("rpmbuild")
specprint_executable = sh.which('specprint', ["tools/"])
yumfind_executable = sh.which("yumfind", ["tools/"])
jobs = 2
JOBS = 2
def __init__(self, distro, root_dir, instances, opts=None):
super(YumDependencyHandler, self).__init__(distro, root_dir, instances, opts)
@@ -103,9 +99,13 @@ class YumDependencyHandler(base.DependencyHandler):
self.anvil_repo_filename = sh.joinpths(self.deps_dir, self.REPO_FN)
self.rpm_sources_dir = sh.joinpths(self.rpmbuild_dir, "SOURCES")
self.anvil_repo_dir = sh.joinpths(self.root_dir, "repo")
# Executables we require to operate
self.py2rpm_executable = sh.which("py2rpm", ["tools/"])
self.rpmbuild_executable = sh.which("rpmbuild")
self.specprint_executable = sh.which('specprint', ["tools/"])
self.yumfind_executable = sh.which("yumfind", ["tools/"])
# We inspect yum for packages, this helper allows us to do this.
self.helper = yum_helper.Helper(self.log_dir)
self._no_remove = None
def py2rpm_start_cmdline(self):
cmdline = [
@@ -206,7 +206,7 @@ class YumDependencyHandler(base.DependencyHandler):
utils.log_iterable(src_repo_files,
header=('Building %s RPM packages from their'
' SRPMs for repo %s using %s jobs') %
(len(src_repo_files), self.SRC_REPOS[repo_name], self.jobs),
(len(src_repo_files), self.SRC_REPOS[repo_name], self.JOBS),
logger=LOG)
makefile_path = sh.joinpths(self.deps_dir, "binary-%s.mk" % repo_name)
marks_dir = sh.joinpths(self.deps_dir, "marks-binary")
@@ -233,7 +233,7 @@ class YumDependencyHandler(base.DependencyHandler):
self._create_repo(repo_name)
def _execute_make(self, filename, marks_dir):
cmdline = ["make", "-f", filename, "-j", str(self.jobs)]
cmdline = ["make", "-f", filename, "-j", str(self.JOBS)]
out_filename = sh.joinpths(self.log_dir, "%s.log" % sh.basename(filename))
sh.execute_save_output(cmdline, cwd=marks_dir, out_filename=out_filename)
@@ -393,7 +393,7 @@ class YumDependencyHandler(base.DependencyHandler):
sh.write_file(makefile_path, utils.expand_template(content, params),
tracewriter=self.tracewriter)
utils.log_iterable(package_files,
header="Building %s SRPM packages using %s jobs" % (len(package_files), self.jobs),
header="Building %s SRPM packages using %s jobs" % (len(package_files), self.JOBS),
logger=LOG)
self._execute_make(makefile_path, marks_dir)