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

« back to all changes in this revision

Viewing changes to grackle/client.py

  • Committer: William Grant
  • Date: 2012-01-24 22:54:07 UTC
  • Revision ID: william.grant@canonical.com-20120124225407-8f4cxv3p14njgjnp
Use testtools so we work in python2.6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
def put_message(archive_name, fileobj):
2
 
    pass
 
1
import httplib
 
2
 
 
3
def put_message(archive_name, file_obj):
 
4
    connection = httplib.HTTPConnection('localhost', 8435)
 
5
    connection.request('POST', '/archive/%s' % archive_name, file_obj.read())
 
6
    response = connection.getresponse()
 
7
    data = response.read()
 
8
    if response.status == httplib.BAD_REQUEST:
 
9
        raise Exception('wtf')
 
10
    elif response.status == httplib.CREATED:
 
11
        return
 
12
    else:
 
13
        raise Exception('!!')