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
1=== modified file 'post-amis-to-iso-tracker'
2--- post-amis-to-iso-tracker 2012-09-05 15:32:27 +0000
3+++ post-amis-to-iso-tracker 2012-09-26 16:29:22 +0000
4@@ -16,6 +16,8 @@
5
6 from __future__ import print_function
7
8+import argparse
9+import os
10 import sys
11
12 # import isotracker
13@@ -83,9 +85,22 @@
14
15
16 def main():
17- with open(sys.argv[1], 'r') as handle:
18- milestone = isotracker.default_milestone()
19-
20+ parser = argparse.ArgumentParser(
21+ description="Publish a provided list of AMIs to the QA tracker.")
22+ parser.add_argument("--milestone", type=isotracker.milestone_code,
23+ help="A milestone name to use instead of the default",
24+ default=isotracker.default_milestone())
25+ parser.add_argument("input_file", type=str,
26+ help="An input file (published-ec2-daily.txt)")
27+ args = parser.parse_args()
28+
29+ print("Publishing to milestone: %s" % args.milestone)
30+
31+ if not os.path.exists(args.input_file):
32+ print("Can't find input file: %s" % args.input_file)
33+ sys.exit(1)
34+
35+ with open(args.input_file, 'r') as handle:
36 for line in handle:
37 zone, ami, arch, store = line.split()[0:4]
38 if not ami.startswith('ami-'):
39@@ -99,7 +114,7 @@
40 continue
41
42 try:
43- isotracker.post_build(product, ami, milestone)
44+ isotracker.post_build(product, ami, args.milestone)
45 except KeyError as e:
46 print(e)
47 continue

Subscribers

People subscribed via source and target branches