コード例 #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()
コード例 #2
0
ファイル: listen.py プロジェクト: anshika-agarwal/openrvdas
          dest = ''
          interface = ''
          port = int(addr[-1])  # port is last arg
          if len(addr) > 1:
            dest = addr[-2] # destination (multi/broadcast) is prev arg
          if len(addr) > 2:
            interface = addr[-3] # interface is first arg
          if len(addr) > 3:
            parser.error('Format error for --write_udp argument. Format '
                         'should be [[interface:]destination:]port')
          writers.append(UDPWriter(port=port, destination=dest,
                                   interface=interface, eol=eol))

      if new_args.write_redis:
        for channel in new_args.write_redis.split(','):
          writers.append(RedisWriter(channel=channel))

      if new_args.write_record_screen:
        writers.append(RecordScreenWriter())

      if new_args.write_database:
        password = all_args.database_password
        # Parse out values for user@host:database. We count on
        # --database_password having been specified somewhere.
        (user, host_db) = new_args.write_database.split('@')
        (host, database) = host_db.split(':')
        writers.append(DatabaseWriter(database=database, host=host,
                                      user=user, password=password))

      if new_args.write_cached_data_server:
        data_server = new_args.write_cached_data_server