Merge lp:~stgraber/ubuntu-archive-tools/amis-add-argparse into lp:ubuntu-archive-tools

Proposed by Stéphane Graber
Status: Merged
Merged at revision: 618
Proposed branch: lp:~stgraber/ubuntu-archive-tools/amis-add-argparse
Merge into: lp:ubuntu-archive-tools
Diff against target: 47 lines (+19/-4)
1 file modified
post-amis-to-iso-tracker (+19/-4)
To merge this branch: bzr merge lp:~stgraber/ubuntu-archive-tools/amis-add-argparse
Reviewer Review Type Date Requested Status
Colin Watson Approve
Review via email: mp+126494@code.launchpad.net

Description of the change

In preparation for the cloud images being posted to the tracker directly from
their nusakan-equivalent machine, I'm adding some argument handling to the
script, allowing the milestone to be overriden from the command line.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'post-amis-to-iso-tracker'
--- post-amis-to-iso-tracker 2012-09-05 15:32:27 +0000
+++ post-amis-to-iso-tracker 2012-09-26 16:29:22 +0000
@@ -16,6 +16,8 @@
1616
17from __future__ import print_function17from __future__ import print_function
1818
19import argparse
20import os
19import sys21import sys
2022
21# import isotracker23# import isotracker
@@ -83,9 +85,22 @@
8385
8486
85def main():87def main():
86 with open(sys.argv[1], 'r') as handle:88 parser = argparse.ArgumentParser(
87 milestone = isotracker.default_milestone()89 description="Publish a provided list of AMIs to the QA tracker.")
8890 parser.add_argument("--milestone", type=isotracker.milestone_code,
91 help="A milestone name to use instead of the default",
92 default=isotracker.default_milestone())
93 parser.add_argument("input_file", type=str,
94 help="An input file (published-ec2-daily.txt)")
95 args = parser.parse_args()
96
97 print("Publishing to milestone: %s" % args.milestone)
98
99 if not os.path.exists(args.input_file):
100 print("Can't find input file: %s" % args.input_file)
101 sys.exit(1)
102
103 with open(args.input_file, 'r') as handle:
89 for line in handle:104 for line in handle:
90 zone, ami, arch, store = line.split()[0:4]105 zone, ami, arch, store = line.split()[0:4]
91 if not ami.startswith('ami-'):106 if not ami.startswith('ami-'):
@@ -99,7 +114,7 @@
99 continue114 continue
100115
101 try:116 try:
102 isotracker.post_build(product, ami, milestone)117 isotracker.post_build(product, ami, args.milestone)
103 except KeyError as e:118 except KeyError as e:
104 print(e)119 print(e)
105 continue120 continue

Subscribers

People subscribed via source and target branches