Exemple #1
0
    def prepare_capture(self):
        self._logger.info("Preparing capture.")
        self._update_status(step='capture')
        self._pool_executor = ThreadPoolExecutor(
            max_workers=multiprocessing.cpu_count())
        if any(dev.target_page is None for dev in self.devices):
            raise util.DeviceException(
                "Target page for at least one of the devicescould not be"
                "determined, please run 'spread configure' to configure your"
                "your devices.")
        with ThreadPoolExecutor(len(self.devices)) as executor:
            futures = []
            self._logger.debug("Preparing capture in devices")
            for dev in self.devices:
                futures.append(executor.submit(dev.prepare_capture, self.path))
        util.check_futures_exceptions(futures)

        flip_target = ('flip_target_pages' in self.config['device'].keys()
                       and self.config['device']['flip_target_pages'].get())
        if flip_target:
            (self.devices[0].target_page,
             self.devices[1].target_page) = (self.devices[1].target_page,
                                             self.devices[0].target_page)
        self._run_hook('prepare_capture', self.devices, self.path)
        self._run_hook('start_trigger_loop', self.capture)
        self._update_status(prepared=True)
Exemple #2
0
    def prepare_capture(self):
        """ Prepare capture on devices and initialize trigger plugins. """
        self._logger.info("Preparing capture.")
        self._update_status(step='capture')
        if any(dev.target_page is None for dev in self.devices):
            raise util.DeviceException(
                "Target page for at least one of the devices could not be"
                "determined, please run 'spread configure' to configure your"
                "devices.")
        with concfut.ThreadPoolExecutor(len(self.devices)) as executor:
            futures = []
            self._logger.debug("Preparing capture in devices")
            for dev in self.devices:
                futures.append(executor.submit(dev.prepare_capture))
        util.check_futures_exceptions(futures)

        flip_target = ('flip_target_pages' in self.config['device'].keys() and
                       self.config['device']['flip_target_pages'].get())
        if flip_target:
            (self.devices[0].target_page,
             self.devices[1].target_page) = (self.devices[1].target_page,
                                             self.devices[0].target_page)
        self._run_hook('prepare_capture', self.devices)
        self._run_hook('start_trigger_loop', self.capture)
        self._update_status(prepared=True)
Exemple #3
0
 def devices(self):
     if 'driver' not in self.config.keys():
         raise util.DeviceException(
             "No driver has been configured\n"
             "Please run `spread configure` to select a driver.")
     if self._devices is None:
         self._devices = plugin.get_devices(self.config, force_reload=True)
     if any(not dev.connected() for dev in self._devices):
         self._logger.warning(
             "At least one of the devices has been disconnected."
             "Please make sure it has been re-enabled before taking another"
             "action.")
         self._devices = None
     if not self._devices:
         raise util.DeviceException("Could not find any compatible "
                                    "devices!")
     return self._devices