diff options
author | Vikraman Choudhury <vikraman.choudhury@gmail.com> | 2011-08-22 04:32:27 +0530 |
---|---|---|
committer | Vikraman Choudhury <vikraman.choudhury@gmail.com> | 2011-08-22 04:32:27 +0530 |
commit | 015b806f241c76d31611c7bcf565c89c6af84bfc (patch) | |
tree | a7569fc9d8d26ccc2ace6dcda891e236f3fe6999 | |
parent | fix typo in profile template (diff) | |
download | gentoostats-015b806f241c76d31611c7bcf565c89c6af84bfc.tar.gz gentoostats-015b806f241c76d31611c7bcf565c89c6af84bfc.tar.bz2 gentoostats-015b806f241c76d31611c7bcf565c89c6af84bfc.zip |
fix exceptions
-rwxr-xr-x | client/gentoostats-send | 18 | ||||
-rw-r--r-- | client/gentoostats/list.py | 6 | ||||
-rw-r--r-- | client/gentoostats/search.py | 6 |
3 files changed, 14 insertions, 16 deletions
diff --git a/client/gentoostats-send b/client/gentoostats-send index 49dcb83..324b2bc 100755 --- a/client/gentoostats-send +++ b/client/gentoostats-send @@ -4,7 +4,7 @@ import sys import json import argparse import ConfigParser -import urllib, httplib +import httplib from gentoostats.payload import Payload def getAuthInfo(auth): @@ -63,13 +63,15 @@ def main(): post_body = serialize(post_data, human=True) post_headers = {'Content-type':'application/json'} - conn = httplib.HTTPSConnection(args['server'] + ':' + str(args['port'])) - conn.request('POST', url=post_url, headers=post_headers, body=post_body) - - #TODO: Handle exceptions - response = conn.getresponse() - print response.status, response.reason - print 'Server response: ' + response.read() + try: + conn = httplib.HTTPSConnection(args['server'] + ':' + str(args['port'])) + conn.request('POST', url=post_url, headers=post_headers, body=post_body) + response = conn.getresponse() + print response.status, response.reason + print 'Server response: ' + response.read() + except httplib.HTTPException: + sys.stderr.write('Something went wrong') + sys.exit(1) if __name__ == "__main__": main() diff --git a/client/gentoostats/list.py b/client/gentoostats/list.py index 78ec0e4..3140041 100644 --- a/client/gentoostats/list.py +++ b/client/gentoostats/list.py @@ -1,20 +1,18 @@ +import pprint as pp from gentoostats import utils def pprint(title, object): """ Pretty printer for the decoded json data """ - # TODO: write a custom pretty printer here - import pprint print title - pprint.pprint(object) + pp.pprint(object) def add_parser(subparsers): """ Setup argparse parsers """ - # TODO: add help and descriptions for all opts list_parser = subparsers.add_parser('list') list_subparsers = list_parser.add_subparsers() diff --git a/client/gentoostats/search.py b/client/gentoostats/search.py index dfc4b29..c77c119 100644 --- a/client/gentoostats/search.py +++ b/client/gentoostats/search.py @@ -1,20 +1,18 @@ +import pprint as pp from gentoostats import utils def pprint(title, object): """ Pretty printer for the decoded json data """ - # TODO: write a custom pretty printer here - import pprint print title - pprint.pprint(object) + pp.pprint(object) def add_parser(subparsers): """ Setup argparse parsers """ - # TODO: add help and descriptions for all opts search_parser = subparsers.add_parser('search') search_parser.add_argument('-c', '--category') search_parser.add_argument('-p', '--package') |