示例#1
0
    def start(self,
              command,
              arguments,
              on_started=None,
              on_exit=None,
              env=None):
        if self.is_running():
            raise RuntimeError('Process is already running.')
        args = [command]
        args.extend(arguments)
        if env is None:
            env = clean_environment()

        def run_process():
            with open(self.stdout_path, 'w') as stdout_fd:
                with open(self.stderr_path, 'w') as stderr_fd:
                    self.process = subprocess.Popen(args,
                                                    stdout=stdout_fd,
                                                    stderr=stderr_fd,
                                                    env=env)
                    if on_started:
                        on_started(self)
                    self.process.wait()
                    if on_exit:
                        on_exit(self)

        start_thread(target=run_process)
示例#2
0
 def shoot(self, guider_id, exposure, initial_pause):
     if exposure < 30:
         raise BadRequestError('Exposure should be at least 30 seconds')
     guider = [
         g for g in controller.indi_server.guiders() if g.id == guider_id
     ]
     if not guider:
         raise BadRequestError('Guider not found: {} (guiders: {})'.format(
             guider_id,
             ', '.join([g.id for g in controller.indi_server.guiders()])))
     start_thread(self.__darv, guider[0], exposure, initial_pause)
     return {'started': 'ok'}
示例#3
0
 def __start_slew_solver(self, options):
     if not 'cameraOptions' in options:
         raise BadRequestError(
             'You need to capture from camera when using Slew mode')
     if not 'target' in options:
         raise BadRequestError('You need a target when using Slew mode')
     if not 'telescope' in options:
         raise BadRequestError('You need a telescope when using Slew mode')
     self.solver_thread = start_thread(self.__slew_solver_thread, options)
     return self.to_map()
示例#4
0
 def __init__(self):
     self.settings = settings
     settings.add_update_listener(self.__on_settings_update)
     self.indi_profiles = SavedList(INDIProfile)
     self.sequences_runner = SequencesRunner(logger, self)
     self.sequences = None
     self.ping_thread = start_thread(self.__ping_clients)
     self.__create_indi_service()
     self.__create_indi_server()
     self.sequences = SavedList(Sequence)
     self.astrometry_downloader = AstrometryIndexDownloader(event_listener)
     self.platesolving = PlateSolving(self.indi_server, event_listener)
示例#5
0
    def __init__(self, on_saved, on_error):
        self.files_queue = mp_queue(SaveAsyncFITS.MAX_QUEUE_SIZE)
        self.notify_queue = mp_queue()

        self.process_files = mp_start_process(self.__process_sequence_files,
                                              self.files_queue,
                                              self.notify_queue)
        self.notify_thread = start_thread(self.__notify_sequence_finished,
                                          self.notify_queue)

        self.on_saved = on_saved
        self.on_error = on_error
示例#6
0
 def __init__(self):
     self.sse = SSE(app.logger)
     self.settings = settings
     settings.on_update = self.__on_settings_update
     self.indi_profiles = SavedList(INDIProfile)
     self.event_listener = EventListener(self.sse)
     self.sequences_runner = SequencesRunner(app.logger, self)
     self.sequences = None
     self.ping_thread = start_thread(self.__ping_clients)
     self.__create_indi_service()
     self.__create_indi_server()
     self.sequences = SavedList(Sequence)
     self.astrometry_downloader = AstrometryIndexDownloader(
         self.event_listener)
示例#7
0
    def __start_solver(self, options):
        temp_path = os.path.join(StaticSettings.ASTROMETRY_TEMP_PATH,
                                 'solve_field_{}'.format(time.time()))
        os.makedirs(temp_path, exist_ok=True)

        fits_file_path = None
        logger.debug('Solve field options: %s',
                     self.__platesolving_options_log(options))
        if 'fileBuffer' in options:
            data = base64.b64decode(
                options['fileBuffer']
                [options['fileBuffer'].find(PlateSolving.DATAURL_SEPARATOR) +
                 len(PlateSolving.DATAURL_SEPARATOR):])
            fits_file_path = self.__data_to_fits(data, temp_path)
        elif 'filePath' in options and os.path.isfile(options['filePath']):
            fits_file_path = options['filePath']
        elif 'cameraOptions' in options:
            from system import controller
            cameraOptions = options['cameraOptions']
            camera = controller.indi_server.get_camera(
                cameraOptions['camera']['id'])
            logger.debug('Shooting on camera {} with options {}'.format(
                camera, cameraOptions))
            result = camera.shoot_image(cameraOptions)
            logger.debug('Shoot successfull: {}'.format(result))
            fits_file_path = result['filename']
        else:
            raise BadRequestError(
                'You must pass either a fileBuffer object (data-uri formatted) or a filePath argument'
            )
        resolution = None
        with fits.open(fits_file_path) as fits_file:
            resolution = fits_file[0].data.shape

        if options.get('sync', False):
            return self.__wait_for_solution(options, resolution,
                                            fits_file_path, temp_path)
        else:
            self.solver_thread = start_thread(self.__async_wait_for_solution,
                                              options, resolution,
                                              fits_file_path, temp_path)
            return self.to_map()
示例#8
0
 def connect(self, hostname='localhost', port=4400):
     self.__connect = True
     self.__thread = start_thread(self.__socket_loop, hostname, port)
     return self.__get_result().get('connected', False)
 def __init__(self, sequence, controller, logger, on_finished=None):
     self.sequence = sequence
     self.controller = controller
     self.logger = logger
     self.thread = start_thread(self.__run)
     self.on_finished = on_finished
def broadcast_service():
    start_thread(__broadcast_loop)
示例#11
0
 def on_start(self):
     logger.debug('PHD2 Service started')
     self.__change_state(True, key='running', publish=False)
     self.__events_thread = start_thread(self.__check_events)
 def publish(self, data, type):
     start_thread(self.__publish_to_clients, data, type)
示例#13
0
 def start(self):
     self.last_connection_check = time.time()
     start_thread(self.__loop)