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

6 by Aaron Bentley
Use constants.
1
import httplib
6.1.1 by Aaron Bentley
Fix URLs etc.
2
3
4
class GrackleClient:
5
6
    def __init__(self, host, port):
7
        self.host = host
8
        self.port = port
9
6.1.3 by Aaron Bentley
Accept arbitrary permalink urls.
10
    def put_message(self, archive_name, permalink, file_obj):
6.1.1 by Aaron Bentley
Fix URLs etc.
11
        connection = httplib.HTTPConnection(self.host, self.port)
6.1.3 by Aaron Bentley
Accept arbitrary permalink urls.
12
        connection.request('PUT', permalink, file_obj.read())
6.1.1 by Aaron Bentley
Fix URLs etc.
13
        response = connection.getresponse()
14
        data = response.read()
15
        if response.status == httplib.BAD_REQUEST:
16
            raise Exception('wtf')
17
        elif response.status == httplib.CREATED:
18
            return
19
        else:
20
            raise Exception('!!')