예제 #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)
     setup_fastencoder_nocompression(protocol)
     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 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
예제 #4
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)
     setup_fastencoder_nocompression(protocol)
     protocol.large_packets = self.large_packets
     return protocol