示例#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())
示例#2
0
    def setup(self):
        """
        Query sessions, if there exist any, prompt whether to join one
        """
        try:
            self.client.connect()
            # 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)

            # if there are no sessions, create a new session, else join a session
            response = self.client.get_sessions()
            sessions = response.sessions
            if len(sessions) == 0:
                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()
示例#3
0
文件: app.py 项目: walterhil/core
 def show_error(self, title: str, message: str) -> None:
     self.after(0, lambda: ErrorDialog(self, title, message).show())
示例#4
0
 def show_exception_data(self, title: str, message: str,
                         details: str) -> None:
     self.after(0,
                lambda: ErrorDialog(self, title, message, details).show())
示例#5
0
 def show_exception(self, message: str, e: Exception) -> None:
     logger.exception("app exception", exc_info=e)
     self.after(
         0,
         lambda: ErrorDialog(self, "App Exception", message, str(e)).show())
示例#6
0
 def setup(self, session_id: int = None) -> None:
     """
     Query sessions, if there exist any, prompt whether to join one
     """
     try:
         self.client.connect()
         # get all available services
         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] = ConfigService.from_proto(
                 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()