def disconnect_application(self): if not self.is_app_running(self.APP_BACKDROP): self.socket.send(commands.CloseCommand(destination_id=False)) start_time = time.time() while not self.is_app_running(None): self.socket.send_and_wait(commands.StatusCommand()) current_time = time.time() if current_time - start_time > self.timeout: raise TimeoutException() time.sleep(self.WAIT_INTERVAL) else: logger.debug('Closing not necessary. Backdrop is running ...')
def __init__(self, socket): self.request_id = 1 self.transport_id = 'receiver-0' self.session_id = None self.app_id = None self.channels = [] self.socket = socket self.socket.add_send_listener(self._handle_send) self.socket.add_read_listener(self._handle_response) self.socket.send_and_wait(commands.StatusCommand())
def launch_application(self, app_id): if not self.is_app_running(app_id): self.socket.send(commands.LaunchCommand(app_id)) start_time = time.time() while not self.is_app_running(app_id): self.socket.send_and_wait(commands.StatusCommand()) current_time = time.time() if current_time - start_time > self.timeout: raise TimeoutException() time.sleep(self.WAIT_INTERVAL) else: logger.debug('Starting not necessary. Application is running ...')
def stop_application(self): if not self.is_app_running(self.APP_BACKDROP): self.socket.send(commands.StopCommand()) retries = 0 while not self.is_app_running(self.APP_BACKDROP): if retries > self.max_retries: return False self.socket.send_and_wait(commands.StatusCommand()) time.sleep(1) retries += 1 return True else: logger.debug('Stop not necessary. Backdrop is running ...') return True
def launch_application(self, app_id): if not self.is_app_running(app_id): self.socket.send(commands.LaunchCommand(app_id)) retries = 0 while not self.is_app_running(app_id): if retries > self.max_retries: return False self.socket.send_and_wait(commands.StatusCommand()) time.sleep(1) retries += 1 return True else: logger.debug('Starting not necessary. Application is running ...') return True
def disconnect_application(self): if not self.is_app_running(self.APP_BACKDROP): self.socket.send(commands.CloseCommand(destination_id=False)) try: retries = 0 while not self.is_app_running(self.APP_BACKDROP): if retries > self.max_retries: return False self.socket.send_and_wait(commands.StatusCommand()) time.sleep(1) retries += 1 return True except ChannelClosedException: logger.info('Connection was closed. I guess another ' 'client has attached to it.') return True else: logger.debug('Closing not necessary. Backdrop is running ...') return True
print(poll.execute()) elif arguments["fetch"]: fetch = cmd.FetchCommand(used_args, services_manager) fetch.execute() elif arguments["history"]: history = cmd.HistoryCommand(used_args, services_manager) res = history.execute() print(res) elif arguments["backup"]: backup = cmd.BackupCommand(used_args, services_manager) print(backup.execute()) elif arguments["restore"]: restore = cmd.RestoreCommand(used_args, services_manager) print(restore.execute()) elif arguments["services"]: services = cmd.ServicesCommand(used_args, services_manager, "config.txt") print(services.execute()) elif arguments["help"]: print(__doc__) elif arguments["status"]: status = cmd.StatusCommand(used_args, services_manager) status.execute()