示例#1
0
def selected_cases(self):
    """Get a list of all grid cases selected in the project tree

    Returns:
        A list of :class:`rips.generated.generated_classes.Case`
    """
    case_infos = self._project_stub.GetSelectedCases(Empty())
    cases = []
    for case_info in case_infos.data:
        cases.append(self.case(case_info.id))
    return cases
示例#2
0
 def __is_valid_port(port):
     location = "localhost:" + str(port)
     channel = grpc.insecure_channel(location,
                                     options=[('grpc.enable_http_proxy',
                                               False)])
     app = App_pb2_grpc.AppStub(channel)
     try:
         app.GetVersion(Empty(), timeout=1)
     except grpc.RpcError:
         return False
     return True
示例#3
0
文件: Project.py 项目: cxz/ResInsight
    def selectedCases(self):
        """Get a list of all cases selected in the project tree

        Returns:
            A list of rips Case objects
        """
        caseInfos = self.project.GetSelectedCases(Empty())
        cases = []
        for caseInfo in caseInfos.data:
            cases.append(Case(self.channel, caseInfo.id))
        return cases
示例#4
0
    def __init__(self, port=50051, launched=False):
        """Attempts to connect to ResInsight at aa specific port on localhost

        Args:
            port(int): port number
        """
        logging.basicConfig()
        location = "localhost:" + str(port)

        self.channel = grpc.insecure_channel(location,
                                             options=[
                                                 ("grpc.enable_http_proxy",
                                                  False)
                                             ])
        self.launched = launched
        self.commands = Commands_pb2_grpc.CommandsStub(self.channel)

        # Main version check package
        self.app = App_pb2_grpc.AppStub(self.channel)

        self._check_connection_and_version(self.channel, launched, location)

        # Intercept UNAVAILABLE errors and retry on failures
        interceptors = (RetryOnRpcErrorClientInterceptor(
            retry_policy=ExponentialBackoffRetryPolicy(min_backoff=100,
                                                       max_backoff=5000,
                                                       max_num_retries=20),
            status_for_retry=(grpc.StatusCode.UNAVAILABLE, ),
        ), )

        intercepted_channel = grpc.intercept_channel(self.channel,
                                                     *interceptors)

        # Recreate command stubs with the retry policy
        self.commands = Commands_pb2_grpc.CommandsStub(intercepted_channel)

        # Service packages
        self.project = Project.create(intercepted_channel)

        # Command Router object used as entry point for independent processing functions
        self.command_router = CommandRouter(self.app.GetPdmObject(Empty()),
                                            intercepted_channel)

        path = os.getcwd()
        self.set_start_dir(path=path)
示例#5
0
文件: Project.py 项目: cxz/ResInsight
    def cases(self):
        """Get a list of all cases in the project
        
        Returns:
            A list of rips Case objects
        """
        try:
            caseInfos = self.project.GetAllCases(Empty())

            cases = []
            for caseInfo in caseInfos.data:
                cases.append(Case(self.channel, caseInfo.id))
            return cases
        except grpc.RpcError as e:
            if e.code() == grpc.StatusCode.NOT_FOUND:
                return []
            else:
                print("ERROR: ", e)
                return []
示例#6
0
 def is_gui(self):
     """Returns true if the connected ResInsight instance is a GUI app"""
     return self.app.GetRuntimeInfo(
         Empty()).app_type == App_pb2.ApplicationTypeEnum.Value(
             'GUI_APPLICATION')
示例#7
0
 def exit(self):
     """Tell ResInsight instance to quit"""
     print("Telling ResInsight to Exit")
     return self.app.Exit(Empty())
示例#8
0
 def __version_message(self):
     return self.app.GetVersion(Empty())
示例#9
0
 def is_console(self):
     """Returns true if the connected ResInsight instance is a console app"""
     return self.app.GetRuntimeInfo(
         Empty()).app_type == App_pb2.ApplicationTypeEnum.Value(
             "CONSOLE_APPLICATION")
示例#10
0
文件: Project.py 项目: cxz/ResInsight
 def __init__(self, channel):
     self.channel = channel
     self.project = Project_pb2_grpc.ProjectStub(channel)
     PdmObject.__init__(self, self.project.GetPdmObject(Empty()),
                        self.channel)
示例#11
0
 def closeProject(self):
     """Close the current project (and reopen empty one)"""
     return self.__execute(closeProject=Empty())
示例#12
0
def close(self):
    """Close the current project (and open new blank project)"""
    self._execute_command(closeProject=Empty())
示例#13
0
def create(channel):
    project_stub = Project_pb2_grpc.ProjectStub(channel)
    pb2_object = project_stub.GetPdmObject(Empty())
    return Project(pb2_object, channel)