add an export option

Add an option to export the list of packages that got installed
to the mirror so that we can use the list to compare
the difference between the requirements (packages to be installed)
and the mirror (what actually got installed)

Change-Id: Ifda23d78ea4f324a145fc0279f4c80dc25570f73
Related-Bug: #1172417
This commit is contained in:
Khai Do 2013-11-19 23:06:46 +00:00
parent 46aca65aee
commit 8eaf6f00e0

View File

@ -92,6 +92,10 @@ class Mirror(object):
parser.add_argument('--no-update', dest='no_update',
action='store_true',
help='do not update any git repos')
parser.add_argument('--export', dest='export_file',
default=None,
help='export installed package list to a file '
'(must be absolute path)')
self.args = parser.parse_args()
self.config = yaml.load(open(self.args.config))
@ -310,6 +314,13 @@ class Mirror(object):
(project, branch, out))
print("pip install did not indicate success")
print("cached:\n%s" % freeze)
# save the list of installed packages to a file
if self.args.export_file:
print("Export installed package list to " +
self.args.export_file)
with open(self.args.export_file, "w") \
as package_list_file:
package_list_file.write(freeze)
else:
print("no requirements")
shutil.rmtree(workdir)