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


Python Transport.process方法代碼示例

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


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

示例1: Mailgun

# 需要導入模塊: from transport import Transport [as 別名]
# 或者: from transport.Transport import process [as 別名]
class Mailgun(object):

    def __init__(self, domain, api_key):
        self._client = Transport(domain, api_key)

    def get(self, action, *args, **kwargs):
        """
        HTTP GET method
        """
        return self._client.process(action, "get", *args, **kwargs)

    def post(self, action, *args, **kwargs):
        """
        HTTP POST method
        """
        return self._client.process(action, "post", *args, **kwargs)

    def delete(self, action, *args, **kwargs):
        """
        HTTP DELETE method
        """
        return self._client.process(action, "delete", *args, **kwargs)

    def put(self, action, *args, **kwargs):
        """
        HTTP PUT method
        """
        return self._client.process(action, "put", *args, **kwargs)
開發者ID:2014,項目名稱:pymailgun,代碼行數:30,代碼來源:mailgun.py

示例2: __init__

# 需要導入模塊: from transport import Transport [as 別名]
# 或者: from transport.Transport import process [as 別名]
class Client:
  def __init__(self, user):
    self.user = user
    self.ip = str(54) + '.' + str(random.randrange(0, 255)) + '.' + str(random.randrange(0, 255)) + '.' + str(random.randrange(0, 255))
    self.connections = []
    self.routerBuffer = []
    self.inbox = {}
    self.transportLayer = Transport(self)
    self.applicationLayer = Application(self)

  # Adds a link between this client and another
  def addConnection(self, client):
    if client == self:
      return
    if client.ip in self.connections:
      return
    self.connections.append(client.ip)

  # Sends a message (tells the application layer to make a packet)
  def sendMessage(self, source, destination, message , time):
    applicationPacket = self.applicationLayer.generatePacket(time, source, destination, message)
    tcpPackets = self.transportLayer.process(applicationPacket, time)

  def __repr__(self):
    return self.ip

  def __str__(self):
    return self.ip + ' - ' + str(self.connections) + " => Router Buffer: " + str(self.routerBuffer) + "  Inbox: " + str(self.inbox)
開發者ID:nburfield,項目名稱:CPE-400-Networking-Project,代碼行數:30,代碼來源:client.py


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