Merge lp:~vds/ubuntuone-windows-installer/fix_rss into lp:ubuntuone-windows-installer/beta

Proposed by Vincenzo Di Somma
Status: Merged
Approved by: Rick McBride
Approved revision: 17
Merged at revision: 65
Proposed branch: lp:~vds/ubuntuone-windows-installer/fix_rss
Merge into: lp:ubuntuone-windows-installer/beta
Diff against target: 173 lines (+101/-45)
2 files modified
utils/rss_templates.py (+37/-0)
utils/upload_new_update.py (+64/-45)
To merge this branch: bzr merge lp:~vds/ubuntuone-windows-installer/fix_rss
Reviewer Review Type Date Requested Status
Rick McBride (community) Approve
Manuel de la Peña (community) Approve
Review via email: mp+31272@code.launchpad.net

Description of the change

Switched from manifest to rss.

To post a comment you must log in.
Revision history for this message
Manuel de la Peña (mandel) wrote :

I believe that each item of the RSS feed must have its own uuid, otherwise there use of an uuid does not make any sense, right?

review: Needs Fixing
Revision history for this message
Vincenzo Di Somma (vds) wrote :

Yes, but as it is only for tests there will always be one element right?

Revision history for this message
Manuel de la Peña (mandel) wrote :

> Yes, but as it is only for tests there will always be one element right?

Yes you are right, we can leave it like this for the time being until we move the content and the RSS somewhere else. Can you put a # TODO so that we remember to do it?

