コード例 #1
0
ファイル: subprocess_wrapper.py プロジェクト: svn2github/Xpra
 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
0
 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
コード例 #3
0
def loopback_protocol(process_packet_cb, get_packet_cb):
    conn = loopback_connection("fake", "fake")
    protocol = Protocol(GLib,
                        conn,
                        process_packet_cb,
                        get_packet_cb=get_packet_cb)
    protocol.enable_encoder("rencode")
    protocol.enable_compressor("none")
    return protocol
コード例 #4
0
ファイル: subprocess_wrapper.py プロジェクト: svn2github/Xpra
 def make_protocol(self):
     #make a connection using the process stdin / stdout
     conn = TwoFileConnection(self.process.stdin, self.process.stdout, abort_test=None, target=self.description, info=self.description, close_cb=self.subprocess_exit)
     conn.timeout = 0
     protocol = Protocol(gobject, conn, self.process_packet, get_packet_cb=self.get_packet)
     #we assume the other end has the same encoders (which is reasonable):
     #TODO: fallback to bencoder
     try:
         protocol.enable_encoder("rencode")
     except Exception as e:
         log.warn("failed to enable rencode: %s", e)
         protocol.enable_encoder("bencode")
     #we assume this is local, so no compression:
     protocol.enable_compressor("none")
     protocol.large_packets = self.large_packets
     return protocol
コード例 #5
0
 def make_protocol(self):
     #make a connection using the process stdin / stdout
     conn = TwoFileConnection(self.process.stdin,
                              self.process.stdout,
                              abort_test=None,
                              target=self.description,
                              info=self.description,
                              close_cb=self.subprocess_exit)
     conn.timeout = 0
     protocol = Protocol(gobject,
                         conn,
                         self.process_packet,
                         get_packet_cb=self.get_packet)
     #we assume the other end has the same encoders (which is reasonable):
     #TODO: fallback to bencoder
     try:
         protocol.enable_encoder("rencode")
     except Exception as e:
         log.warn("failed to enable rencode: %s", e)
         protocol.enable_encoder("bencode")
     #we assume this is local, so no compression:
     protocol.enable_compressor("none")
     protocol.large_packets = self.large_packets
     return protocol
コード例 #6
0
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