1import sys
2import urllib2
3
4sys.path.append('lib')
5
6from builds.build_query import BuildQuery
7
8if __name__ == "__main__":
9    args = sys.argv
10    if len(args) == 2:
11        version = args[1]
12        builds, changes = BuildQuery().get_all_builds(version=version)
13        build = BuildQuery().find_membase_build_with_version(builds, version)
14        if build.change and build.change.url:
15            try:
16                print "downloading {0}".format(build.change.url)
17                page = urllib2.urlopen(build.change.url)
18                changes = open('changes.txt', 'w')
19                changes.write('{0}'.format(page.read()))
20                changes.close()
21            except urllib2.HTTPError as error:
22                print 'unable to download {0}'.format(build.change.url)
23