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


Python rpyc.connect方法代碼示例

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


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

示例1: ensure_connected

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def ensure_connected(func):
        @wraps(func)
        def func_wrapper(*args):
            self = args[0]
            if not isinstance(self.conn, Connection) or self.conn.closed:
                self.connect()
            print('running {0}()'.format(func.__name__))
            # 如果和rpyc服務端斷開了,則自動重新連接
            try:
                return func(*args)
            except Exception as e:
                if isinstance(e, EOFError):
                    self.connect()
                    return func(*args)
                else:
                    raise e
        return func_wrapper 
開發者ID:gsw945,項目名稱:schedule-system,代碼行數:19,代碼來源:rpyc_util.py

示例2: service01

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def service01():
    conn = rpyc.connect(host='localhost', port=18861)
    root = conn.root  # MyService object
    # object
    print root

    print root.get_service_name()
    print root.get_service_aliases()

    # custom method
    print root.get_answer()  # 66
    print root.exposed_get_answer()  # 66
    # print root.get_question()  # AttributeError: cannot access 'get_question'

    registrar = UDPRegistryClient()
    list_of_servers = registrar.discover("foo")
    print rpyc.discover(service_name='MY', host='localhost') 
開發者ID:tomoncle,項目名稱:Python-notes,代碼行數:19,代碼來源:client_test.py

示例3: opt4

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def opt4(self, p_iJoy = None, p_iLine = None):
        p_lLines = {}
        if p_iJoy == None:
            return self.opt4_datas()
        if p_iJoy & CRT_LEFT or p_iJoy & CRT_RIGHT:
            list = self.m_lLines[p_iLine]['options']
            value = self.m_lLines[p_iLine]['value']
            new = explore_list(p_iJoy, value, list)
            if new:
                new = int(new.replace("%", ''))
                try:
                    try: self.con.root
                    except: self.con = rpyc.connect('localhost', 18861)
                    vol = self.con.root.change_vol(new)
                    if vol == new:
                        self.m_lLines[p_iLine]['value'] = str(new) + "%"
                except:
                    pass 
開發者ID:krahsdevil,項目名稱:Retropie-CRT-Edition,代碼行數:20,代碼來源:main_sub2.py

示例4: getNewtasks

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def getNewtasks(self,num):

		data=[]

		if self.__client is None:
			self.connect()

		result = self.__client.root.client_getNewtasks(num)
		
		for task in result:

			Settings.WAT_MSG_INFO['taskid']=task[0]
			Settings.WAT_MSG_INFO['website']=task[1]
                	Settings.WAT_MSG_INFO['profile']=task[2]
			msg = json.dumps(Settings.WAT_MSG_INFO)
			
			content={"taskid":task[0],"msg":msg}

			data.append(content)
	
		return data 
開發者ID:imiyoo2010,項目名稱:teye_scanner_for_book,代碼行數:23,代碼來源:RDB.py

示例5: connect

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def connect(self):
        self.disconnect()
        client_config={
            "allow_all_attrs": True
        }
        self.conn = rpyc.connect(self.host, self.port, config=client_config) 
開發者ID:gsw945,項目名稱:schedule-system,代碼行數:8,代碼來源:rpyc_util.py

示例6: main

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def main():
    username, password = login()
    if username is not None:
        try:
            service = rpyc.connect(HOST, PORT)
            manager = service.root
            sessionId, name = manager.login(username, password)
            print("Welcome, {}, to Meter RPYC".format(name))
            interact(manager, sessionId)
        except ConnectionError as err:
            print("Error: Is the meter server running? {}".format(err)) 
開發者ID:lovexiaov,項目名稱:python-in-practice,代碼行數:13,代碼來源:meterclient-rpyc.py

示例7: conn

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def conn(cls):
        connections = rpyc.connect('localhost', 15111)
        connections.root.save_data(123)
        print connections.root.get_data() 
開發者ID:tomoncle,項目名稱:Python-notes,代碼行數:6,代碼來源:demo.py

示例8: __init__

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def __init__(self, host, port):
        c = rpyc.connect(host, port)
        c._config['sync_request_timeout'] = None
        self.proxy = c.root 
開發者ID:nladuo,項目名稱:MMFinder,代碼行數:6,代碼來源:SPTAG_rpc_search_client.py

示例9: connect

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def connect(self, service = VoidService, config = {}):
        """Same as :func:`connect <rpyc.utils.factory.connect>`, but with the ``host`` and ``port`` 
        parameters fixed"""
        if self.local_port is None:
            # ParamikoMachine
            stream = SocketStream(self.remote_machine.connect_sock(self.remote_port))
            return rpyc.connect_stream(stream, service = service, config = config)
        else:
            return rpyc.connect("localhost", self.local_port, service = service, config = config) 
開發者ID:krintoxi,項目名稱:NoobSec-Toolkit,代碼行數:11,代碼來源:zerodeploy.py

示例10: classic_connect

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def classic_connect(self):
        """Same as :func:`classic.connect <rpyc.utils.classic.connect>`, but with the ``host`` and 
        ``port`` parameters fixed"""
        if self.local_port is None:
            # ParamikoMachine
            stream = SocketStream(self.remote_machine.connect_sock(self.remote_port))
            return rpyc.classic.connect_stream(stream)
        else:
            return rpyc.classic.connect("localhost", self.local_port) 
開發者ID:krintoxi,項目名稱:NoobSec-Toolkit,代碼行數:11,代碼來源:zerodeploy.py

示例11: connect_all

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def connect_all(self, service = VoidService, config = {}):
        """connects to all deployed servers; returns a list of connections (order guaranteed)"""
        return [s.connect(service, config) for s in self.servers] 
開發者ID:krintoxi,項目名稱:NoobSec-Toolkit,代碼行數:5,代碼來源:zerodeploy.py

示例12: connect

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def connect(self):

		try:
			self.__client = rpyc.connect(Settings.RPYC_HOST,Settings.RPYC_PORT)

			self.__client.root.open()

		except Exception,e:
			
			self.close() 
開發者ID:imiyoo2010,項目名稱:teye_scanner_for_book,代碼行數:12,代碼來源:RDB.py

示例13: _init

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def _init(self):
        
        self._taskid    =int(cfg.getData('taskid'))
        self._website   =cfg.getData("target").get_host()

	self._host    =cfg.getData('RPC_SERVER_IP')
        self._port    =int(cfg.getData('RPC_SERVER_PORT'))
        
        try:
            self._client=rpyc.connect(self._host,self._port)
            self._client.root.open()
            
        except Exception,e:
            log.error(str(e)) 
開發者ID:imiyoo2010,項目名稱:teye_scanner_for_book,代碼行數:16,代碼來源:mysqlmanager.py

示例14: setup_remote_connection

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def setup_remote_connection(self):
        '''
        Setup rpyc server connection.
        '''
        self.c = rpyc.connect(self.data.localhost.ip,self.data.localhost.port)
        print('Connection established to %s via port %s.'%(str(self.data.localhost.ip),str(self.data.localhost.port))) 
開發者ID:qkitgroup,項目名稱:qkit,代碼行數:8,代碼來源:client_main.py

示例15: _setup_signal_slots

# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def _setup_signal_slots(self):
        self.cb_scale.currentIndexChanged.connect(self._range_changed)   #combo box 
開發者ID:qkitgroup,項目名稱:qkit,代碼行數:4,代碼來源:client_main.py


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