示例#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, 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,
                              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
示例#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):
     #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)
     setup_fastencoder_nocompression(protocol)
     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=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)
     setup_fastencoder_nocompression(protocol)
     protocol.large_packets = self.large_packets
     return protocol
示例#6
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
示例#7
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
示例#8
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
示例#9
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