本文整理汇总了Python中xpra.net.protocol.Protocol.enable_encoder方法的典型用法代码示例。如果您正苦于以下问题:Python Protocol.enable_encoder方法的具体用法?Python Protocol.enable_encoder怎么用?Python Protocol.enable_encoder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xpra.net.protocol.Protocol
的用法示例。
在下文中一共展示了Protocol.enable_encoder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_protocol
# 需要导入模块: from xpra.net.protocol import Protocol [as 别名]
# 或者: from xpra.net.protocol.Protocol import enable_encoder [as 别名]
def make_protocol(self):
#figure out where we read from and write to:
if self.input_filename=="-":
#disable stdin buffering:
self._input = os.fdopen(sys.stdin.fileno(), 'rb', 0)
setbinarymode(self._input.fileno())
else:
self._input = open(self.input_filename, 'rb')
if self.output_filename=="-":
#disable stdout buffering:
self._output = os.fdopen(sys.stdout.fileno(), 'wb', 0)
setbinarymode(self._output.fileno())
else:
self._output = open(self.output_filename, 'wb')
#stdin and stdout wrapper:
conn = TwoFileConnection(self._output, self._input, abort_test=None, target=self.name, info=self.name, close_cb=self.net_stop)
conn.timeout = 0
protocol = Protocol(gobject, conn, self.process_packet, get_packet_cb=self.get_packet)
try:
protocol.enable_encoder("rencode")
except Exception as e:
log.warn("failed to enable rencode: %s", e)
protocol.enable_encoder("bencode")
protocol.enable_compressor("none")
protocol.large_packets = self.large_packets
return protocol
示例2: loopback_protocol
# 需要导入模块: from xpra.net.protocol import Protocol [as 别名]
# 或者: from xpra.net.protocol.Protocol import enable_encoder [as 别名]
def loopback_protocol(process_packet_cb, get_packet_cb):
conn = loopback_connection("fake", "fake")
protocol = Protocol(gobject, conn, process_packet_cb, get_packet_cb=get_packet_cb)
protocol.enable_encoder("rencode")
protocol.enable_compressor("none")
return protocol