<commit_before>#!/usr/bin/env python3

import sys
import redis
import redis.exceptions

host = sys.argv[1]
host = host.strip('\r\n')
port = 6379
timeout = 5

try:
    db = redis.StrictRedis(host=host, port=port, socket_timeout=timeout)
    i = db.info()
    ver = i.get('redis_version')
    siz = db.dbsize()
   
    print('[+] {0}:{1} - {2}({3})'.format(host, port, ver, siz))

except redis.exceptions.ResponseError as e:
    print('[+] {0}:{1} - {2}'.format(host, port, e))

except redis.exceptions.ConnectionError:
    print('[-] {0}:{1} - Connection Error'.format(host, port))

except redis.exceptions.TimeoutError:
    print('[-] {0}:{1} - Timeout'.format(host, port))

except redis.exceptions.InvalidResponse:
    print('[-] {0}:{1} - Invalid Response'.format(host, port))<commit_msg>Make output easier to parse with cli tools.<commit_after>#!/usr/bin/env python3

import sys
import redis
import redis.exceptions

host = sys.argv[1]
host = host.strip('\r\n')
port = 6379
timeout = 5

try:
    db = redis.StrictRedis(host=host, port=port, socket_timeout=timeout)
    i = db.info()
    ver = i.get('redis_version')
    siz = db.dbsize()
   
    print('[+] {0}:{1}:{2}'.format(host, ver, siz))

except redis.exceptions.ResponseError as e:
    print('[+] {0}::{1}'.format(host, e))

except redis.exceptions.ConnectionError:
    print('[-] {0}::Connection Error'.format(host))

except redis.exceptions.TimeoutError:
    print('[-] {0}::Timeout'.format(host))

except redis.exceptions.InvalidResponse:
    print('[-] {0}::Invalid Response'.format(host))
{'fraction_non_alphanumeric': 0.18931101094655506, 'fraction_numerical': 0.022537025112685124, 'mean_word_length': 4.232323232323233, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3253313', 'n_tokens_mistral': 589, 'n_tokens_neox': 582, 'n_words': 120}