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


Python Session.recv方法代码示例

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


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

示例1: doDatabaseAction

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import recv [as 别名]
def doDatabaseAction(broker, user, password, db_name, action, child=None):
    s = Session(broker, service="ChorusManagement")
    s.authorize(user, password)

    if child is not None:
        child = [ child ]
    s.doConnect(attributes={"Database" : db_name, "Action" : action}, children=child)
    response = s.recv()
    checkForError(response)

    s.close()

    return response
开发者ID:DukeNuoDB,项目名称:nuodb-python,代码行数:15,代码来源:util.py

示例2: monitorDomainStats

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import recv [as 别名]
def monitorDomainStats(broker, user, password, listener=None):
    if not listener:
        listener = _StandardOutListener()

    s = Session(broker, service="HostStats")
    s.authorize(user, password)

    s.doConnect()
    checkForError(s.recv())

    monitor = SessionMonitor(s, listener=listener)
    monitor.start()

    return monitor
开发者ID:DukeNuoDB,项目名称:nuodb-python,代码行数:16,代码来源:util.py

示例3: getCloudEntry

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import recv [as 别名]
def getCloudEntry(broker, db_name, attrs=None):
    if not attrs:
        attrs = dict()
    attrs["Database"] = db_name

    s = Session(broker, service="SQL2")

    s.doConnect(attributes=attrs)
    connectDetail = s.recv()
    s.close()

    checkForError(connectDetail)

    root = ElementTree.fromstring(connectDetail)
    if root.tag != "Cloud":
        raise SessionException("Unexpecetd response type: " + root.tag)

    return (root.get("Address"), int(root.get("Port")))
开发者ID:DukeNuoDB,项目名称:nuodb-python,代码行数:20,代码来源:util.py

示例4: queryEngine

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import recv [as 别名]
def queryEngine(address, port, target, dbPassword, msgBody=None):
    s = Session(address, port=port, service="Query")
    s.authorize("Cloud", dbPassword)
    s.doConnect()

    msg = "<Query Target=\"%s\"/>" % target
    if msgBody is not None:
        xml = ElementTree.fromstring(msg)
        xml.append(msgBody)
        msg = ElementTree.tostring(xml)

    s.send(msg)
    response = s.recv()

    checkForError(response)

    s.close()

    return response
开发者ID:DukeNuoDB,项目名称:nuodb-python,代码行数:21,代码来源:util.py

