当前位置: 首页>>代码示例>>Python>>正文


Python ServerProxy.isRunning方法代码示例

本文整理汇总了Python中xmlrpclib.ServerProxy.isRunning方法的典型用法代码示例。如果您正苦于以下问题:Python ServerProxy.isRunning方法的具体用法?Python ServerProxy.isRunning怎么用?Python ServerProxy.isRunning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xmlrpclib.ServerProxy的用法示例。


在下文中一共展示了ServerProxy.isRunning方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Server

# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import isRunning [as 别名]
    class Server(object):
        """Server is the local represetative of a remote pdfserver

        pdfserver: a xmlrpclib.ServerProxy to pdfserver
        address: a host:port string
        busy: True if it is in use, otherwise False
        running: True if it is running
        connection: a ssh2 connection to remote host
        port: remote port where pdfserver is servicing
        """
        def __init__(self, connection):
            """Initialize the remote server

            connection -- a ssh2 connection to remote host
            """
            self.connection = connection
            self.pdfserver = None
            self.port = -1
            self.address = ''

            # One server can only service one fitting request at a time
            # by default, create and use
            self.busy = True
            self.running = False

            self.__start()

        def __start(self):
            """Start remote pdfserver. pdfserver.py must be in the user's PATH.
            It chooses the remote port on which it is running.
            """
            command = "pdffit2server"
            output = self.connection.execute(command)
            try:
                self.port = int(output.splitlines()[0])
            except (IndexError,ValueError):
                raise ControlRuntimeError, \
                "Unrecognized output from remote host %s: "%self.connection.host + output
            return

        def connect(self):
            """Set up XMLRPC ServerProxy and test connection.
            """
            from xmlrpclib import ServerProxy
            self.address = "http://%s:%i"%(self.connection.host, self.port)
            transport = self.connection.getXMLRPCTransport()
            self.pdfserver = ServerProxy(self.address,transport)

            import time

            # now keep polling if the server is up ( test for 15 seconds)
            counter = 5
            while counter > 0 and not self.running:
                if self.connection.owner.quit:
                    return
                try:
                    # server started slowly, allow 3 seconds in the beginning
                    time.sleep(3)
                    self.running = self.pdfserver.isRunning()
                    counter = -1
                except ControlConnectError:
                    counter -= 1


            if counter == 0:
                raise ControlRuntimeError, \
                    "Can not connect to [email protected]'%s'"%self.connection.host

        def close(self):
            """Kill the server"""
            if self.running:
                self.pdfserver.kill_server()
            return
开发者ID:XiaohaoYang,项目名称:diffpy.pdfgui,代码行数:75,代码来源:serverhost.py

示例2: ErtRPCClient

# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import isRunning [as 别名]
class ErtRPCClient(object):
    def __init__(self, host, port, verbose=False):
        self._server_proxy = ServerProxy("http://%s:%s" % (host, port), allow_none=True, verbose=verbose)
        socket.setdefaulttimeout(180) # 3 minutes

    def ertVersion(self):
        """
         Returns a version tuple: (major, minor, micro)
         @rtype: tuple
        """
        return tuple(self._server_proxy.ertVersion())

    def getTimeMap(self, target_case_name):
        """
         Returns a list of datetime objects for the named target case name
         @type target_case_name: str
         @rtype: list of datetime
        """
        return self._server_proxy.getTimeMap(target_case_name)


    def isRunning(self):
        """
        Returns True if a simulation batch has been started and is running.
        @rtype: bool
        """
        return self._server_proxy.isRunning()


    def isInitializationCaseAvailable(self):
        """
        Returns True if the initialization case is prepared and ready to run simulations.
        @rtype: bool
        """
        return self._server_proxy.isInitializationCaseAvailable()


    def startSimulationBatch(self, initialization_case_name, simulation_count):
        """
        Start a simulation batch. Will prepare a batch that will run for the specified number of realizations.
        Will fail if the server is already running a batch or no initialization case is available.
        @param initialization_case_name: The case containing geo realizations
        @type initialization_case_name: str
        @type simulation_count: int
        """
        try:
            self._server_proxy.startSimulationBatch(initialization_case_name, simulation_count)
        except Fault as f:
            raise convertFault(f)


    def addSimulation(self, target_case_name, geo_id, pert_id, sim_id, keywords):
        """
        Start a simulation.
        @type target_case_name: str
        @type geo_id: int
        @type pert_id:
        @type sim_id: int
        @type keywords: dict[str, list]
        @raise UserWarning if the server is not ready to receive simulations
        @raise UserWarning if the server is already running a simulation with the same id as sim_id
        """
        try:
            self._server_proxy.addSimulation(target_case_name, geo_id, pert_id, sim_id, keywords)
        except Fault as f:
            raise convertFault(f)


    def isRealizationFinished(self, sim_id):
        """
        Returns true if the realization is finished running.
        @type sim_id: int
        @rtype: bool
        """
        return self._server_proxy.isRealizationFinished(sim_id)

    def didRealizationSucceed(self, sim_id):
        """
        Check if the realization successfully finished running.
        @type sim_id: int
        @rtype: bool
        """
        return self._server_proxy.didRealizationSucceed(sim_id)

    def didRealizationFail(self, sim_id):
        """
        Check if the realization failed while running.
        @type sim_id: int
        @rtype: bool
        """
        return self._server_proxy.didRealizationFail(sim_id)

    def getGenDataResult(self, target_case_name, sim_id, report_step, keyword):
        """
        Retrieve a GenData result from a target case
        @type target_case_name: str
        @type sim_id: int
        @type report_step: int
        @type keyword: str
        @rtype: list[float]
#.........这里部分代码省略.........
开发者ID:agchitu,项目名称:ert,代码行数:103,代码来源:ertrpcclient.py

示例3: ErtRPCClient

# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import isRunning [as 别名]
class ErtRPCClient(object):
    def __init__(self, host, port, verbose=False):
        self._server_proxy = ServerProxy("http://%s:%s" % (host, port), allow_none=True, verbose=verbose)
        socket.setdefaulttimeout(180) # 3 minutes

    def ertVersion(self):
        """
         Returns a version tuple: (major, minor, micro)
         @rtype: tuple
        """
        return tuple(self._server_proxy.ertVersion())

    def getTimeMap(self, target_case_name):
        """
         Returns a list of datetime objects for the named target case name
         @type target_case_name: str
         @rtype: list of datetime
        """
        return self._server_proxy.getTimeMap(target_case_name)


    def isRunning(self):
        """
        Returns True if a simulation batch has been started and is running.
        @rtype: bool
        """
        return self._server_proxy.isRunning()


    def isInitializationCaseAvailable(self):
        """
        Returns True if the initialization case is prepared and ready to run simulations.
        @rtype: bool
        """
        return self._server_proxy.isInitializationCaseAvailable()


    def startSimulationBatch(self, initialization_case_name, simulation_count):
        """
        Start a simulation batch. Will prepare a batch that will run for the specified number of realizations.
        Will fail if the server is already running a batch or no initialization case is available.
        @param initialization_case_name: The case containing geo realizations
        @type initialization_case_name: str
        @type simulation_count: int
        """
        try:
            self._server_proxy.startSimulationBatch(initialization_case_name, simulation_count)
        except Fault as f:
            raise convertFault(f)


    def addSimulation(self, target_case_name, geo_id, pert_id, sim_id, keywords):
        """
        Start a simulation.
        @type target_case_name: str
        @type geo_id: int
        @type pert_id:
        @type sim_id: int
        @type keywords: dict[str, list]
        @raise UserWarning if the server is not ready to receive simulations
        @raise UserWarning if the server is already running a simulation with the same id as sim_id
        """
        try:
            self._server_proxy.addSimulation(target_case_name, geo_id, pert_id, sim_id, keywords)
        except Fault as f:
            raise convertFault(f)


    def isRealizationFinished(self, sim_id):
        """
        Returns true if the realization is finished running.
        @type sim_id: int
        @rtype: bool
        """
        return self._server_proxy.isRealizationFinished(sim_id)

    def didRealizationSucceed(self, sim_id):
        """
        Check if the realization successfully finished running.
        @type sim_id: int
        @rtype: bool
        """
        return self._server_proxy.didRealizationSucceed(sim_id)

    def didRealizationFail(self, sim_id):
        """
        Check if the realization failed while running.
        @type sim_id: int
        @rtype: bool
        """
        return self._server_proxy.didRealizationFail(sim_id)

    def getGenDataResult(self, target_case_name, sim_id, report_step, keyword):
        """
        Retrieve a GenData result from a target case
        @type target_case_name: str
        @type sim_id: int
        @type report_step: int
        @type keyword: str
        @rtype: list[float]
#.........这里部分代码省略.........
开发者ID:akva2,项目名称:ert,代码行数:103,代码来源:ertrpcclient.py


注:本文中的xmlrpclib.ServerProxy.isRunning方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。