Exemplo n.º 1
0
 def show_grpc_exception(self,
                         message: str,
                         e: grpc.RpcError,
                         blocking: bool = False) -> None:
     logger.exception("app grpc exception", exc_info=e)
     dialog = ErrorDialog(self, "GRPC Exception", message, e.details())
     if blocking:
         dialog.show()
     else:
         self.after(0, lambda: dialog.show())
Exemplo n.º 2
0
    def setup(self, session_id: int = None) -> None:
        """
        Query sessions, if there exist any, prompt whether to join one
        """
        try:
            self.client.connect()
            self.setup_cpu_usage()

            # get service information
            response = self.client.get_services()
            for service in response.services:
                group_services = self.services.setdefault(service.group, set())
                group_services.add(service.name)

            # get config service informations
            response = self.client.get_config_services()
            for service in response.services:
                self.config_services[service.name] = service
                group_services = self.config_services_groups.setdefault(
                    service.group, set()
                )
                group_services.add(service.name)

            # join provided session, create new session, or show dialog to select an
            # existing session
            response = self.client.get_sessions()
            sessions = response.sessions
            if session_id:
                session_ids = set(x.id for x in sessions)
                if session_id not in session_ids:
                    dialog = ErrorDialog(
                        self.app, "Join Session Error", f"{session_id} does not exist"
                    )
                    dialog.show()
                    self.app.close()
                else:
                    self.join_session(session_id)
            else:
                if not sessions:
                    self.create_new_session()
                else:
                    dialog = SessionsDialog(self.app, True)
                    dialog.show()
        except grpc.RpcError as e:
            logging.exception("core setup error")
            dialog = ErrorDialog(self.app, "Setup Error", e.details())
            dialog.show()
            self.app.close()