VisionEgg.PyroClient

Package VisionEgg :: Module PyroClient |
[frames] | no frames]

# Source Code for Module VisionEgg.PyroClient

     1  # The Vision Egg: PyroClient
     2  #
     3  # Copyright (C) 2001-2003 Andrew Straw.
     4  # Copyright (C) 2008 California Insitute of Technology
     5  # Author: Andrew Straw <astraw@users.sourceforge.net>
     6  # URL: <http://www.visionegg.org/>
     7  #
     8  # Distributed under the terms of the GNU Lesser General Public License
     9  # (LGPL). See LICENSE.TXT that came with this file.
    10  #
    11  # $Id$
    12
    13  """
    14  Python Remote Objects support - Client side.
    15
    16  """
    17
    18  import socket
    19  import VisionEgg
    20
    21  import logging                              # available in Python 2.3
    22
    23  __version__ = VisionEgg.release_name
    24  __cvs__ = '$Revision$'.split()[1]
    25  __date__ = ' '.join('$Date$'.split()[1:3])
    26  __author__ = 'Andrew Straw <astraw@users.sourceforge.net>'
    27
    28  import Pyro.core
    29
    30 -class PyroClient:
    31      """Simplifies getting PyroControllers from a remote computer."""
    32 -    def __init__(self,server_hostname='',server_port=7766):
    33          """Initialize Pyro client."""
    34          Pyro.core.initClient()
    35          try:
    36              self.server_hostname = socket.getfqdn(server_hostname)
    37          except Exception, x:
    38              logger = logging.getLogger('VisionEgg.PyroClient')
    39              logger.warning("while getting fully qualified domain name: %s: %s"%
    40                             (str(x.__class__),str(x)))
    41              self.server_hostname = server_hostname
    42          self.server_port = server_port
    43
    44 -    def get(self,name):
    45          """Return a remote Pyro object being served by Pyro server."""
    46          URI = "PYROLOC://%s:%d/%s" % (self.server_hostname, self.server_port, name)
    47          return Pyro.core.getProxyForURI(URI)
    48