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


Python Session.authorize方法代码示例

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


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

示例1: killProcess

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import authorize [as 别名]
def killProcess(agent, user, password, pid):
    s = Session(agent, service="ProcessStop")
    s.authorize(user, password)

    response = s.doRequest(attributes={"PID" : str(pid)})

    return int(ElementTree.fromstring(response).get("ExitCode"))
开发者ID:DukeNuoDB,项目名称:nuodb-python,代码行数:9,代码来源:util.py

示例2: stopProcess

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

    s.send("<Request Action=\"shutdown\"/>")

    s.close()
开发者ID:DukeNuoDB,项目名称:nuodb-python,代码行数:10,代码来源:util.py

示例3: query

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import authorize [as 别名]
    def query(self, type, msgBody=None):
        s = Session(self.getPeer().getConnectStr(), service="Manager")
        s.authorize(self.getPeer().getDomain().getUser(), self.getPeer().getDomain().getPassword())
        pwdResponse = s.doRequest(attributes={"Type": "GetDatabaseCredentials", "Database": self.getDbName()})

        pwdXml = ElementTree.fromstring(pwdResponse)
        pwd = pwdXml.find("Password").text.strip()

        return queryEngine(self.getAddress(), self.getPort(), type, pwd, msgBody)
开发者ID:princeirmal,项目名称:nuodb-python,代码行数:11,代码来源:entity.py

示例4: query

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import authorize [as 别名]
    def query(self, query_type, msg_body=None):
        session = Session(self.peer.connect_str, service="Manager")
        session.authorize(self.peer.domain.user, self.peer.domain.password)
        pwd_response = session.doRequest(attributes={"Type": "GetDatabaseCredentials", "Database": self.database.name})

        pwd_xml = ElementTree.fromstring(pwd_response)
        pwd = pwd_xml.find("Password").text.strip()

        return queryEngine(self.address, self.port, query_type, pwd, msg_body)
开发者ID:jgetto,项目名称:nuodb-python,代码行数:11,代码来源:entity.py

示例5: doDatabaseAction

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import authorize [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

示例6: monitorEngine

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import authorize [as 别名]
def monitorEngine(address, port, dbPassword, listener=None):
    if not listener:
        listener = _StandardOutListener()

    s = Session(address, port=port, service="Monitor")
    s.authorize("Cloud", dbPassword)

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

    s.doConnect()

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

示例7: monitorDomainStats

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import authorize [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

示例8: getArchiveHistory

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import authorize [as 别名]
def getArchiveHistory(agent, user, password, archive, options=None):
    s = Session(agent, service="ProcessStart")
    s.authorize(user, password)

    option = _OPTION_VALUE_STR % ("--archive", archive)
    opts = [ ElementTree.fromstring(option) ]

    if options:
        for (k,v) in options:
            if v:
                option = _OPTION_VALUE_STR % (k, v)
            else:
                option = _OPTION_FLAG_STR % k
            opts.append(ElementTree.fromstring(option))

    return s.doRequest(attributes={"Process" : "archiveHistory"}, children=opts)
开发者ID:DukeNuoDB,项目名称:nuodb-python,代码行数:18,代码来源:util.py

示例9: startProcess

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import authorize [as 别名]
def startProcess(agent, user, password, db_name, options=None):
    s = Session(agent, service="ProcessStart")
    s.authorize(user, password)

    if not options:
        options = []

    options.append(("--database", db_name))

    opts = []
    for (k,v) in options:
        if v:
            optStr = _OPTION_VALUE_STR % (k, v)
        else:
            optStr = _OPTION_FLAG_STR % k
        opts.append(ElementTree.fromstring(optStr))

    return s.doRequest(attributes={"Process" : "server"}, children=opts)
开发者ID:DukeNuoDB,项目名称:nuodb-python,代码行数:20,代码来源:util.py

示例10: queryEngine

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import authorize [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

示例11: find_peer

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import authorize [as 别名]
    def find_peer(self, address, port=None):
        """
        Find a peer by address
        @type: address str
        @type: port int or str
        @rtype: Peer
        """
        if port is None:
            if ":" in address:
                address, port = address.split(":", 2)
            else:
                port = self.__entry_peer.port
        else:
            if ":" in address:
                address, _ = address.split(":", 2)

        ip = socket.gethostbyname(address)
        inet_sock_addr = ":".join([ip, str(port)])
        try:
            return self.__peers_by_addr[inet_sock_addr]
        except:
            pass

        session = Session(address, port=port, service="Identity")
        session.authorize(self.__user, self.__password)
        response = session.doRequest()
        try:
            root = ElementTree.fromstring(response)
            if self.__domain_name != root.get("Domain"):
                return None
            peer = self.get_peer(root.get("AgentId"))
            if peer:
                self.__peers_by_addr[peer._get_normalized_addr()] = peer
            return peer
        except:
            return None
开发者ID:jgetto,项目名称:nuodb-python,代码行数:38,代码来源:entity.py

示例12: Domain

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import authorize [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

示例13: getState

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import authorize [as 别名]
def getState(broker, user, password):
    s = Session(broker, service="State")
    s.authorize(user, password)
    
    return s.doRequest()
开发者ID:DukeNuoDB,项目名称:nuodb-python,代码行数:7,代码来源:util.py

示例14: setLicense

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import authorize [as 别名]
def setLicense(broker, user, password, licenseText):
    s = Session(broker, service="License")
    s.authorize(user, password)

    s.doRequest(attributes={ "Action" : "ApplyLicense" }, text=licenseText)
开发者ID:DukeNuoDB,项目名称:nuodb-python,代码行数:7,代码来源:util.py

示例15: getLicense

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import authorize [as 别名]
def getLicense(broker, user, password):
    s = Session(broker, service="License")
    s.authorize(user, password)

    return s.doRequest(attributes={ "Action" : "GetCurrentLicense" })
开发者ID:DukeNuoDB,项目名称:nuodb-python,代码行数:7,代码来源:util.py


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