def process_getCapabilities(self, seqid, iprot, oprot):
     args = getCapabilities_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = getCapabilities_result()
     try:
         result.success = self._handler.getCapabilities()
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except concrete.services.ttypes.ServicesException as ex:
         msg_type = TMessageType.REPLY
         result.ex = ex
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("getCapabilities", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
 def process_annotate(self, seqid, iprot, oprot):
     args = annotate_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = annotate_result()
     try:
         result.success = self._handler.annotate(args.original)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except concrete.exceptions.ttypes.ConcreteThriftException as ex:
         msg_type = TMessageType.REPLY
         result.ex = ex
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("annotate", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 3
0
 def process_retrieveRequestToken(self, seqid, iprot, oprot):
     args = retrieveRequestToken_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = retrieveRequestToken_result()
     try:
         result.success = self._handler.retrieveRequestToken(args.carrier)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TalkException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("retrieveRequestToken", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
def write_results_after_future(
    result, event_handler, handler_ctx, seqid, oprot, fn_name,
    known_exceptions, future,
):
    """Result/exception handler for asyncio futures."""
    try:
        try:
            result.success = future.result()
            reply_type = TMessageType.REPLY
        except TException as e:
            for exc_name, exc_type in known_exceptions.items():
                setattr(result, exc_name, e)
                reply_type = TMessageType.REPLY
                event_handler.handlerException(handler_ctx, fn_name, e)
                break
            else:
                raise
    except Exception as e:
        result = TApplicationException(message=str(e))
        reply_type = TMessageType.EXCEPTION
        event_handler.handlerError(handler_ctx, fn_name, e)

    event_handler.preWrite(handler_ctx, fn_name, result)
    oprot.writeMessageBegin(fn_name, reply_type, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()
    event_handler.postWrite(handler_ctx, fn_name, result)
 def process_failRequestV2(self, seqid, iprot, oprot):
     args = failRequestV2_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = failRequestV2_result()
     try:
         self._handler.failRequestV2(args.id, args.e)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except AuthorizationException as aze:
         msg_type = TMessageType.REPLY
         result.aze = aze
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("failRequestV2", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 6
0
 def process_sendSupervisorWorkerHeartbeat(self, seqid, iprot, oprot):
     args = sendSupervisorWorkerHeartbeat_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = sendSupervisorWorkerHeartbeat_result()
     try:
         self._handler.sendSupervisorWorkerHeartbeat(args.heartbeat)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except AuthorizationException as aze:
         msg_type = TMessageType.REPLY
         result.aze = aze
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("sendSupervisorWorkerHeartbeat", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 7
0
 def process_getLocalAssignmentForStorm(self, seqid, iprot, oprot):
     args = getLocalAssignmentForStorm_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = getLocalAssignmentForStorm_result()
     try:
         result.success = self._handler.getLocalAssignmentForStorm(args.id)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except NotAliveException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except AuthorizationException as aze:
         msg_type = TMessageType.REPLY
         result.aze = aze
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("getLocalAssignmentForStorm", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 8
0
 def process_checkUserAgeWithDocomo(self, seqid, iprot, oprot):
     args = checkUserAgeWithDocomo_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = checkUserAgeWithDocomo_result()
     try:
         result.success = self._handler.checkUserAgeWithDocomo(args.openIdRedirectUrl, args.standardAge, args.verifier)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TalkException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("checkUserAgeWithDocomo", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 9
0
 def process_fetchMessageOperations(self, seqid, iprot, oprot):
     args = fetchMessageOperations_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = fetchMessageOperations_result()
     try:
         result.success = self._handler.fetchMessageOperations(args.localRevision, args.lastOpTimestamp, args.count)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TalkException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("fetchMessageOperations", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 10
0
 def process_getAllServersWithPreferredServer(self, seqid, iprot, oprot):
     args = getAllServersWithPreferredServer_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = getAllServersWithPreferredServer_result()
     try:
         result.success = self._handler.getAllServersWithPreferredServer(args.serverTypes, args.serverGroups, args.failedServers)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except SnappyException as error:
         msg_type = TMessageType.REPLY
         result.error = error
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("getAllServersWithPreferredServer", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 11
0
    def recv_Log(self, iprot, mtype, rseqid):
        """
        Called when the result of the log request was received.
        """
        if mtype == TMessageType.EXCEPTION:
            result = TApplicationException()
        else:
            result = scribe.Log_result()

        result.read(iprot)
        iprot.readMessageEnd()

        try:
            d = self._reqs.pop(rseqid)
        except KeyError:
            log.err(result, "Unexpected log result")

        if isinstance(result, Exception):
            d.errback(result)
        elif result.success is not None:
            d.callback(result.success)
        else:
            d.errback(TApplicationException(
                TApplicationException.MISSING_RESULT,
                'Log failed: unknown result'))
Esempio n. 12
0
 def process_postSnsInvitationMessage(self, seqid, iprot, oprot):
     args = postSnsInvitationMessage_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = postSnsInvitationMessage_result()
     try:
         self._handler.postSnsInvitationMessage(args.snsIdType, args.snsAccessToken, args.toSnsUserId)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TalkException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("postSnsInvitationMessage", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 13
0
 def process_sendChatCheckedByWatermark(self, seqid, iprot, oprot):
     args = sendChatCheckedByWatermark_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = sendChatCheckedByWatermark_result()
     try:
         self._handler.sendChatCheckedByWatermark(args.seq, args.mid, args.watermark, args.sessionId)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TalkException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("sendChatCheckedByWatermark", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 14
0
 def process_create(self, seqid, iprot, oprot):
   args = create_args()
   args.read(iprot)
   iprot.readMessageEnd()
   result = create_result()
   try:
     result.success = self._handler.create(args.request)
     msg_type = TMessageType.REPLY
   except (TTransport.TTransportException, KeyboardInterrupt, SystemExit):
     raise
   except ServiceUnavailable as service_error:
     msg_type = TMessageType.REPLY
     result.service_error = service_error
   except ImageNotSupported as error:
     msg_type = TMessageType.REPLY
     result.error = error
   except UploadImageError as image_error:
     msg_type = TMessageType.REPLY
     result.image_error = image_error
   except Exception as ex:
     msg_type = TMessageType.EXCEPTION
     logging.exception(ex)
     result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
   oprot.writeMessageBegin("create", msg_type, seqid)
   result.write(oprot)
   oprot.writeMessageEnd()
   oprot.trans.flush()
Esempio n. 15
0
 def process_similar(self, seqid, iprot, oprot):
     args = similar_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = similar_result()
     try:
         result.success = self._handler.similar(args.query, args.n, args.sorting)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TSearchException as error:
         msg_type = TMessageType.REPLY
         result.error = error
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("similar", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 16
0
 def process_getBotUseInfo(self, seqid, iprot, oprot):
     args = getBotUseInfo_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = getBotUseInfo_result()
     try:
         result.success = self._handler.getBotUseInfo(args.botMid)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TalkException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("getBotUseInfo", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 17
0
 def process_notifyLeaveRoom(self, seqid, iprot, oprot):
     args = notifyLeaveRoom_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = notifyLeaveRoom_result()
     try:
         self._handler.notifyLeaveRoom(args.roomMid)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TalkException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("notifyLeaveRoom", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 18
0
 def _handle_request(self, listener_name, sock, addr):
     client = TFileObjectTransport(sock.makefile())
     itrans = self.tfactory.getTransport(client)
     otrans = self.tfactory.getTransport(client)
     iprot = self.pfactory.getProtocol(itrans)
     oprot = self.pfactory.getProtocol(otrans)
     try:
         while True:
             (name, type, seqid) = iprot.readMessageBegin()
             request_start = time.time()
             try:
                 timeout_con = Timeout(self.cfg.timeout, Timeout)
                 timeout_con.start()
                 if name not in self.wsgi._processMap:
                     iprot.skip(TType.STRUCT)
                     iprot.readMessageEnd()
                     x = TApplicationException(
                         TApplicationException.UNKNOWN_METHOD, "Unknown function %s" % (name))
                     oprot.writeMessageBegin(
                         name, TMessageType.EXCEPTION, seqid)
                     x.write(oprot)
                     oprot.writeMessageEnd()
                     oprot.trans.flush()
                     raise ThriftFuncNotFound
                 else:
                     self.wsgi._processMap[name](self.wsgi, seqid, iprot, oprot)
             except ThriftFuncNotFound, ex:
                 self.log.error("Unknown function %s" % (name))
                 self.log.access(
                     addr, name, "FUNC_NOT_FOUND", time.time() - request_start)
             except Timeout, ex:
                 self.log.error("A greenlet process timeout.")
                 self.log.access(
                     addr, name, "TIMEOUT", time.time() - request_start)
Esempio n. 19
0
 def process_execute(self, seqid, iprot, oprot):
     args = execute_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = execute_result()
     try:
         result.success = self._handler.execute(args.functionName, args.funcArgs)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except DRPCExecutionException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except AuthorizationException as aze:
         msg_type = TMessageType.REPLY
         result.aze = aze
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("execute", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 20
0
 def process_ping(self, seqid, iprot, oprot):
     args = ping_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = ping_result()
     try:
         result.success = self._handler.ping()
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except AboutToShutDownException as shutdown_exception:
         msg_type = TMessageType.REPLY
         result.shutdown_exception = shutdown_exception
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("ping", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
 def recv_basePing(self, iprot, mtype, rseqid):
   if mtype == TMessageType.EXCEPTION:
     x = TApplicationException()
     x.read(iprot)
     iprot.readMessageEnd()
     raise x
   result = basePing_result()
   result.read(iprot)
   iprot.readMessageEnd()
   return
 def recv_disconnect(self):
   (fname, mtype, rseqid) = self._iprot.readMessageBegin()
   if mtype == TMessageType.EXCEPTION:
     x = TApplicationException()
     x.read(self._iprot)
     self._iprot.readMessageEnd()
     raise x
   result = disconnect_result()
   result.read(self._iprot)
   self._iprot.readMessageEnd()
   return
Esempio n. 23
0
 def recv_clusterForNode(self):
   (fname, mtype, rseqid) = self._iprot.readMessageBegin()
   if mtype == TMessageType.EXCEPTION:
     x = TApplicationException()
     x.read(self._iprot)
     self._iprot.readMessageEnd()
     raise x
   result = clusterForNode_result()
   result.read(self._iprot)
   self._iprot.readMessageEnd()
   return
Esempio n. 24
0
 def recv_registe_device(self, ):
   (fname, mtype, rseqid) = self._iprot.readMessageBegin()
   if mtype == TMessageType.EXCEPTION:
     x = TApplicationException()
     x.read(self._iprot)
     self._iprot.readMessageEnd()
     raise x
   result = registe_device_result()
   result.read(self._iprot)
   self._iprot.readMessageEnd()
   return
 def recv_updateDialogState(self):
   (fname, mtype, rseqid) = self._iprot.readMessageBegin()
   if mtype == TMessageType.EXCEPTION:
     x = TApplicationException()
     x.read(self._iprot)
     self._iprot.readMessageEnd()
     raise x
   result = updateDialogState_result()
   result.read(self._iprot)
   self._iprot.readMessageEnd()
   return
Esempio n. 26
0
 def recv_send_measure_info(self, ):
   (fname, mtype, rseqid) = self._iprot.readMessageBegin()
   if mtype == TMessageType.EXCEPTION:
     x = TApplicationException()
     x.read(self._iprot)
     self._iprot.readMessageEnd()
     raise x
   result = send_measure_info_result()
   result.read(self._iprot)
   self._iprot.readMessageEnd()
   return
 def recv_changeVisitorApplicationEnvironment(self):
   (fname, mtype, rseqid) = self._iprot.readMessageBegin()
   if mtype == TMessageType.EXCEPTION:
     x = TApplicationException()
     x.read(self._iprot)
     self._iprot.readMessageEnd()
     raise x
   result = changeVisitorApplicationEnvironment_result()
   result.read(self._iprot)
   self._iprot.readMessageEnd()
   return
Esempio n. 28
0
 def recv_start_exporting(self, ):
   (fname, mtype, rseqid) = self._iprot.readMessageBegin()
   if mtype == TMessageType.EXCEPTION:
     x = TApplicationException()
     x.read(self._iprot)
     self._iprot.readMessageEnd()
     raise x
   result = start_exporting_result()
   result.read(self._iprot)
   self._iprot.readMessageEnd()
   return
Esempio n. 29
0
 def recv_ping(self, iprot, mtype, rseqid):
   d = self._reqs.pop(rseqid)
   if mtype == TMessageType.EXCEPTION:
     x = TApplicationException()
     x.read(iprot)
     iprot.readMessageEnd()
     return d.errback(x)
   result = ping_result()
   result.read(iprot)
   iprot.readMessageEnd()
   return d.callback(None)
Esempio n. 30
0
 def recv_remoteDirectoryListing(self):
   (fname, mtype, rseqid) = self._iprot.readMessageBegin()
   if mtype == TMessageType.EXCEPTION:
     x = TApplicationException()
     x.read(self._iprot)
     self._iprot.readMessageEnd()
     raise x
   result = remoteDirectoryListing_result()
   result.read(self._iprot)
   self._iprot.readMessageEnd()
   return
Esempio n. 31
0
 def process_call(self, seqid, iprot, oprot):
     args = call_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = call_result()
     try:
         result.success = self._handler.call(args.body)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TApplicationException as ex:
         logging.exception("TApplication exception in handler")
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception("Unexpected exception in handler")
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, "Internal error")
     oprot.writeMessageBegin("call", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 32
0
 def process_multiGetLastReadMessageIds(self, seqid, iprot, oprot):
     args = multiGetLastReadMessageIds_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = multiGetLastReadMessageIds_result()
     try:
         result.success = self._handler.multiGetLastReadMessageIds(
             args.chatIds)
         msg_type = TMessageType.REPLY
     except (TTransport.TTransportException, KeyboardInterrupt, SystemExit):
         raise
     except TalkException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except Exception as ex:
         msg_type = TMessageType.EXCEPTION
         logging.exception(ex)
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("multiGetLastReadMessageIds", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 33
0
 def process_getSnsMyProfile(self, seqid, iprot, oprot):
     args = getSnsMyProfile_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = getSnsMyProfile_result()
     try:
         result.success = self._handler.getSnsMyProfile(
             args.snsIdType, args.snsAccessToken)
         msg_type = TMessageType.REPLY
     except (TTransport.TTransportException, KeyboardInterrupt, SystemExit):
         raise
     except TalkException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except Exception as ex:
         msg_type = TMessageType.EXCEPTION
         logging.exception(ex)
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("getSnsMyProfile", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 34
0
 def process_getJoinedSquares(self, seqid, iprot, oprot):
     args = getJoinedSquares_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = getJoinedSquares_result()
     try:
         result.success = self._handler.getJoinedSquares(
             args.continuationToken, args.limit)
         msg_type = TMessageType.REPLY
     except (TTransport.TTransportException, KeyboardInterrupt, SystemExit):
         raise
     except SquareException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except Exception as ex:
         msg_type = TMessageType.EXCEPTION
         logging.exception(ex)
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("getJoinedSquares", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 35
0
 def process_fetchMessageOperations(self, seqid, iprot, oprot):
     args = fetchMessageOperations_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = fetchMessageOperations_result()
     try:
         result.success = self._handler.fetchMessageOperations(
             args.localRevision, args.lastOpTimestamp, args.count)
         msg_type = TMessageType.REPLY
     except (TTransport.TTransportException, KeyboardInterrupt, SystemExit):
         raise
     except TalkException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except Exception as ex:
         msg_type = TMessageType.EXCEPTION
         logging.exception(ex)
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("fetchMessageOperations", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 36
0
 def process_checkUserAgeWithDocomo(self, seqid, iprot, oprot):
     args = checkUserAgeWithDocomo_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = checkUserAgeWithDocomo_result()
     try:
         result.success = self._handler.checkUserAgeWithDocomo(
             args.openIdRedirectUrl, args.standardAge, args.verifier)
         msg_type = TMessageType.REPLY
     except (TTransport.TTransportException, KeyboardInterrupt, SystemExit):
         raise
     except TalkException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except Exception as ex:
         msg_type = TMessageType.EXCEPTION
         logging.exception(ex)
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("checkUserAgeWithDocomo", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 37
0
 def process_retrieveOpenIdAuthUrlWithDocomo(self, seqid, iprot, oprot):
     args = retrieveOpenIdAuthUrlWithDocomo_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = retrieveOpenIdAuthUrlWithDocomo_result()
     try:
         result.success = self._handler.retrieveOpenIdAuthUrlWithDocomo()
         msg_type = TMessageType.REPLY
     except (TTransport.TTransportException, KeyboardInterrupt, SystemExit):
         raise
     except TalkException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except Exception as ex:
         msg_type = TMessageType.EXCEPTION
         logging.exception(ex)
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("retrieveOpenIdAuthUrlWithDocomo", msg_type,
                             seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
 def process_setCoolingMode(self, seqid, iprot, oprot):
     args = setCoolingMode_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = setCoolingMode_result()
     try:
         self._handler.setCoolingMode(args.foodCoolingMode)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("setCoolingMode", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 39
0
    async def _ping(self, ctx):
        memory_buffer = TMemoryOutputBuffer(self._transport.get_request_size_limit())
        oprot = self._protocol_factory.get_protocol(memory_buffer)
        oprot.write_request_headers(ctx)
        oprot.writeMessageBegin('ping', TMessageType.CALL, 0)
        args = ping_args()
        args.write(oprot)
        oprot.writeMessageEnd()
        response_transport = await self._transport.request(ctx, memory_buffer.getvalue())

        iprot = self._protocol_factory.get_protocol(response_transport)
        iprot.read_response_headers(ctx)
        _, mtype, _ = iprot.readMessageBegin()
        if mtype == TMessageType.EXCEPTION:
            x = TApplicationException()
            x.read(iprot)
            iprot.readMessageEnd()
            if x.type == TApplicationExceptionType.RESPONSE_TOO_LARGE:
                raise TTransportException(type=TTransportExceptionType.RESPONSE_TOO_LARGE, message=x.message)
            raise x
        result = ping_result()
        result.read(iprot)
        iprot.readMessageEnd()
 def process_getIdentifier(self, seqid, iprot, oprot):
     args = getIdentifier_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = getIdentifier_result()
     try:
         result.success = self._handler.getIdentifier()
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("getIdentifier", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 41
0
 def process_register_client_id(self, seqid, iprot, oprot):
     args = register_client_id_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = register_client_id_result()
     try:
         self._handler.register_client_id(args.block_id, args.client_id)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("register_client_id", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 42
0
 def nested(self, iprot, oprot, server_ctx=None):
     name, _, seqid = iprot.readMessageBegin()
     if isinstance(name, bytes):
         name = name.decode('utf8')
     if name not in self._processMap:
         iprot.skip(TType.STRUCT)
         iprot.readMessageEnd()
         x = TApplicationException(
             TApplicationException.UNKNOWN_METHOD,
             'Unknown function {!r}'.format(name),
         )
         oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid)
         x.write(oprot)
         oprot.writeMessageEnd()
         oprot.trans.flush()
     else:
         yield from self._processMap[name](
             self,
             seqid,
             iprot,
             oprot,
             server_ctx,
         )
Esempio n. 43
0
 def process_createSquareChat(self, seqid, iprot, oprot):
     args = createSquareChat_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = createSquareChat_result()
     try:
         result.success = self._handler.createSquareChat(
             args.reqSeq, args.squareChat, args.squareMemberMids)
         msg_type = TMessageType.REPLY
     except (TTransport.TTransportException, KeyboardInterrupt, SystemExit):
         raise
     except SquareException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except Exception as ex:
         msg_type = TMessageType.EXCEPTION
         logging.exception(ex)
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("createSquareChat", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 44
0
 def callback(transport):
     iprot = protocol_factory.get_protocol(transport)
     ctx = iprot.read_request_headers()
     mname, _, _ = iprot.readMessageBegin()
     if mname != op:
         iprot.skip(TType.STRUCT)
         iprot.readMessageEnd()
         raise TApplicationException(TApplicationExceptionType.UNKNOWN_METHOD)
     req = iprot.readString()
     iprot.readMessageEnd()
     try:
         method([ctx, req])
     except:
         traceback.print_exc()
         sys.exit(1)
Esempio n. 45
0
 def echo(self, input=None):
     """
 Parameters:
  - input
 """
     if (self._fbthrift_cpp_transport):
         args = echo_args()
         args.input = input
         result = self._fbthrift_cpp_transport._send_request(
             "MyService", "echo", args, echo_result)
         if result.success is not None:
             return result.success
         raise TApplicationException(TApplicationException.MISSING_RESULT)
     self.send_echo(input)
     return self.recv_echo()
Esempio n. 46
0
 def get500(self, ):
   if (self._fbthrift_cpp_transport):
     args = get500_args()
     result = self._fbthrift_cpp_transport._send_request("Raiser", "get500", args, get500_result)
     if result.success is not None:
       return result.success
     if result.f is not None:
       raise result.f
     if result.b is not None:
       raise result.b
     if result.s is not None:
       raise result.s
     raise TApplicationException(TApplicationException.MISSING_RESULT)
   self.send_get500()
   return self.recv_get500()
Esempio n. 47
0
 def process_savetodb(self, seqid, iprot, oprot):
     args = savetodb_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = savetodb_result()
     try:
         self._handler.savetodb(args.movie_name, args.country,
                                args.language, args.type, args.score)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("savetodb", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 48
0
    def reset_protocol(self):
        if self.__proto_id == self.trans.get_protocol_id():
            return

        proto_id = self.trans.get_protocol_id()

        if proto_id == self.T_BINARY_PROTOCOL:
            self.__proto = TBinaryProtocolAccelerated(self.trans,
                                                      self.strictRead, True)
        elif proto_id == self.T_COMPACT_PROTOCOL:
            self.__proto = TCompactProtocolAccelerated(self.trans)
        else:
            raise TApplicationException(TProtocolException.INVALID_PROTOCOL,
                                        "Unknown protocol requested")
        self.__proto_id = proto_id
Esempio n. 49
0
 def process_compute_mod_branin_function(self, seqid, iprot, oprot):
     args = compute_mod_branin_function_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = compute_mod_branin_function_result()
     try:
         result.success = self._handler.compute_mod_branin_function(
             args.input)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("compute_mod_branin_function", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 50
0
 def isPrime(self, num=None):
     """
 Parameters:
  - num
 """
     if (self._fbthrift_cpp_transport):
         args = isPrime_args()
         args.num = num
         result = self._fbthrift_cpp_transport._send_request(
             "TestService", "isPrime", args, isPrime_result)
         if result.success is not None:
             return result.success
         raise TApplicationException(TApplicationException.MISSING_RESULT)
     self.send_isPrime(num)
     return self.recv_isPrime()
Esempio n. 51
0
 def bounce_map(self, m=None):
     """
 Parameters:
  - m
 """
     if (self._fbthrift_cpp_transport):
         args = bounce_map_args()
         args.m = m
         result = self._fbthrift_cpp_transport._send_request(
             "SomeService", "bounce_map", args, bounce_map_result)
         if result.success is not None:
             return result.success
         raise TApplicationException(TApplicationException.MISSING_RESULT)
     self.send_bounce_map(m)
     return self.recv_bounce_map()
Esempio n. 52
0
 def process_updateChinaProvienceData(self, seqid, iprot, oprot):
     args = updateChinaProvienceData_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = updateChinaProvienceData_result()
     try:
         result.success = self._handler.updateChinaProvienceData(
             args.provience)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("updateChinaProvienceData", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
 def process_myMethod(self, seqid, iprot, oprot):
     args = myMethod_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = myMethod_result()
     try:
         self._handler.myMethod(args.first, args.second, args.third,
                                args.fourth)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("myMethod", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 54
0
 def process_getDataSetFileOfVariableAtTimeIndex(self, seqid, iprot, oprot):
     args = getDataSetFileOfVariableAtTimeIndex_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = getDataSetFileOfVariableAtTimeIndex_result()
     try:
         result.success = self._handler.getDataSetFileOfVariableAtTimeIndex(
             args.simulationDataSetRef, args.varInfo, args.timeIndex)
         msg_type = TMessageType.REPLY
     except (TTransport.TTransportException, KeyboardInterrupt, SystemExit):
         raise
     except ThriftDataAccessException as dataAccessException:
         msg_type = TMessageType.REPLY
         result.dataAccessException = dataAccessException
     except Exception as ex:
         msg_type = TMessageType.EXCEPTION
         logging.exception(ex)
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("getDataSetFileOfVariableAtTimeIndex",
                             msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 55
0
 def process_displayPostProcessingDataInVCell(self, seqid, iprot, oprot):
     args = displayPostProcessingDataInVCell_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = displayPostProcessingDataInVCell_result()
     try:
         self._handler.displayPostProcessingDataInVCell(
             args.simulationDataSetRef)
         msg_type = TMessageType.REPLY
     except (TTransport.TTransportException, KeyboardInterrupt, SystemExit):
         raise
     except ThriftDataAccessException as dataAccessException:
         msg_type = TMessageType.REPLY
         result.dataAccessException = dataAccessException
     except Exception as ex:
         msg_type = TMessageType.EXCEPTION
         logging.exception(ex)
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("displayPostProcessingDataInVCell", msg_type,
                             seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 56
0
 def process_test(self, seqid, iprot, oprot):
     args = test_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = test_result()
     try:
         result.success = self._handler.test(args.test)
         msg_type = TMessageType.REPLY
     except TTransport.TTransportException:
         raise
     except TApplicationException as ex:
         logging.exception('TApplication exception in handler')
         msg_type = TMessageType.EXCEPTION
         result = ex
     except Exception:
         logging.exception('Unexpected exception in handler: %s',
                           traceback.format_exc())
         msg_type = TMessageType.EXCEPTION
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("test", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 57
0
 def process_sendChatCheckedByWatermark(self, seqid, iprot, oprot):
     args = sendChatCheckedByWatermark_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = sendChatCheckedByWatermark_result()
     try:
         self._handler.sendChatCheckedByWatermark(args.seq, args.mid,
                                                  args.watermark,
                                                  args.sessionId)
         msg_type = TMessageType.REPLY
     except (TTransport.TTransportException, KeyboardInterrupt, SystemExit):
         raise
     except TalkException as e:
         msg_type = TMessageType.REPLY
         result.e = e
     except Exception as ex:
         msg_type = TMessageType.EXCEPTION
         logging.exception(ex)
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("sendChatCheckedByWatermark", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()
Esempio n. 58
0
 def init(self, int1=None):
     """
 Parameters:
  - int1
 """
     if (self._fbthrift_cpp_transport):
         args = init_args()
         args.int1 = int1
         result = self._fbthrift_cpp_transport._send_request(
             "TestService", "init", args, init_result)
         if result.success is not None:
             return result.success
         raise TApplicationException(TApplicationException.MISSING_RESULT)
     self.send_init(int1)
     return self.recv_init()
Esempio n. 59
0
 def _handle_request(self, listener_name, sock, addr):
     client = TFileObjectTransport(sock.makefile())
     itrans = self.tfactory.getTransport(client)
     otrans = self.tfactory.getTransport(client)
     iprot = self.pfactory.getProtocol(itrans)
     oprot = self.pfactory.getProtocol(otrans)
     try:
         while True:
             (name, type, seqid) = iprot.readMessageBegin()
             request_start = time.time()
             try:
                 timeout_con = Timeout(self.cfg.timeout, Timeout)
                 timeout_con.start()
                 if name not in self.wsgi._processMap:
                     iprot.skip(TType.STRUCT)
                     iprot.readMessageEnd()
                     x = TApplicationException(
                         TApplicationException.UNKNOWN_METHOD, "Unknown function %s" % (name))
                     oprot.writeMessageBegin(
                         name, TMessageType.EXCEPTION, seqid)
                     x.write(oprot)
                     oprot.writeMessageEnd()
                     oprot.trans.flush()
                     raise ThriftFuncNotFound
                 else:
                     self.wsgi._processMap[name](self.wsgi, seqid, iprot, oprot)
             except ThriftFuncNotFound, ex:
                 self.log.error("Unknown function %s" % (name))
                 self.log.access(
                     addr, name, "FUNC_NOT_FOUND", time.time() - request_start)
                 break
             except Timeout, ex:
                 self.log.error("A greenlet process timeout.")
                 self.log.access(
                     addr, name, "TIMEOUT", time.time() - request_start)
                 break
Esempio n. 60
0
 def process_endServiceDelivery(self, seqid, iprot, oprot):
     args = endServiceDelivery_args()
     args.read(iprot)
     iprot.readMessageEnd()
     result = endServiceDelivery_result()
     try:
         self._handler.endServiceDelivery(args.serviceID,
                                          args.serviceDeliveryToken,
                                          args.unitsReceived)
         msg_type = TMessageType.REPLY
     except (TTransport.TTransportException, KeyboardInterrupt, SystemExit):
         raise
     except wpthrift_types.ttypes.Error as err:
         msg_type = TMessageType.REPLY
         result.err = err
     except Exception as ex:
         msg_type = TMessageType.EXCEPTION
         logging.exception(ex)
         result = TApplicationException(
             TApplicationException.INTERNAL_ERROR, 'Internal error')
     oprot.writeMessageBegin("endServiceDelivery", msg_type, seqid)
     result.write(oprot)
     oprot.writeMessageEnd()
     oprot.trans.flush()