# Path: afl_utils/AflPrettyPrint.py
# class clr:
#     # taken from AFL's debug.h
#     BLK = "\x1b[0;30m"
#     RED = "\x1b[0;31m"
#     GRN = "\x1b[0;32m"
#     BRN = "\x1b[0;33m"
#     BLU = "\x1b[0;34m"
#     MGN = "\x1b[0;35m"
#     CYA = "\x1b[0;36m"
#     NOR = "\x1b[0;37m"
#     GRA = "\x1b[1;30m"
#     LRD = "\x1b[1;31m"
#     LGN = "\x1b[1;32m"
#     YEL = "\x1b[1;33m"
#     LBL = "\x1b[1;34m"
#     PIN = "\x1b[1;35m"
#     LCY = "\x1b[1;36m"
#     BRI = "\x1b[1;37m"
#     RST = "\x1b[0m"
# 
# def print_ok(msg_str):
#     print("{0}[*] {1}{2}".format(clr.LGN, clr.RST, msg_str))
# 
# def print_warn(msg_str):
#     print("{0}[!] {1}{2}".format(clr.YEL, clr.RST, msg_str))
# 
# def print_err(msg_str):
#     print("{0}[!] {1}{2}".format(clr.LRD, clr.RST, msg_str))
# 
# Path: db_connectors/con_sqlite.py
# class sqliteConnector:
#     def __init__(self, database_path, verbose=True):
#     def init_database(self, table, table_spec):
#     def dataset_exists(self, table, dataset, compare_fields):
#     def insert_dataset(self, table, dataset):
#     def commit_close(self):


import argparse
    import simplejson as json
    import json
import os
import sys
import socket
import twitter
import afl_utils
from urllib.error import URLError
from afl_utils.AflPrettyPrint import clr, print_ok, print_warn, print_err
from db_connectors import con_sqlite
            except (twitter.TwitterHTTPError, URLError):
                print_warn("Problem connecting to Twitter! Tweet not sent!")
            except Exception as e:
                print_err("Sending tweet failed (Reason: " + clr.GRA + "%s" % e.__cause__ + clr.RST + ")")


def main(argv):
    parser = argparse.ArgumentParser(description="Post selected contents of fuzzer_stats to Twitter.",
                                     usage="afl-stats [-h] [-c config] [-d database] [-t]\n")

    parser.add_argument("-c", "--config", dest="config_file",
                        help="afl-stats config file (Default: afl-stats.conf)!", default="afl-stats.conf")
    parser.add_argument("-d", "--database", dest="database_file",
                        help="Dump stats history into database.")
    parser.add_argument('-t', '--twitter', dest='twitter', action='store_const', const=True,
                        help='Post stats to twitter (Default: off).', default=False)
    parser.add_argument('-q', '--quiet', dest='quiet', action='store_const', const=True,
                        help='Suppress any output (Default: off).', default=False)

    args = parser.parse_args(argv[1:])

    if not args.quiet:
        show_info()

    if args.database_file:
        db_file = os.path.abspath(os.path.expanduser(args.database_file))
    else:
        db_file = None

    if db_file:

# Path: afl_utils/AflPrettyPrint.py
# class clr:
#     # taken from AFL's debug.h
#     BLK = "\x1b[0;30m"
#     RED = "\x1b[0;31m"
#     GRN = "\x1b[0;32m"
#     BRN = "\x1b[0;33m"
#     BLU = "\x1b[0;34m"
#     MGN = "\x1b[0;35m"
#     CYA = "\x1b[0;36m"
#     NOR = "\x1b[0;37m"
#     GRA = "\x1b[1;30m"
#     LRD = "\x1b[1;31m"
#     LGN = "\x1b[1;32m"
#     YEL = "\x1b[1;33m"
#     LBL = "\x1b[1;34m"
#     PIN = "\x1b[1;35m"
#     LCY = "\x1b[1;36m"
#     BRI = "\x1b[1;37m"
#     RST = "\x1b[0m"
# 
# def print_ok(msg_str):
#     print("{0}[*] {1}{2}".format(clr.LGN, clr.RST, msg_str))
# 
# def print_warn(msg_str):
#     print("{0}[!] {1}{2}".format(clr.YEL, clr.RST, msg_str))
# 
# def print_err(msg_str):
#     print("{0}[!] {1}{2}".format(clr.LRD, clr.RST, msg_str))
# 
# Path: db_connectors/con_sqlite.py
# class sqliteConnector:
#     def __init__(self, database_path, verbose=True):
#     def init_database(self, table, table_spec):
#     def dataset_exists(self, table, dataset, compare_fields):
#     def insert_dataset(self, table, dataset):
#     def commit_close(self):


# Path: afl_utils/afl_stats.py
import argparse
    import simplejson as json
    import json
import os
import sys
import socket
import twitter
import afl_utils
from urllib.error import URLError
from afl_utils.AflPrettyPrint import clr, print_ok, print_warn, print_err
from db_connectors import con_sqlite

            except (twitter.TwitterHTTPError, URLError):
                print_warn("Problem connecting to Twitter! Tweet not sent!")
            except Exception as e:
                print_err("Sending tweet failed (Reason: " + clr.GRA + "%s" % e.__cause__ + clr.RST + ")")


def main(argv):
    parser = argparse.ArgumentParser(description="Post selected contents of fuzzer_stats to Twitter.",
                                     usage="afl-stats [-h] [-c config] [-d database] [-t]\n")

    parser.add_argument("-c", "--config", dest="config_file",
                        help="afl-stats config file (Default: afl-stats.conf)!", default="afl-stats.conf")
    parser.add_argument("-d", "--database", dest="database_file",
                        help="Dump stats history into database.")
    parser.add_argument('-t', '--twitter', dest='twitter', action='store_const', const=True,
                        help='Post stats to twitter (Default: off).', default=False)
    parser.add_argument('-q', '--quiet', dest='quiet', action='store_const', const=True,
                        help='Suppress any output (Default: off).', default=False)

    args = parser.parse_args(argv[1:])

    if not args.quiet:
        show_info()

    if args.database_file:
        db_file = os.path.abspath(os.path.expanduser(args.database_file))
    else:
        db_file = None

    if db_file:

        lite_db = con_sqlite.sqliteConnector(db_file, verbose=False)