From 8eaf6f00e0d02e68a45f1537f729ef3b7dd72493 Mon Sep 17 00:00:00 2001 From: Khai Do Date: Tue, 19 Nov 2013 23:06:46 +0000 Subject: [PATCH] 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 --- pypi_mirror/cmd/run_mirror.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pypi_mirror/cmd/run_mirror.py b/pypi_mirror/cmd/run_mirror.py index b706b15..cec76f4 100644 --- a/pypi_mirror/cmd/run_mirror.py +++ b/pypi_mirror/cmd/run_mirror.py @@ -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)