本文整理汇总了Python中dulwich.protocol.Protocol.read_cmd方法的典型用法代码示例。如果您正苦于以下问题:Python Protocol.read_cmd方法的具体用法?Python Protocol.read_cmd怎么用?Python Protocol.read_cmd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dulwich.protocol.Protocol
的用法示例。
在下文中一共展示了Protocol.read_cmd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from dulwich.protocol import Protocol [as 别名]
# 或者: from dulwich.protocol.Protocol import read_cmd [as 别名]
def handle(self):
proto = Protocol(self.rfile.read, self.wfile.write)
command, args = proto.read_cmd()
# switch case to handle the specific git command
if command == 'git-upload-pack':
cls = UploadPackHandler
elif command == 'git-receive-pack':
cls = ReceivePackHandler
else:
return
h = cls(self.server.backend, self.rfile.read, self.wfile.write)
h.handle()
示例2: ProtocolTests
# 需要导入模块: from dulwich.protocol import Protocol [as 别名]
# 或者: from dulwich.protocol.Protocol import read_cmd [as 别名]
class ProtocolTests(TestCase):
def setUp(self):
self.rout = StringIO()
self.rin = StringIO()
self.proto = Protocol(self.rin.read, self.rout.write)
def test_write_pkt_line_none(self):
self.proto.write_pkt_line(None)
self.assertEquals(self.rout.getvalue(), "0000")
def test_write_pkt_line(self):
self.proto.write_pkt_line("bla")
self.assertEquals(self.rout.getvalue(), "0007bla")
def test_read_pkt_line(self):
self.rin.write("0008cmd ")
self.rin.seek(0)
self.assertEquals("cmd ", self.proto.read_pkt_line())
def test_read_pkt_seq(self):
self.rin.write("0008cmd 0005l0000")
self.rin.seek(0)
self.assertEquals(["cmd ", "l"], list(self.proto.read_pkt_seq()))
def test_read_pkt_line_none(self):
self.rin.write("0000")
self.rin.seek(0)
self.assertEquals(None, self.proto.read_pkt_line())
def test_write_sideband(self):
self.proto.write_sideband(3, "bloe")
self.assertEquals(self.rout.getvalue(), "0009\x03bloe")
def test_send_cmd(self):
self.proto.send_cmd("fetch", "a", "b")
self.assertEquals(self.rout.getvalue(), "000efetch a\x00b\x00")
def test_read_cmd(self):
self.rin.write("0012cmd arg1\x00arg2\x00")
self.rin.seek(0)
self.assertEquals(("cmd", ["arg1", "arg2"]), self.proto.read_cmd())
def test_read_cmd_noend0(self):
self.rin.write("0011cmd arg1\x00arg2")
self.rin.seek(0)
self.assertRaises(AssertionError, self.proto.read_cmd)