~unity-2d-team/unity-2d/Shell-MultiMonitor

« back to all changes in this revision

Viewing changes to grackle/client.py

  • Committer: Aaron Bentley
  • Date: 2012-01-10 15:36:31 UTC
  • mto: (6.1.30 trunk)
  • mto: This revision was merged to the branch mainline in revision 45.
  • Revision ID: aaron@canonical.com-20120110153631-vvqlfg122u08wsrt
Accept arbitrary permalink urls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import httplib
2
 
from urlparse import urlunparse
3
 
from urllib import quote
4
 
 
5
 
 
6
 
def message_path(archive_name, message_id):
7
 
    return '/%s/%s' % (quote(archive_name), quote(message_id))
8
2
 
9
3
 
10
4
class GrackleClient:
13
7
        self.host = host
14
8
        self.port = port
15
9
 
16
 
    def message_url(self, archive_name, message_id):
17
 
        netloc = '%s:%d' % (self.host, self.port)
18
 
        path = message_path(archive_name, message_id)
19
 
        return urlunparse(('http', netloc, path, '', '', ''))
20
 
 
21
 
    def put_message(self, archive_name, message_id, file_obj):
22
 
        url = self.message_url(archive_name, message_id)
 
10
    def put_message(self, archive_name, permalink, file_obj):
23
11
        connection = httplib.HTTPConnection(self.host, self.port)
24
 
        connection.request('PUT', url, file_obj.read())
 
12
        connection.request('PUT', permalink, file_obj.read())
25
13
        response = connection.getresponse()
26
14
        data = response.read()
27
15
        if response.status == httplib.BAD_REQUEST: