當前位置: 首頁>>代碼示例>>Python>>正文


Python rpyc.Service方法代碼示例

本文整理匯總了Python中rpyc.Service方法的典型用法代碼示例。如果您正苦於以下問題:Python rpyc.Service方法的具體用法?Python rpyc.Service怎麽用?Python rpyc.Service使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rpyc的用法示例。


在下文中一共展示了rpyc.Service方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import Service [as 別名]
def __init__(self, active_projects=None, port=1234, host='localhost'):
        if active_projects is None: active_projects = {}
        super(AngrServer, self).__init__()
        self.port = port
        self.host = host
        class AngrService(rpyc.Service):
            exposed_projects = active_projects

            def on_connect(self):
                self._conn._config.update(dict(
                    allow_all_attrs = True,
                    allow_pickle = True,
                    allow_getattr = True,
                    allow_setattr = True,
                    allow_delattr = True,
                    import_custom_exceptions = True,
                    instantiate_custom_exceptions = True,
                    instantiate_oldstyle_exceptions = True,
                ))
        self.service = AngrService 
開發者ID:angr,項目名稱:angr,代碼行數:22,代碼來源:service.py

示例2: CustomizedService

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import Service [as 別名]
def CustomizedService(DATA):
    class Plasma1Service(rpyc.Service):
    
        def on_connect(self):
            # code that runs when a connection is created
            print 'New connection with %s initiated.'%str(self._conn._config['endpoints'][1])
    
        def on_disconnect(self):
            # code that runs when the connection has already closed
            print 'Connection to %s closed.'%str(self._conn._config['endpoints'][1])
            
        def exposed_get_history(self,p,range):   #range in hours
            if DATA.debug: print 'history request from client %s'%str(self._conn._config['endpoints'][1])
            return getattr(DATA,str(p)).get_history(range)
            
        def exposed_get_last_value(self,p):
            if DATA.debug: print 'value request'
            return [getattr(DATA,str(p)).get_timestamp(),getattr(DATA,str(p)).get_last_value()]
            
    return Plasma1Service 
開發者ID:qkitgroup,項目名稱:qkit,代碼行數:22,代碼來源:srv_thread.py

示例3: CustomizedHydroponicsService

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import Service [as 別名]
def CustomizedHydroponicsService(hydroponics_controller, scheduler):
    state = {"paused": False, "resume_time": None}

    class HydroponicsService(rpyc.Service):
        def exposed_is_paused(self):
            return state["paused"]

        def exposed_get_resume_time(self):
            return state["resume_time"]

        def exposed_resume(self):
            """Resume regular operation of the hydroponics system."""

            state["paused"] = False
            try:
                scheduler.remove_job("resume")
            except JobLookupError:
                pass

            for job in ["pump", "lights on", "lights off"]:
                scheduler.resume_job(job)

            current_hour = datetime.datetime.now().time()
            time_on = datetime.time(LIGHTS_TIME_ON, 0)
            time_off = datetime.time(LIGHTS_TIME_OFF, 0)
            if current_hour > time_on and current_hour < time_off:
                hydroponics_controller.lights_on()

        def exposed_pause(self, duration):
            """Pause the hydroponics system for duration seconds."""

            state["paused"] = True
            state["resume_time"] = self.get_resumption_time(duration)
            hydroponics_controller.lights_off()
            hydroponics_controller.pump_off()

            for job in ["pump", "lights on", "lights off"]:
                scheduler.pause_job(job)

            scheduler.add_job(self.exposed_resume, 'date',
                              run_date=state["resume_time"], id="resume")

        def get_resumption_time(self, pause_duration):
            pause_datetime = datetime.timedelta(minutes=int(pause_duration))
            return datetime.datetime.now() + pause_datetime
    
    return HydroponicsService 
開發者ID:tpudlik,項目名稱:hydroponics,代碼行數:49,代碼來源:hydroponics_server.py


注:本文中的rpyc.Service方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。