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


Python ServerRequest.prepareRequest方法代碼示例

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


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

示例1: addNodeAccepted

# 需要導入模塊: from cpc.network.server_request import ServerRequest [as 別名]
# 或者: from cpc.network.server_request.ServerRequest import prepareRequest [as 別名]
    def addNodeAccepted(self):
        conf = ServerConf()

        inf = open(conf.getCACertFile(), "r")
        key = inf.read()
        #only sending fqdn the requesting should already know the unqualified
        # hostname
        node = NodeConnectRequest(conf.getServerId(),
            conf.getClientSecurePort(),
            conf.getServerSecurePort(),
            key,
            conf.getFqdn(),
            None)
        cmdstring ='node-connection-accepted'
        fields = []
        input=Input('cmd',cmdstring)


        input2=Input('connectRequest',
            json.dumps(node,default=json_serializer.toJson,indent=4))


        fields.append(input)
        fields.append(input2)
        fields.append(Input('version', "1"))

        # this goes over  client secure port , and we don't want the server to use
        # cookies 
        response= self.postRequest(ServerRequest.prepareRequest(fields),
            require_certificate_authentication=False,
            disable_cookies=True)
        return response
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:34,代碼來源:untrusted_server_message.py

示例2: commandFinishedForwardedRequest

# 需要導入模塊: from cpc.network.server_request import ServerRequest [as 別名]
# 或者: from cpc.network.server_request.ServerRequest import prepareRequest [as 別名]
    def commandFinishedForwardedRequest(self, cmdID, workerServer,
                                        projectServer, returncode,
                                        cputime, haveData):
        """A server-to-sever request doing command-finished. Used in
            forwarding non-local command-finished requests."""
        cmdstring='command-finished-forward'
        fields = []
        input = Input('cmd', cmdstring)
        fields.append(input)
        fields.append(Input('cmd_id', cmdID))
        fields.append(Input('version', "1"))
        fields.append(Input('worker_server', workerServer))
        fields.append(Input('project_server', projectServer))
        if returncode is not None:
            fields.append(Input('return_code', returncode))
        fields.append(Input('used_cpu_time', cputime))
        if haveData:
            fields.append(Input('run_data', 1))

        #the files are not sent in this message, instead they are pulled 
        # from the project server upon receiving this message (for now)
        files = []
        headers = dict()
        #headers['end-node'] = self.host
        #headers['end-node-port'] = self.port
        #self.connect()
        #log.debug("forwarding command finished to %s"%self.endNode)
        response= self.putRequest(ServerRequest.prepareRequest(fields, files,
            headers))
        return response
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:32,代碼來源:server_message.py

示例3: __persistConnection

# 需要導入模塊: from cpc.network.server_request import ServerRequest [as 別名]
# 或者: from cpc.network.server_request.ServerRequest import prepareRequest [as 別名]
    def __persistConnection(self,direction,headers = dict()):
        headers['persistent-connection'] = direction
        #message body is actually irrellevant and is not read on the other
        # side.
        #we just need to conform to the http protocol
        fields = []
        fields.append(Input('cmd', "persist-connection"))

        #sending along the connection parameters for this server
        conf = ServerConf()
        connectionParams = dict()
        connectionParams['serverId'] = conf.getServerId()
        connectionParams['hostname'] = conf.getHostName()
        connectionParams['fqdn'] = conf.getFqdn()
        connectionParams['client_secure_port'] = conf\
        .getClientSecurePort()
        connectionParams['server_secure_port'] = conf\
        .getServerSecurePort()


        input2 = Input('connectionParams',
            json.dumps(connectionParams,default = json_serializer.toJson,
                indent=4))  # a json structure that needs to be dumped
        fields.append(input2)


        response= self.putRequest(ServerRequest.prepareRequest(fields, [],
            headers))

        return response
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:32,代碼來源:direct_message.py

示例4: projectGetDefaultRequest

# 需要導入模塊: from cpc.network.server_request import ServerRequest [as 別名]
# 或者: from cpc.network.server_request.ServerRequest import prepareRequest [as 別名]
 def projectGetDefaultRequest(self):
     """Get the default project project name"""
     cmdstring="project-get-default"
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     response= self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:10,代碼來源:message.py

示例5: projectRollbackRequest

# 需要導入模塊: from cpc.network.server_request import ServerRequest [as 別名]
# 或者: from cpc.network.server_request.ServerRequest import prepareRequest [as 別名]
 def projectRollbackRequest(self, project):
     """Cancel a series of previously scheduled set&connect requests."""
     cmdstring="project-rollback"
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     response= self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:10,代碼來源:message.py

示例6: listModules

