Example #1
0
def which_python_executable():
    """Return full path to python executable.

    On some OS Python 3 is executed with python3 but in conda environments it
    is executed with python. Return Python 3 executable regardless of the
    Python installation.
    """
    executable = whichfile("python3")
    if executable is None:
        executable = whichfile("python")
    return executable
Example #2
0
 def setUp(self, pool_name):
     """Start MacroServer DS.
     """
     try:
         db = PyTango.Database()
         # Discover the MS launcher script
         msExec = whichexecutable.whichfile("MacroServer")
         # register MS server
         ms_ds_name = "MacroServer/" + self.ms_ds_name
         ms_free_ds_name = get_free_server(db, ms_ds_name)
         self._msstarter = ProcessStarter(msExec, ms_free_ds_name)
         # register MS device
         dev_name_parts = self.ms_name.split('/')
         prefix = '/'.join(dev_name_parts[0:2])
         start_from = int(dev_name_parts[2])
         self.ms_name = get_free_device(
             db, prefix, start_from)
         self._msstarter.addNewDevice(self.ms_name, klass='MacroServer')
         # register Door device
         dev_name_parts = self.door_name.split('/')
         prefix = '/'.join(dev_name_parts[0:2])
         start_from = int(dev_name_parts[2])
         self.door_name = get_free_device(db, prefix, start_from)
         self._msstarter.addNewDevice(self.door_name, klass='Door')
         db.put_device_property(self.ms_name, {'PoolNames': pool_name})
         # start MS server
         self._msstarter.startDs()
         self.door = PyTango.DeviceProxy(self.door_name)
     except Exception, e:
         # force tearDown in order to eliminate the MacroServer
         print e
         self.tearDown()
Example #3
0
 def setUp(self, properties=None):
     """Start Pool DS and register extensions.
     """
     db = PyTango.Database()
     # Discover the Pool launcher script
     poolExec = whichexecutable.whichfile("Pool")
     # register Pool server
     pool_ds_name = "Pool/" + self.pool_ds_name
     pool_free_ds_name = get_free_server(PyTango.Database(),
                                         pool_ds_name)
     self._starter = ProcessStarter(poolExec, pool_free_ds_name)
     # register Pool device
     dev_name_parts = self.pool_name.split('/')
     prefix = '/'.join(dev_name_parts[0:2])
     start_from = int(dev_name_parts[2])
     self.pool_name = get_free_device(db, prefix, start_from)
     self._starter.addNewDevice(self.pool_name, klass='Pool')
     # Add properties
     if properties is not None:
         for key, values in properties.items():
             db.put_device_property(self.pool_name,
                                    {key: values})
     # start Pool server
     self._starter.startDs()
     # register extensions so the test methods can use them
     self.pool = PyTango.DeviceProxy(self.pool_name)
Example #4
0
 def setUp(self):
     """Start Pool DS and register extensions.
     """
     # Discover the Pool launcher script
     poolExec = whichexecutable.whichfile("Pool")
     # register Pool server
     pool_ds_name = "Pool/" + self.pool_ds_name
     pool_free_ds_name = get_free_server(PyTango.Database(),
                                         pool_ds_name)
     self._starter = ProcessStarter(poolExec, pool_free_ds_name)
     # register Pool device
     dev_name_parts = self.pool_name.split('/')
     prefix = '/'.join(dev_name_parts[0:2])
     start_from = int(dev_name_parts[2])
     self.pool_name = get_free_device(
         PyTango.Database(), prefix, start_from)
     self._starter.addNewDevice(self.pool_name, klass='Pool')
     # start Pool server
     self._starter.startDs()
     # register extensions so the test methods can use them
     self.pool = PyTango.DeviceProxy(self.pool_name)
Example #5
0
    def setUp(self, properties=None):
        """
        Start MacroServer DS.

        :param properties: dictionary with the macroserver properies.

        """
        try:
            db = PyTango.Database()
            # Discover the MS launcher script
            msExec = whichexecutable.whichfile("MacroServer")
            # register MS server
            ms_ds_name_base = "MacroServer/" + self.ms_ds_name
            self.ms_ds_name = get_free_server(db, ms_ds_name_base)
            self._msstarter = ProcessStarter(msExec, self.ms_ds_name)
            # register MS device
            dev_name_parts = self.ms_name.split('/')
            prefix = '/'.join(dev_name_parts[0:2])
            start_from = int(dev_name_parts[2])
            self.ms_name = get_free_device(
                db, prefix, start_from)
            self._msstarter.addNewDevice(self.ms_name, klass='MacroServer')
            # register Door device
            dev_name_parts = self.door_name.split('/')
            prefix = '/'.join(dev_name_parts[0:2])
            start_from = int(dev_name_parts[2])
            self.door_name = get_free_device(db, prefix, start_from)
            self._msstarter.addNewDevice(self.door_name, klass='Door')
            # Add properties
            if properties:
                for key, values in properties.items():
                    db.put_device_property(self.ms_name,
                                           {key: values})
            # start MS server
            self._msstarter.startDs()
            self.door = PyTango.DeviceProxy(self.door_name)
        except Exception, e:
            # force tearDown in order to eliminate the MacroServer
            print e
            self.tearDown()
Example #6
0
    def setUp(self, properties=None):
        """
        Start MacroServer DS.

        :param properties: dictionary with the macroserver properies.

        """
        try:
            db = PyTango.Database()
            # Discover the MS launcher script
            msExec = whichexecutable.whichfile("MacroServer")
            # register MS server
            ms_ds_name_base = "MacroServer/" + self.ms_ds_name
            self.ms_ds_name = get_free_server(db, ms_ds_name_base)
            self._msstarter = ProcessStarter(msExec, self.ms_ds_name)
            # register MS device
            dev_name_parts = self.ms_name.split('/')
            prefix = '/'.join(dev_name_parts[0:2])
            start_from = int(dev_name_parts[2])
            self.ms_name = get_free_device(db, prefix, start_from)
            self._msstarter.addNewDevice(self.ms_name, klass='MacroServer')
            # register Door device
            dev_name_parts = self.door_name.split('/')
            prefix = '/'.join(dev_name_parts[0:2])
            start_from = int(dev_name_parts[2])
            self.door_name = get_free_device(db, prefix, start_from)
            self._msstarter.addNewDevice(self.door_name, klass='Door')
            # Add properties
            if properties:
                for key, values in list(properties.items()):
                    db.put_device_property(self.ms_name, {key: values})
            # start MS server
            self._msstarter.startDs(wait_seconds=20)
            self.door = PyTango.DeviceProxy(self.door_name)
        except Exception as e:
            # force tearDown in order to eliminate the MacroServer
            print(e)
            self.tearDown()