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']
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)
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(".", "")
def _set_email(self, request): if "email" not in request: raise IncompleteRequestBody("email parameter not found in request") else: self.email = request["email"]
def _set_output(self, request): if "output" not in request: raise IncompleteRequestBody( "output parameter not found in request") else: self.output = request["output"]
def _set_debug(self, request): if "debug" not in request: raise IncompleteRequestBody("debug parameter not found in request") else: self.debug = request["debug"]
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"]
def _set_version(self, request): if "version" not in request: raise IncompleteRequestBody("version not found in request") else: self.version = request["version"]
def _set_device(self, request): if "device" not in request: raise IncompleteRequestBody("device not found in request") else: self.device = request["device"]
def _set_timestamp(self, request): if "timestamp" not in request: raise IncompleteRequestBody("timestamp not found in request") else: self.timestamp = request["timestamp"] / 1000