Ejemplo n.º 1
0
    def _get_api(self, name, endpoint, port):
        locator_pipe = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        locator_pipe.settimeout(4.0)
        locator_pipe.connect((endpoint, port))
        locator_pipe.send(packb([0, 1, [name]]))
        u = Unpacker()
        msg = None
        while msg is None:
            response = locator_pipe.recv(80960)
            u.feed(response)
            msg = Message.initialize(u.next())

        locator_pipe.close()
        if msg.id == message.RPC_CHUNK: #PROTOCOL_LIST.index("rpc::chunk"):
            return unpackb(msg.data)
        if msg.id == message.RPC_ERROR: #PROTOCOL_LIST.index("rpc::error"):
            raise Exception(msg.message)
Ejemplo n.º 2
0
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details. """


if __name__ == '__main__':
   from msgpack import Unpacker
   from sys import stdin
   unpacker = Unpacker(stdin)

   # print header:
   try:
      header = unpacker.next()
      print ' '.join(header)
   except Exception, e:
      print e

   # print data:
   for msg in unpacker:
      try:
         print ' '.join(map(str, msg))
      except:
         pass

Ejemplo n.º 3
0
 Copyright (C) 2014 Tobias Simon, Integrated Communication Systems Group, TU Ilmenau

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details. """

if __name__ == '__main__':
    from msgpack import Unpacker
    from sys import stdin
    unpacker = Unpacker(stdin)

    # print header:
    try:
        header = unpacker.next()
        print ' '.join(header)
    except Exception, e:
        print e

    # print data:
    for msg in unpacker:
        try:
            print ' '.join(map(str, msg))
        except:
            pass