diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2012-10-13 22:27:10 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2012-10-13 22:27:10 +0200 |
commit | 46173e352cf3c55ecf9f5892ff83d78c1996da77 (patch) | |
tree | 502236eecfbdad2fee6b83f5147135c4b76ba21f /module/remote/JSONClient.py | |
parent | added JSON and WS client, re organized tests, new classes for easier api tests (diff) | |
download | pyload-46173e352cf3c55ecf9f5892ff83d78c1996da77.tar.xz |
added exceptions for clients, created test for WS client
Diffstat (limited to 'module/remote/JSONClient.py')
-rw-r--r-- | module/remote/JSONClient.py | 8 |
1 files changed, 5 insertions, 3 deletions
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): |