# 需要導入模塊: from cpc.network.server_request import ServerRequest [as 別名]
# 或者: from cpc.network.server_request.ServerRequest import prepareRequest [as 別名]
 def listModules(self):
     cmdString = "list-modules"
     fields  = []
     input = Input('cmd',cmdString)
     fields.append(input)
     fields.append(Input('version', "1"))
     msg = ServerRequest.prepareRequest(fields,[])
     return self.postRequest(msg)
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:10,代碼來源:message.py

示例7: projectsRequest

# 需要導入模塊: from cpc.network.server_request import ServerRequest [as 別名]
# 或者: from cpc.network.server_request.ServerRequest import prepareRequest [as 別名]
 def projectsRequest(self):
     """List all projects"""
     cmdstring="projects"
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     response= self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:10,代碼來源:message.py

示例8: projectCommitRequest

# 需要導入模塊: from cpc.network.server_request import ServerRequest [as 別名]
# 或者: from cpc.network.server_request.ServerRequest import prepareRequest [as 別名]
 def projectCommitRequest(self, project):
     """Commit a series of previously scheduled set&connect requests, 
        atomically."""
     cmdstring="project-commit"
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     response= self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:11,代碼來源:message.py

示例9: serverInfo

# 需要導入模塊: from cpc.network.server_request import ServerRequest [as 別名]
# 或者: from cpc.network.server_request.ServerRequest import prepareRequest [as 別名]
 def serverInfo(self):
     cmdstring='server-info'
     fields = []
     input = Input('cmd', cmdstring)
     fields.append(input)
     fields.append(Input('version', "1"))
     msg = ServerRequest.prepareRequest(fields,[])
     response= self.postRequest(msg)
     return response
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:11,代碼來源:message.py

示例10: stopRequest

# 需要導入模塊: from cpc.network.server_request import ServerRequest [as 別名]
# 或者: from cpc.network.server_request.ServerRequest import prepareRequest [as 別名]
 def stopRequest(self): 
     cmdstring="stop"
     fields = []
     input = Input('cmd', cmdstring)   
     fields.append(input)
     fields.append(Input('version', "1"))
     response= self.postRequest(ServerRequest.prepareRequest(fields, []))
     #response= self.putRequest(ServerRequest.prepareRequest(fields, []))
     return response
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:11,代碼來源:message.py

示例11: projectStartRequest

# 需要導入模塊: from cpc.network.server_request import ServerRequest [as 別名]
# 或者: from cpc.network.server_request.ServerRequest import prepareRequest [as 別名]
 def projectStartRequest(self, name):
     """Start a new empty project """
     cmdstring="project-start"
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     fields.append(Input('name',name))
     response= self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:11,代碼來源:message.py

示例12: saveStateRequest

# 需要導入模塊: from cpc.network.server_request import ServerRequest [as 別名]
# 或者: from cpc.network.server_request.ServerRequest import prepareRequest [as 別名]
 def saveStateRequest(self):
     """Tell the server to save its state now."""
     cmdstring="save-state"
     fields = []
     input = Input('cmd', cmdstring)   
     fields.append(input)
     fields.append(Input('version', "1"))
     response= self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:11,代碼來源:message.py

示例13: readConfRequest

# 需要導入模塊: from cpc.network.server_request import ServerRequest [as 別名]
# 或者: from cpc.network.server_request.ServerRequest import prepareRequest [as 別名]
 def readConfRequest(self):
     """Tell the server to re-read its configuration."""
     cmdstring="readconf"
     fields = []
     input = Input('cmd', cmdstring)   
     fields.append(input)
     fields.append(Input('version', "1"))
     response= self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:11,代碼來源:message.py

示例14: deleteUser

# 需要導入模塊: from cpc.network.server_request import ServerRequest [as 別名]
# 或者: from cpc.network.server_request.ServerRequest import prepareRequest [as 別名]
 def deleteUser(self, user):
     cmdstring="delete-user"
     fields = []
     input = Input('cmd', cmdstring)
     fields.append(input)
     fields.append(Input('user', user))
     msg = ServerRequest.prepareRequest(fields,[])
     response = self.postRequest(msg)
     return response
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:11,代碼來源:message.py

示例15: revokeNode

# 需要導入模塊: from cpc.network.server_request import ServerRequest [as 別名]
# 或者: from cpc.network.server_request.ServerRequest import prepareRequest [as 別名]
 def revokeNode(self,serverId):
     cmdString = "revoke-node"
     fields  = []
     input = Input('cmd',cmdString)
     fields.append(input)
     fields.append(Input('version', "1"))
     fields.append(Input('serverId',serverId))
     msg = ServerRequest.prepareRequest(fields,[])
     return self.postRequest(msg)
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:11,代碼來源:message.py


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