Revision history for this message
Manuel de la Peña (mandel) :
review: Approve
Revision history for this message
Rick McBride (rmcbride) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'utils/__init__.py'
=== added file 'utils/rss_templates.py'
--- utils/rss_templates.py 1970-01-01 00:00:00 +0000
+++ utils/rss_templates.py 2010-07-29 12:24:49 +0000
@@ -0,0 +1,37 @@
1# Copyright 2010 Canonical Ltd. All rights reserved.
2"""
3Parameters:
4
5 - lastBuildDate
6 - pubDate format
7 - version
8 - enclosure url
9 - enclosure lenght
10 - sha
11
12"""
13
14from string import Template
15
16
17RSS_TEMPLATE = Template("""
18<rss version="2.0" xmlns:as="http://appsyndication.org/schemas/appsyn">
19 <channel>
20 <title>Ubuntu One Windows Client</title>
21 <generator>WiX Toolset's ClickThrough for Isolated Applications</generator>
22 <lastBuildDate>$lastBuildDate</lastBuildDate>
23 <ttl>1440</ttl>
24 <as:application type="application/vnd.ms-msi">7bb74cea-a4a3-4904-9706-8f4dc764b368</as:application>
25 <item>
26 <guid isPermaLink="false">urn:msi:7bb74cea-a4a3-4904-9706-8f4dc764b368/$version</guid>
27 <pubDate>$pubDate</pubDate>
28 <title>Ubuntu One Windows Client</title>
29 <description>Ubuntu One Windows Client</description>
30 <as:application type="application/vnd.ms-msi">58cdea62-96b2-482b-b046-d884583c8ccd</as:application>
31 <as:version>$version</as:version>
32 <enclosure url="$url" length="$lenght" type="application/octet-stream" />
33 <as:digest algorithm="sha256">$sha</as:digest>
34 </item>
35 </channel>
36</rss>
37""")
038
=== modified file 'utils/upload_new_update.py'
--- utils/upload_new_update.py 2010-07-09 10:11:58 +0000
+++ utils/upload_new_update.py 2010-07-29 12:24:49 +0000
@@ -3,62 +3,81 @@
33
4"""This utilities release an Ubuntu One windows update."""4"""This utilities release an Ubuntu One windows update."""
55
6import os
7import time
8import hashlib
6import sys9import sys
7from zipfile import ZipFile10
8from xml.dom.minidom import parseString
9import boto11import boto
10from boto.s3.key import Key12from boto.s3.key import Key
1113from boto.exception import S3ResponseError
1214
13MANIFEST_NAME = 'ubuntuone.manifest'15from rss_templates import RSS_TEMPLATE
14PACKAGES_BUCKET_PREFIX = 'vds'16
15MANIFEST_BUCKET = 'vds_manifest'17
1618
17def upload_package(name, version, conn, package_filename):19BUCKET = 'u1wintest'
18 """Creates the bucket and upload the package"""20RSS_FILE_NAME = 'rss'
19 new_bucket_name = '%s-%s-%s' % (PACKAGES_BUCKET_PREFIX, name, version)21
20 new_bucket_name = new_bucket_name.lower()22
21 bucket = conn.create_bucket(new_bucket_name)23def upload_package(bucket, filename):
22 print 'New bucket created: %s' % new_bucket_name24 """Upload the package"""
23 k = Key(bucket)25 try:
24 k.key = package_filename26 print 'Removing %s...' % filename
25 k.set_contents_from_filename(package_filename)27 bucket.delete_key(filename)
26 print 'Package uploaded: %s' % package_filename28 except S3ResponseError:
27 bucket.set_acl('public-read', package_filename)29 print 'No previous upload.'
28 print 'Making package public: %s' % package_filename30 print 'Uploading %s...' % filename
2931 k = Key(bucket)
3032 k.key = filename
31def update_manifest(conn, manifest):33 k.set_contents_from_filename(filename)
32 bucket = conn.create_bucket((MANIFEST_BUCKET))34 bucket.set_acl('public-read', filename)
33 k = Key(bucket)35 print "Uploaded!"
34 k.key = 'manifest'36
35 k.set_contents_from_string(manifest)37
36 print 'Manifest updated'38def upload_rss(bucket, filename, rss_params):
37 bucket.set_acl('public-read', 'manifest')39 """Upload the RSS"""
38 print 'Making manifest public'40 now = time.strftime('%d %b %Y %H:%M:%S %Z')
3941 rss_params['lastBuildDate'] = rss_params['pubDate'] = now
4042 fd = open(filename,'r')
41def main(package_filename):43 rss_params['sha'] = hashlib.sha1(fd.read()).hexdigest()
44 rss_params['lenght'] = os.path.getsize(filename)
45 try:
46 print 'Removing rss...'
47 bucket.delete_key(RSS_FILE_NAME)
48 except S3ResponseError:
49 print 'No previous upload'
50 print 'Generating new rss...'
51 rss = RSS_TEMPLATE.substitute(rss_params)
52 print 'Uploading new rss...'
53 k = Key(bucket)
54 k.key = RSS_FILE_NAME
55 k.set_contents_from_string(rss)
56 bucket.set_acl('public-read', RSS_FILE_NAME)
57 print "Uploaded!"
58
59
60def main(filename, rss_params):
42 """ """61 """ """
43 # prepare to upload
44 packagezip = ZipFile(package_filename, 'r')
45 manifest = packagezip.read(MANIFEST_NAME)
46 manifest_dom = parseString(manifest)
47 identity = manifest_dom.getElementsByTagName('assemblyIdentity')[0]
48 name = identity.getAttribute('name')
49 version = identity.getAttribute('version')
50 # connect to S362 # connect to S3
51 print 'Connecting to S3...'63 print 'Connecting to S3...'
52 conn = boto.connect_s3()64 conn = boto.connect_s3()
53 print 'Connected!'65 print 'Connected!'
54 upload_package(name, version, conn, package_filename)66 bucket = conn.get_bucket(BUCKET)
55 update_manifest(conn, manifest)67 upload_package(bucket, filename)
68 upload_rss(bucket, filename, rss_params)
5669
5770
58if __name__ == '__main__':71if __name__ == '__main__':
59 argv = sys.argv72 argv = sys.argv
60 #FIXME check we have AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in the env73 #FIXME check we have AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in the env
61 if len (argv) != 2:74 if len (argv) != 4:
62 print "Usage: upload_new_update.py package_file"75 print "Usage: upload_new_update.py package_file version url"
76 print "example:"
77 print 'python upload_new_update.py u1client.msi 0.0.2 "/u1wintest"'
63 sys.exit()78 sys.exit()
64 sys.exit(main(package_filename=argv[1]))79 package_filename = argv[1]
80 rss_params = {}
81 rss_params['version'] = argv[2]
82 rss_params['url'] = argv[3]
83 sys.exit(main(filename=argv[1], rss_params=rss_params))

Subscribers

People subscribed via source and target branches