~ubuntu-branches/ubuntu/trusty/heat/trusty-security

« back to all changes in this revision

Viewing changes to tools/fetch-cloudformation-examples

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Yolanda Robla, Chuck Short
  • Date: 2013-07-22 16:22:29 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130722162229-zzvfu40id94ii0hc
Tags: 2013.2~b2-0ubuntu1
[ Yolanda Robla ]
* debian/tests: added autopkg tests

[ Chuck Short ]
* New upstream release
* debian/control:
  - Add python-pbr to build-depends.
  - Add python-d2to to build-depends.
  - Dropped python-argparse.
  - Add python-six to build-depends.
  - Dropped python-sendfile.
  - Dropped python-nose.
  - Added testrepository.
  - Added python-testtools.
* debian/rules: Run testrepository instead of nosetets.
* debian/patches/removes-lxml-version-limitation-from-pip-requires.patch: Dropped
  no longer needed.
* debian/patches/fix-package-version-detection-when-building-doc.patch: Dropped
  no longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
 
3
 
import httplib
4
 
import os
5
 
import sys
6
 
import shutil
7
 
import xml.etree.ElementTree as xml
8
 
 
9
 
basepath = os.path.abspath(os.path.join(sys.argv[0],
10
 
    os.path.pardir,
11
 
    os.path.pardir,
12
 
    'templates',
13
 
    'cloudformation-examples'))
14
 
 
15
 
bucket = 'cloudformation-templates-us-east-1'
16
 
 
17
 
def main():
18
 
    conn = httplib.HTTPConnection('s3.amazonaws.com')
19
 
    conn.request('GET', '/%s/' % bucket)
20
 
    resp = conn.getresponse()
21
 
 
22
 
    tree = xml.parse(resp)
23
 
    rootElement = tree.getroot()
24
 
 
25
 
    if os.path.exists(basepath):
26
 
        print 'Deleting %s' % basepath
27
 
        shutil.rmtree(basepath)
28
 
 
29
 
    os.makedirs(basepath)
30
 
    print 'Creating %s' % basepath
31
 
 
32
 
    for entry in rootElement.iter('{http://s3.amazonaws.com/doc/2006-03-01/}Key'):
33
 
        key = entry.text
34
 
        if key.endswith('.html'):
35
 
            continue
36
 
        filename = os.path.join(basepath, key)
37
 
 
38
 
        print 'Writing to %s' % filename
39
 
        conn.request('GET', '/%s/%s' % (bucket, key))
40
 
        resp = conn.getresponse()
41
 
        contents = resp.read()
42
 
 
43
 
        f = open(filename, 'w')
44
 
        f.write(contents)
45
 
        f.close()
46
 
 
47
 
if __name__ == '__main__':
48
 
    main()