~didrocks/unity/altf10

« back to all changes in this revision

Viewing changes to grackle/client.py

  • Committer: Curtis Hovey
  • Date: 2012-02-29 22:29:35 UTC
  • Revision ID: curtis.hovey@canonical.com-20120229222935-txjobf042vsykgnr
Rename variable for clarity.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
        connection.request(method, url, body)
47
47
        return connection.getresponse()
48
48
 
49
 
    def put_archive(self, archive_id, mbox=None):
50
 
        """Create an archive.
51
 
 
52
 
        :param archive_id: The archive id.
53
 
        :param mbox: An optional mbox with messages to add to the new archive.
54
 
        """
55
 
        response = self._method_archive(
56
 
            'POST', '', {'archive_id': archive_id}, None)
57
 
        response.read()
58
 
        if response.status == httplib.BAD_REQUEST:
59
 
            raise Exception('wtf')
60
 
        elif response.status == httplib.CREATED:
61
 
            return
62
 
        else:
63
 
            raise Exception('!!')
64
 
 
65
49
    def put_message(self, archive_id, key, file_obj):
66
50
        """Put a message into an archive.
67
51
 
70
54
            the message.
71
55
        :param file_obj: The raw text of the message, as a file.
72
56
        """
73
 
        path = '%s/%s' % (archive_id, key)
74
57
        response = self._method_archive(
75
 
            'POST', path, {}, file_obj.read())
 
58
            'POST', archive_id, {'key': key}, file_obj.read())
76
59
        response.read()
77
60
        if response.status == httplib.BAD_REQUEST:
78
61
            raise Exception('wtf')