示例5: Domain

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import recv [as 别名]
class Domain(BaseListener):
    """Represents the NuoDB domain.
    
    The domain is the top level NuoDB management object. The domain object 
    provides access to the peers and databases that are contained within.
    """

    def __init__(self, broker_addr, domain_user, domain_pwd, listener=None):
        """
        @type broker_addr str
        @type domain_user str
        @type domain_pwd str
        @type listener
        """
        if not domain_pwd:
            raise Exception("A password is required to join a domain")

        self.__session = Session(broker_addr, service="Monitor")
        self.__session.authorize(domain_user, domain_pwd)

        self.__user = domain_user
        self.__password = domain_pwd
        self.__listener = listener
        self.__peers = dict()
        """ @type : dict[str, Peer] """
        self.__databases = dict()
        """ @type : dict[str, Database] """

        self.__monitor = SessionMonitor(self.__session, self)
        
        # These will be set in handle status after joining the domain 
        self.__domain_name = None
        """ @type : str """
        self.__entry_peer = None
        """ @type : Peer """

        try:
            self.__session.doConnect()
            self.__handle_status(self.__session.recv())
        except Exception:
            self.__monitor.close()
            raise

        self.__monitor.start()

    def __str__(self):
        return self.domain_name + " [Entered through: " + self.entry_peer.connect_str + "]"

    def disconnect(self):
        """Disconnect from the domain."""
        self.__monitor.close()
        
    def _send_domain_message(self, service, attributes=None, text=None, children=None):
        session = Session(self.__entry_peer.address, port=self.__entry_peer.port, service=service)
        session.authorize(self.__user, self.__password)
        return session.doRequest(attributes, text, children)

    @property
    def user(self):
        """Return the domain user."""
        return self.__user

    @property
    def password(self):
        """Return the domain password."""
        return self.__password
    
    @property
    def domain_name(self):
        """Return the domain name."""
        return self.__domain_name

    def find_peer(self, address):
        """
        Find a peer by address
        @type: address str
        @rtype: Peer
        """

    def get_peer(self, agent_id):
        """
        Return a peer for a given agent_id.
        @type agent_id str
        @rtype: Peer
        """
        return self.__peers.get(agent_id)

    @property
    def peers(self):
        """
        Return a list of all peers in the domain.
        @rtype: list[Peer]
        """
        return self.__peers.values()

    @property
    def entry_peer(self):
        """
        Return the peer that was used to enter the domain.
        @rtype: Peer
#.........这里部分代码省略.........
开发者ID:keithmcneill,项目名称:nuodb-python,代码行数:103,代码来源:entity.py

示例6: Domain

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import recv [as 别名]
class Domain(BaseListener):
    def __init__(self, brokerAddr, domainUser, domainPwd, listener=None):
        if not domainPwd:
            raise Exception("A password is required to join a domain")

        self.__session = Session(brokerAddr, service="Monitor")
        self.__session.authorize(domainUser, domainPwd)

        self.__user = domainUser
        self.__password = domainPwd
        self.__listener = listener
        self.__peers = dict()
        self.__databases = dict()

        self.__monitor = SessionMonitor(self.__session, self)

        try:
            self.__session.doConnect()
            self.__handleStatus(self.__session.recv())
        except Exception:
            self.__monitor.close()
            raise

        self.__monitor.start()

    def __str__(self):
        return self.getDomainName() + " [Entered through: " + self.getEntryPeer().getConnectStr() + "]"

    def disconnect(self):
        self.__monitor.close()

    def getUser(self):
        return self.__user

    def getPassword(self):
        return self.__password

    def getDomainName(self):
        return self.__domainName

    def getPeer(self, agentId):
        return self.__peers.get(agentId)

    def getPeers(self):
        return self.__peers.itervalues()

    def getEntryPeer(self):
        return self.__entryPeer

    def getDatabase(self, name):
        return self.__databases.get(name)

    def getDatabases(self):
        return self.__databases.itervalues()

    def getDatabaseCount(self):
        return len(self.__databases)

    def shutdown(self, graceful=True):
        for (dbName, db) in self.__databases.items():
            db.shutdown(graceful)

    def messageReceived(self, root):
        if root.tag == "Event":
            eventType = root.get("Type")
            if eventType == "NewBroker":
                self.__peerJoined(Peer.fromMessage(self, root.find("Broker")))
            elif eventType == "BrokerExit":
                self.__peerLeft(Peer.fromMessage(self, root.find("Broker")))
            elif eventType == "StatusChanged":
                status = root.get("Status")

                processElement = root.find("Process")
                db = self.__databases[processElement.get("Database")]
                process = Process.fromMessage(db, processElement)

                self.__processStatusChanged(process, status)
            elif eventType == "ProcessFailed":
                peer = Peer.fromMessage(self, root.find("Broker"))
                peer = self.getPeer(peer.getId())

                reason = root.get("Reason")
                startId = root.get("StartId")

                self.__processFailed(peer, startId, reason)
            elif eventType == "NewProcess" or eventType == "ProcessExit":
                processElement = root.find("Process")
                dbName = processElement.get("Database")

                if dbName not in self.__databases:
                    self.__databases[dbName] = Database(self, dbName)
                    if self.__listener:
                        try:
                            self.__listener.databaseJoined(self.__databases[dbName])
                        except:
                            pass

                if eventType == "NewProcess":
                    startId = processElement.get("StartId")
                    self.__processJoined(Process.fromMessage(self.__databases[dbName], processElement), startId)
#.........这里部分代码省略.........
开发者ID:princeirmal,项目名称:nuodb-python,代码行数:103,代码来源:entity.py


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