From 46173e352cf3c55ecf9f5892ff83d78c1996da77 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 13 Oct 2012 22:27:10 +0200 Subject: added exceptions for clients, created test for WS client --- module/remote/JSONClient.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'module/remote/JSONClient.py') diff --git a/module/remote/JSONClient.py b/module/remote/JSONClient.py index 52b712c81..9f678f5bd 100644 --- a/module/remote/JSONClient.py +++ b/module/remote/JSONClient.py @@ -1,10 +1,12 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from json_converter import loads, dumps from urllib import urlopen, urlencode from httplib import UNAUTHORIZED, FORBIDDEN +from json_converter import loads, dumps +from ttypes import Unauthorized, Forbidden + class JSONClient: URL = "http://localhost:8001/api" @@ -19,9 +21,9 @@ class JSONClient: if ret.code == 500: raise Exception("Remote Exception") if ret.code == UNAUTHORIZED: - raise Exception("Unauthorized") + raise Unauthorized() if ret.code == FORBIDDEN: - raise Exception("Forbidden") + raise Forbidden() return ret.read() def login(self, username, password): -- cgit v1.2.3