예제 #1
0
파일: JSONClient.py 프로젝트: keat01/pyLoad
 def login(self, username, password):
     self.session = loads(
         self.request("/login", {
             'username': username,
             'password': password
         }))
     return self.session
예제 #2
0
파일: JSONClient.py 프로젝트: keat01/pyLoad
 def call(self, func, *args, **kwargs):
     # Add the current session
     kwargs["session"] = self.session
     path = "/" + func + "/" + "/".join(dumps(x) for x in args)
     data = dict((k, dumps(v)) for k, v in kwargs.iteritems())
     rep = self.request(path, data)
     return loads(rep)
예제 #3
0
파일: JSONClient.py 프로젝트: keat01/pyLoad
 def call(self, func, *args, **kwargs):
     # Add the current session
     kwargs["session"] = self.session
     path = "/" + func + "/" + "/".join(dumps(x) for x in args)
     data = dict((k, dumps(v)) for k, v in kwargs.iteritems())
     rep = self.request(path, data)
     return loads(rep)
예제 #4
0
 def request(self, path, data):
     ret = urlopen(self.url + path, urlencode(data))
     if ret.code == 400:
         raise loads(ret.read())
     if ret.code == 404:
         raise AttributeError("Unknown Method")
     if ret.code == 500:
         raise Exception("Remote Exception")
     if ret.code == UNAUTHORIZED:
         raise Unauthorized()
     if ret.code == FORBIDDEN:
         raise Forbidden()
     return ret.read()
예제 #5
0
 def request(self, path, data):
     ret = urlopen(self.url + path, urlencode(data))
     if ret.code == 400:
         raise loads(ret.read())
     if ret.code == 404:
         raise AttributeError("Unknown Method")
     if ret.code == 500:
         raise Exception("Remote Exception")
     if ret.code == UNAUTHORIZED:
         raise Unauthorized()
     if ret.code == FORBIDDEN:
         raise Forbidden()
     return ret.read()
예제 #6
0
파일: WSClient.py 프로젝트: keat01/pyLoad
    def call(self, func, *args, **kwargs):
        if not self.ws:
            raise Exception("Not Connected")

        if kwargs:
            self.ws.send(dumps([func, args, kwargs]))
        else:  # omit kwargs
            self.ws.send(dumps([func, args]))

        code, result = loads(self.ws.recv())
        if code == 404:
            raise AttributeError("Unknown Method")
        elif code == 500:
            raise Exception("Remote Exception: %s" % result)
        elif code == UNAUTHORIZED:
            raise Unauthorized()
        elif code == FORBIDDEN:
            raise Forbidden()

        return result
예제 #7
0
파일: WSClient.py 프로젝트: keat01/pyLoad
    def call(self, func, *args, **kwargs):
        if not self.ws:
            raise Exception("Not Connected")

        if kwargs:
            self.ws.send(dumps([func, args, kwargs]))
        else: # omit kwargs
            self.ws.send(dumps([func, args]))

        code, result = loads(self.ws.recv())
        if code == 404:
            raise AttributeError("Unknown Method")
        elif code == 500:
            raise Exception("Remote Exception: %s" % result)
        elif code == UNAUTHORIZED:
            raise Unauthorized()
        elif code == FORBIDDEN:
            raise Forbidden()

        return result
예제 #8
0
파일: JSONClient.py 프로젝트: keat01/pyLoad
 def login(self, username, password):
     self.session = loads(self.request("/login", {"username": username, "password": password}))
     return self.session
예제 #9
0
 def login(self, username, password):
     self.session = loads(self.request("/login", {'username': username, 'password': password}))
     return self.session