This file is indexed.

/usr/lib/python2.7/dist-packages/VisionEgg/PyroHelpers.py is in python-visionegg 1.2.1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# The Vision Egg: PyroHelpers
#
# Copyright (C) 2001-2003 Andrew Straw.
# Author: Andrew Straw <astraw@users.sourceforge.net>
# URL: <http://www.visionegg.org/>
#
# Distributed under the terms of the GNU Lesser General Public License
# (LGPL). See LICENSE.TXT that came with this file.
#
# $Id$

"""
Python Remote Objects support.

Use this class if you don't want to deal with TCP directly and Python
is the program on both ends of the network.

The module provides some Vision Egg specific code for Pyro.  Pyro
allows you to call python objects on remote machines just like they
are on the local machine.  This makes the task of writing a two
computer Vision Egg application quite easy, because one can mostly
ignore the network-based intermediate stage.

PyroControllers are run on the computer performing the presentation.
The PyroServer class also runs on this computer, and allows these
controllers to be changed from a computer running PyroClient. To
listen to the network PyroListenerController must be instantiated by
the PyroServer -- this checks for any requests coming over the
network, but only at times specified because it is a subclass of
VisionEgg.FlowControl.Controller.

Just like TCPControllers, don't use this class for realtime control
unless you think your network is that fast and reliable.  It's great
for setting up parameters in advance and sending a trigger pulse,
though!"""

import VisionEgg
import VisionEgg.Core
import VisionEgg.FlowControl
import VisionEgg.ParameterTypes as ve_types

import Pyro.core
import Pyro.errors

Pyro.config.PYRO_MULTITHREADED = 0 # No multithreading!

class PyroServer:
    """Set up a Pyro server for your PyroControllers and PyroGoClass.

    This class is analagous to VisionEgg.TCPController.TCPServer.

    """
    def __init__(self):
        # Start Pyro
        Pyro.core.initServer()
        self.daemon = Pyro.core.Daemon()
        self.ok_to_run = 1

    def get_hostname_and_port(self):
        return self.daemon.hostname, self.daemon.port

    def connect(self,object,name):
        """Serve an object under a name"""
        URI=self.daemon.connect(object,name)
        return URI

    def disconnect(self,object):
        if Pyro.core.constants.VERSION >= '3.2':
            self.daemon.disconnect(object)
        else:
            # workaround bug in Pyro pre-3.2
            del self.daemon.implementations[object.GUID()]
            object.setDaemon(None)

    def create_listener_controller(self):
        if hasattr(self,'listen_controller'):
            raise RuntimeError("Only one pyro listen controller allowed per server!")
        self.listen_controller = PyroListenController(self)
        return self.listen_controller

    def handleRequests(self, timeout=0):
        """Only use this if you don't use the PyroListenerController.

        A timeout of 0 specifies return immediately."""
        self.daemon.handleRequests(timeout)

class PyroConstantController(VisionEgg.FlowControl.ConstantController,Pyro.core.ObjBase):
    def __init__(self, **kw):
        VisionEgg.FlowControl.ConstantController.__init__(self,**kw)
        Pyro.core.ObjBase.__init__(self)

class PyroEvalStringController(VisionEgg.FlowControl.EvalStringController,Pyro.core.ObjBase):
    def __init__(self, **kw):
        VisionEgg.FlowControl.EvalStringController.__init__(self,**kw)
        Pyro.core.ObjBase.__init__(self)

class PyroExecStringController(VisionEgg.FlowControl.ExecStringController,Pyro.core.ObjBase):
    def __init__(self, **kw):
        VisionEgg.FlowControl.ExecStringController.__init__(self,**kw)
        Pyro.core.ObjBase.__init__(self)

class PyroEncapsulatedController(VisionEgg.FlowControl.EncapsulatedController,Pyro.core.ObjBase):
    """Create the instance of Controller on client, and send it to server.

    This class is analagous to VisionEgg.TCPController.TCPController.
    """
    def __init__(self,initial_controller=None,**kw):
        VisionEgg.FlowControl.EncapsulatedController.__init__(self,initial_controller)
        Pyro.core.ObjBase.__init__(self)

class PyroLocalDictController(VisionEgg.FlowControl.EncapsulatedController,Pyro.core.ObjBase):
    """Contain several dictionary entries, set controller accordingly.
    """
    def __init__(self, dict=None, key=None, **kw):
        if dict is None:
            self.dict = {}
            initial_controller = VisionEgg.FlowControl.ConstantController(during_go_value=0,
                                                                   between_go_value=0,
                                                                   eval_frequency=VisionEgg.FlowControl.Controller.NEVER)
        else:
            self.dict = dict
        if key is None:
            if len(self.dict.keys()):
                key = self.dict.keys()[0]
                initial_controller = self.dict[key]
            else:
                initial_controller = VisionEgg.FlowControl.ConstantController(during_go_value=0,
                                                                       between_go_value=0,
                                                                       eval_frequency=VisionEgg.FlowControl.Controller.NEVER)
        else:
            initial_controller = dict[key]
        VisionEgg.FlowControl.EncapsulatedController.__init__(self,initial_controller)
        Pyro.core.ObjBase.__init__(self)
    def use_controller(self,key):
        self.set_new_controller(self.dict[key])
    def add_controller(self,key,new_controller):
        self.dict[key] = new_controller

class PyroListenController(VisionEgg.FlowControl.Controller):
    """Handle connection from remote machine, control PyroControllers.

    This meta controller handles a Pyro daemon, which checks the TCP
    socket for new input and acts accordingly.

    This class is analagous to VisionEgg.TCPController.SocketListenController.

    """

    def __init__(self,server=None,**kw):
        """Called by PyroServer. Creates a PyroListenerController instance."""
        if not isinstance(server,PyroServer):
            raise ValueError("Must specify a Pyro Server.")
        if 'eval_frequency' not in kw.keys():
            kw['eval_frequency'] = VisionEgg.FlowControl.Controller.EVERY_FRAME
        if 'return_type' not in kw.keys():
            kw['return_type'] = ve_types.get_type(None)
        VisionEgg.FlowControl.Controller.__init__(self,**kw)
        self.server=server

    def during_go_eval(self):
        # setting timeout = 0 means return ASAP
        self.server.daemon.handleRequests(timeout=0)

    def between_go_eval(self):
        # setting timeout = 0 means return ASAP
        self.server.daemon.handleRequests(timeout=0)