Beispiel #1
0
 def _set_human_translation_requested(self, request):
     if "human_translation_requested" not in request:
         raise IncompleteRequestBody("human_translation_requested not found"
                                     " in request")
     else:
         self.human_translation_requested = request[
             'human_translation_requested']
Beispiel #2
0
    def _set_image(self, request):
        if "image" not in request:
            raise IncompleteRequestBody("image not found in request")

        try:
            self.image = UserImage(request['image'])
        except Exception as ex:
            logger.error("Caught an exception while decoding image")
            logger.error("Message was = {}".format(ex.message))
            raise ImageDecodingException(ex.message)
Beispiel #3
0
    def __init__(self, request):
        try:
            self.request = loads(request)
        except ValueError:
            raise JSONMalformed("Json malformed.")
        except Exception as ex:
            raise Exception("Unknown exception: {}".format(ex.message))

        if "version" not in self.request:
            raise IncompleteRequestBody("version not found in request")
        else:
            self.version = str(self.request["version"]).replace(".", "")
Beispiel #4
0
 def _set_email(self, request):
     if "email" not in request:
         raise IncompleteRequestBody("email parameter not found in request")
     else:
         self.email = request["email"]
Beispiel #5
0
 def _set_output(self, request):
     if "output" not in request:
         raise IncompleteRequestBody(
             "output parameter not found in request")
     else:
         self.output = request["output"]
Beispiel #6
0
 def _set_debug(self, request):
     if "debug" not in request:
         raise IncompleteRequestBody("debug parameter not found in request")
     else:
         self.debug = request["debug"]
Beispiel #7
0
 def _set_user_id(self, request):
     if "user_id" not in request:
         raise IncompleteRequestBody("user_id not found in request")
     else:
         self.user_id = request["user_id"]
Beispiel #8
0
 def _set_version(self, request):
     if "version" not in request:
         raise IncompleteRequestBody("version not found in request")
     else:
         self.version = request["version"]
Beispiel #9
0
 def _set_device(self, request):
     if "device" not in request:
         raise IncompleteRequestBody("device not found in request")
     else:
         self.device = request["device"]
Beispiel #10
0
 def _set_timestamp(self, request):
     if "timestamp" not in request:
         raise IncompleteRequestBody("timestamp not found in request")
     else:
         self.timestamp = request["timestamp"] / 1000