Refactor if: nesting in build_mirror
Change-Id: Ia0fe43e1f44704d5d93235ceadfcf74d00aa190b
This commit is contained in:
@@ -235,8 +235,7 @@ class Mirror(object):
|
|||||||
if (not branch.startswith("remotes/origin")
|
if (not branch.startswith("remotes/origin")
|
||||||
or "origin/HEAD" in branch):
|
or "origin/HEAD" in branch):
|
||||||
continue
|
continue
|
||||||
print("Fetching pip requires for %s:%s" %
|
print("Fetching pip requires for %s:%s" % (project, branch))
|
||||||
(project, branch))
|
|
||||||
if not self.args.no_update:
|
if not self.args.no_update:
|
||||||
self.run_command("git reset --hard %s" % branch)
|
self.run_command("git reset --hard %s" % branch)
|
||||||
self.run_command("git clean -x -f -d -q")
|
self.run_command("git clean -x -f -d -q")
|
||||||
@@ -250,12 +249,14 @@ class Mirror(object):
|
|||||||
"tools/test-requires"):
|
"tools/test-requires"):
|
||||||
if os.path.exists(requires_file):
|
if os.path.exists(requires_file):
|
||||||
reqlist.append(requires_file)
|
reqlist.append(requires_file)
|
||||||
if reqlist:
|
if not reqlist:
|
||||||
|
print("no requirements")
|
||||||
|
continue
|
||||||
|
|
||||||
self.run_command(
|
self.run_command(
|
||||||
venv_format % dict(
|
venv_format % dict(
|
||||||
extra_search_dir=pip_cache_dir, venv_dir=venv))
|
extra_search_dir=pip_cache_dir, venv_dir=venv))
|
||||||
for requirement in [
|
for requirement in ["pip", "wheel", "virtualenv"]:
|
||||||
"pip", "wheel", "virtualenv"]:
|
|
||||||
self.run_command(
|
self.run_command(
|
||||||
upgrade_format % dict(
|
upgrade_format % dict(
|
||||||
pip=pip, download_cache=pip_cache_dir,
|
pip=pip, download_cache=pip_cache_dir,
|
||||||
@@ -291,7 +292,8 @@ class Mirror(object):
|
|||||||
"failed.\n%s\n" %
|
"failed.\n%s\n" %
|
||||||
(project, branch, out))
|
(project, branch, out))
|
||||||
print("pip install did not indicate success")
|
print("pip install did not indicate success")
|
||||||
else:
|
continue
|
||||||
|
|
||||||
freeze = self.run_command("%s freeze -l" % pip)
|
freeze = self.run_command("%s freeze -l" % pip)
|
||||||
requires = self.find_pkg_info(build)
|
requires = self.find_pkg_info(build)
|
||||||
reqfd = open(reqs, "w")
|
reqfd = open(reqs, "w")
|
||||||
@@ -304,8 +306,7 @@ class Mirror(object):
|
|||||||
reqfd.close()
|
reqfd.close()
|
||||||
self.run_command(venv_format % dict(
|
self.run_command(venv_format % dict(
|
||||||
extra_search_dir=pip_cache_dir, venv_dir=venv))
|
extra_search_dir=pip_cache_dir, venv_dir=venv))
|
||||||
for requirement in [
|
for requirement in ["pip", "wheel"]:
|
||||||
"pip", "wheel"]:
|
|
||||||
self.run_command(
|
self.run_command(
|
||||||
upgrade_format % dict(
|
upgrade_format % dict(
|
||||||
pip=pip, download_cache=pip_cache_dir,
|
pip=pip, download_cache=pip_cache_dir,
|
||||||
@@ -333,11 +334,8 @@ class Mirror(object):
|
|||||||
if self.args.export_file:
|
if self.args.export_file:
|
||||||
print("Export installed package list to " +
|
print("Export installed package list to " +
|
||||||
self.args.export_file)
|
self.args.export_file)
|
||||||
with open(self.args.export_file, "w") \
|
with open(self.args.export_file, "w") as package_list_file:
|
||||||
as package_list_file:
|
|
||||||
package_list_file.write(freeze)
|
package_list_file.write(freeze)
|
||||||
else:
|
|
||||||
print("no requirements")
|
|
||||||
shutil.rmtree(workdir)
|
shutil.rmtree(workdir)
|
||||||
|
|
||||||
def _get_distro(self):
|
def _get_distro(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user