本文整理汇总了Python中Packet.getCommand方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.getCommand方法的具体用法?Python Packet.getCommand怎么用?Python Packet.getCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.getCommand方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: import Packet [as 别名]
# 或者: from Packet import getCommand [as 别名]
def handle(self):
msg = self.recv_with_size()
print msg, type(msg)
p = Packet()
p.DecodePacket(msg)
cmd = p.getCommand()
if cmd == "put":
self.handle_put(p)
elif cmd == "get":
self.handle_get(p)
示例2: handle
# 需要导入模块: import Packet [as 别名]
# 或者: from Packet import getCommand [as 别名]
def handle(self):
msg = self.request.recv(1024) #From copyclient
print msg, type(msg)
p = Packet()
p.DecodePacket(msg)
cmd = p.getCommand()
if cmd == "put": #Putting data
self.handle_put(p)
elif cmd == "get": #Getting data
self.handle_get(p)
示例3: handle
# 需要导入模块: import Packet [as 别名]
# 或者: from Packet import getCommand [as 别名]
def handle(self):
# Receive a msg from the copy client
msg = self.request.recv(1024)
# Define a packet object and decode it
p = Packet()
p.DecodePacket(msg)
# Copy client asking for data node to put data
cmd = p.getCommand()
if cmd == "put":
self.handle_put(p)
# Copy client asking for data node to get data
elif cmd == "get":
self.handle_get(p)
示例4: handle
# 需要导入模块: import Packet [as 别名]
# 或者: from Packet import getCommand [as 别名]
def handle(self):
# Establish a connection with the local database
db = mds_db("dfs.db")
db.Connect()
# Define a packet object to decode packet messages
p = Packet()
# Receive a msg from the list, data-node, or copy clients
msg = self.request.recv(1024)
print msg, type(msg)
# Decode the packet received
p.DecodePacket(msg)
# Extract the command part of the received packet
cmd = p.getCommand()
# Invoke the proper action
if cmd == "reg":
# Registration client
self.handle_reg(db, p)
elif cmd == "list":
pass
# Client asking for a list of files
# Fill code
elif cmd == "put":
pass
# Client asking for servers to put data
# Fill code
elif cmd == "get":
pass
# Client asking for servers to get data
# Fill code
elif cmd == "dblks":
pass
# Client sending data blocks for file
# Fill code
db.Close()