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

« back to all changes in this revision

Viewing changes to grackle/client.py

  • Committer: Curtis Hovey
  • Date: 2012-03-16 19:38:35 UTC
  • mto: This revision was merged to the branch mainline in revision 45.
  • Revision ID: curtis.hovey@canonical.com-20120316193835-egu5tc1n0xlr5udj
Rename args to be honest about what is expected.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
        self.port = port
28
28
        self.netloc = '%s:%d' % (host, port)
29
29
 
30
 
    def archive_url(self, archive_id, query):
 
30
    def archive_url(self, path, query):
31
31
        """Return the URL for an archive
32
32
 
33
 
        :param archive_id: The id of the archive to generate the URL for.
 
33
        :param oath: The path to generate the URL for.
34
34
        :param query: The query to use in the URL, as a dict.
35
35
        """
36
 
        path = '/archive/%s' % quote(archive_id)
 
36
        path = '/archive/%s' % quote(path)
37
37
        query_string = urlencode(query)
38
38
        return urlunparse(('http', self.netloc, path, '', query_string, ''))
39
39
 
40
40
    def _get_connection(self):
41
41
        return httplib.HTTPConnection(self.host, self.port)
42
42
 
43
 
    def _method_archive(self, method, archive_id, query, body=None):
 
43
    def _method_archive(self, method, path, query, body=None):
44
44
        """Perform an HTTP method on an archive's URL."""
45
 
        url = self.archive_url(archive_id, query)
 
45
        url = self.archive_url(path, query)
46
46
        connection = self._get_connection()
47
47
        connection.request(method, url, body)
48
48
        return connection.getresponse()