コード例 #1
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,
                              socktype=self.name,
                              close_cb=self.net_stop)
     conn.timeout = 0
     protocol = Protocol(self,
                         conn,
                         self.process_packet,
                         get_packet_cb=self.get_packet)
     if LOCAL_ALIASES:
         protocol.send_aliases = LOCAL_SEND_ALIASES
         protocol.receive_aliases = LOCAL_RECEIVE_ALIASES
     setup_fastencoder_nocompression(protocol)
     protocol.large_packets = self.large_packets
     return protocol
コード例 #2
0
 def make_protocol(self):
     #make a connection using the process stdin / stdout
     conn = TwoFileConnection(self.process.stdin,
                              self.process.stdout,
                              abort_test=self.abort_test,
                              target=self.description,
                              socktype=self.description,
                              close_cb=self.subprocess_exit)
     conn.timeout = 0
     protocol = Protocol(self,
                         conn,
                         self.process_packet,
                         get_packet_cb=self.get_packet)
     if LOCAL_ALIASES:
         protocol.send_aliases = LOCAL_SEND_ALIASES
         protocol.receive_aliases = LOCAL_RECEIVE_ALIASES
     setup_fastencoder_nocompression(protocol)
     protocol.large_packets = self.large_packets
     return protocol