def callComponent(self, callProtocol, name, argDict, cache, compType, srcModTime): """ client-side handler for remote component calls """ # we don't need the callProtocol argument in this case unPickled=None host, port, path=self.__parseComponentName(name) args = cPickle.dumps((path, argDict, cache, compType, srcModTime)) msg="%10d%s" %(len(args), args) sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((host, port)) data=sock.recv(1) if data=='\0': SocketScience.send_it_all(sock, msg) length=int(SocketScience.read_this_many(sock, 10)) data=SocketScience.read_this_many(sock, length) unPickled=cPickle.loads(data) DEBUG(REMOTE_CLIENT, 'unp was %s' % str(unPickled)) if unPickled[0] == 0: #ok return unPickled[1] else: raise getRemoteException(unPickled[2]) raise RemoteException, ("remote host did not speak " "protocol: %s:%s") % (host, port)
def callComponent(self, callProtocol, name, argDict, cache, compType, srcModTime): """ client-side handler for remote component calls """ # we don't need the callProtocol argument in this case unPickled = None host, port, path = self.__parseComponentName(name) args = cPickle.dumps((path, argDict, cache, compType, srcModTime)) msg = "%10d%s" % (len(args), args) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((host, port)) data = sock.recv(1) if data == '\0': SocketScience.send_it_all(sock, msg) length = int(SocketScience.read_this_many(sock, 10)) data = SocketScience.read_this_many(sock, length) unPickled = cPickle.loads(data) DEBUG(REMOTE_CLIENT, 'unp was %s' % str(unPickled)) if unPickled[0] == 0: #ok return unPickled[1] else: raise getRemoteException(unPickled[2]) raise RemoteException, ("remote host did not speak " "protocol: %s:%s") % (host, port)
def callComponent(self, callProtocol, name, argDict, cache, compType, srcModTime): """ client-side handler for remote component calls """ # we don't need the callProtocol argument in this case unPickled = None host, port, path = self.__parseComponentName(name) args = cPickle.dumps((path, argDict, cache, compType, srcModTime)) msg = "%10d%s" % (len(args), args) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((host, port)) data = sock.recv(1) if data == "\0": SocketScience.send_it_all(sock, msg) length = int(SocketScience.read_this_many(sock, 10)) data = SocketScience.read_this_many(sock, length) unPickled = cPickle.loads(data) if ( type(unPickled) == types.TupleType and len(unPickled) == 3 and type(unPickled[0]) == types.ClassType and issubclass(unPickled[0], exceptions.Exception) and isinstance(unPickled[1], exceptions.Exception) ): raise getRemoteException(unPickled[1]) return unPickled
def run(host, port, path, argDict, cache=0, compType = AE.Component.DT_DATA, srcModTime = None): unPickled=None args = cPickle.dumps((path, argDict, cache, compType, srcModTime)) msg="%10d%s" %(len(args), args) sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((host, port)) data=sock.recv(1) if data=='\0': SocketScience.send_it_all(sock, msg) length=int(SocketScience.read_this_many(sock, 10)) data=SocketScience.read_this_many(sock, length) unPickled=cPickle.loads(data) if (type(unPickled)==types.TupleType and len(unPickled)==3 and type(unPickled[0])==types.ClassType and issubclass(unPickled[0], exceptions.Exception) and isinstance(unPickled[1], exceptions.Exception)): raise RemoteException(unPickled[0], unPickled[1], unPickled[2]) return unPickled
def _sendResponse(sock, responseData, requestData, sessionDict): try: SocketScience.send_it_all(sock, responseData) except IOError, en: #ignore broken pipes if en != errno.EPIPE: logException()
def marshalRequest(self, socket, sessionDict): SocketScience.send_it_all(socket, '\0') DEBUG(REMOTE, 'sent sentinel') lenDataStr = SocketScience.read_this_many(socket, 10) DEBUG(REMOTE, 'read length') lenData = int(lenDataStr) data = SocketScience.read_this_many(socket, lenData) DEBUG(REMOTE, 'read request data: %s' % str(data)) unpickled = cPickle.loads(data) DEBUG(REMOTE, 'unpickled data: %s' % str(unpickled)) # as a teenager pretends to be, returning to his parents.... return unpickled
def marshalRequest(self, socket, sessionDict): SocketScience.send_it_all(socket, '\0') DEBUG(REMOTE, 'sent sentinel') lenDataStr = SocketScience.read_this_many(socket, 10) DEBUG(REMOTE, 'read length') lenData = int(lenDataStr) data = SocketScience.read_this_many(socket, lenData) DEBUG(REMOTE, 'read request data: %s' % str(data)) unpickled=cPickle.loads(data) DEBUG(REMOTE, 'unpickled data: %s' % str(unpickled)) # as a teenager pretends to be, returning to his parents.... return unpickled
def marshalRequest(self, sock, sessionDict): """ Sends a handshake byte, obtains the content length from the value of the first ten bytes read, and then reads no more than that amount, which it marshals with the 'marshal' module. Finally, returns the marshalled request data """ SocketScience.send_it_all(sock, '\0') DEBUG(AECGI, 'sent sentinel') lenDataStr = SocketScience.read_this_many(sock, 10) DEBUG(AECGI, 'read length') lenData = int(lenDataStr) data = SocketScience.read_this_many(sock, lenData) DEBUG(AECGI, 'read request data') marcia = marshal.loads(data) return marcia
def marshalRequest(self, sock, sessionDict): """ Sends a handshake byte, obtains the content length from the value of the first ten bytes read, and then reads no more than that amount, which it marshals with the 'marshal' module. Finally, returns the marshalled request data """ SocketScience.send_it_all(sock, '\0') DEBUG(AECGI, 'sent sentinel') lenDataStr = SocketScience.read_this_many(sock, 10) DEBUG(AECGI, 'read length') lenData = int(lenDataStr) data = SocketScience.read_this_many(sock, lenData) DEBUG(AECGI, 'read request data') marcia=marshal.loads(data) return marcia
def _sendResponse(sock, responseData, requestData, sessionDict): try: SocketScience.send_it_all(sock, responseData) except: logException() # reset alarm signal.alarm(Configuration.PostResponseTimeout) try: DEBUG(REQUESTHANDLER, 'post request hook') PostRequest(Configuration.job, requestData, sessionDict) except: logException() try: DEBUG(REQUESTHANDLER, "cleaning up") CleanupRequest(Configuration.job, requestData, sessionDict) except: logException()
def callComponent(self, callProtocol, name, argDict, cache, compType, srcModTime): """ client-side handler for remote component calls """ # we don't need the callProtocol argument in this case unPickled = None host, port, path = self.__parseComponentName(name) args = cPickle.dumps((path, argDict, cache, compType, srcModTime)) msg = "%10d%s" % (len(args), args) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((host, port)) data = sock.recv(1) if data == '\0': SocketScience.send_it_all(sock, msg) length = int(SocketScience.read_this_many(sock, 10)) data = SocketScience.read_this_many(sock, length) unPickled = cPickle.loads(data) if (type(unPickled) == types.TupleType and len(unPickled) == 3 and type(unPickled[0]) == types.ClassType and issubclass(unPickled[0], exceptions.Exception) and isinstance(unPickled[1], exceptions.Exception)): raise getRemoteException(unPickled[1]) return unPickled