~ubuntu-branches/ubuntu/maverick/euca2ools/maverick-updates

« back to all changes in this revision

Viewing changes to bin/euca-download-bundle

  • Committer: Bazaar Package Importer
  • Author(s): Dustin Kirkland
  • Date: 2010-03-05 16:59:25 UTC
  • Revision ID: james.westby@ubuntu.com-20100305165925-40rmhda8swzojyva
Tags: 1.2-0ubuntu5
* Cherry pick fixes from upstream, up to bzr r265, fixes:
  - LP: #522398 - throw exceptions instead of sys.exit(1)
  - LP: #522396 - fix version string
  - LP: #523332 - check rsync return code
  - LP: #516738 - upstream fix for image store
  - LP: #525137 - don't sys.exit(1)
  - LP: #526697 - merge upstream fix for this one
  - LP: #531076 - fix euca-describe-instances against one instance
  - LP: #526591 - fix config file parsing

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
import getopt, sys, os
36
36
from xml.dom import minidom
37
 
from euca2ools import Euca2ool, FileValidationError, Util
 
37
from euca2ools import Euca2ool, FileValidationError, Util, ConnectionFailed
38
38
from boto.exception import S3ResponseError
39
39
from boto.s3 import Connection
40
40
from boto.s3.key import Key
57
57
 
58
58
"""
59
59
 
60
 
version_string = """    euca-download-bundle version: 1.0 (BSD)"""
61
60
 
62
 
def usage():
 
61
def usage(status=1):
63
62
    print usage_string
64
63
    Util().usage()
 
64
    sys.exit(status)
65
65
 
66
66
def version():
67
 
    print version_string
 
67
    print Util().version()
68
68
    sys.exit()
69
69
 
70
70
def ensure_bucket(connection, bucket):
141
141
 
142
142
    for name, value in euca.opts:
143
143
        if name in ('-h', '--help'):
144
 
            usage()
 
144
            usage(0)
145
145
        elif name in ('-d', '--directory'):
146
146
            directory = value
147
147
        elif name in ('-b', '--bucket'):
157
157
                print 'Invalid manifest', manifest_path
158
158
                sys.exit(1)
159
159
 
160
 
        conn = euca.make_connection()
 
160
        try:
 
161
            conn = euca.make_connection()
 
162
        except ConnectionFailed, e:
 
163
            print e.message
 
164
            sys.exit(1)
 
165
 
161
166
        bucket_instance = ensure_bucket(conn, bucket)
162
167
        manifests = get_manifests(bucket_instance)
163
168
        download_manifests(bucket_instance, manifests, directory)