Beispiel #1
0
 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 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)
Beispiel #4
0
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
Beispiel #5
0
 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
Beispiel #7
0
 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
Beispiel #8
0
 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
Beispiel #9
0
 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