Exemplo n.º 1
0
    def test_read_defaults(self):
        # Check whether there's already a server on default port before we
        # try to start one up.
        try:
            rs = redis.Redis()
            response = rs.client_list()
            server_proc = None
        except redis.ConnectionError:
            # No server, create one of our own
            cmd_line = ['redis-server']
            server_proc = subprocess.Popen(cmd_line, stdout=subprocess.DEVNULL)
            time.sleep(0.25)

        writer = RedisWriter('%s' % channel)
        reader = RedisReader('%s' % channel)

        for i in range(len(SAMPLE_DATA)):
            writer.write(SAMPLE_DATA[i])
            self.assertEqual(SAMPLE_DATA[i], reader.read())

        if server_proc:
            server_proc.kill()
Exemplo n.º 2
0
      if new_args.udp:
        eol = all_args.network_eol
        for addr_str in new_args.udp.split(','):
          addr = addr_str.split(':')
          source = ''
          port = int(addr[-1])  # port is last arg
          if len(addr) > 1:
            source = addr[-2] # source (multi/broadcast) is prev arg
          if len(addr) > 2:
            parser.error('Format error for --udp argument. Format '
                         'should be [source:]port')
          readers.append(UDPReader(port=port, source=source, eol=eol))

      if new_args.redis:
        for channel in new_args.redis.split(','):
          readers.append(RedisReader(channel=channel))

      if new_args.logfile:
        for filebase in new_args.logfile.split(','):
          readers.append(LogfileReader(
            filebase=filebase, use_timestamps=all_args.logfile_use_timestamps,
            time_format=all_args.time_format,
            refresh_file_spec=all_args.refresh_file_spec))

      if new_args.cached_data_server:
        fields = new_args.cached_data_server
        server = None
        if fields.find('@') > 0:
          fields, server = fields.split('@')
        subscription = {'fields': {f:{'seconds':0} for f in fields.split(',')}}
        if server: