# Path: dizzy/tools.py
# def check_root(text):
#     if hasattr(os, 'geteuid'):
#         if os.geteuid() != 0:
#             print_dizzy("You must be root to " + text + ".")
#             exit(1)
#     else:
#         if ctypes.windll.shell32.IsUserAnAdmin() != 1:
#             print_dizzy("You must be Admin to " + text + ".")
#             exit(1)
# 
# Path: dizzy/log.py
# def print_dizzy(value, level=NORMAL):
#     if print_level >= level:
#         with print_lock:
#             print(print_colors[level], end='')
#             print(value)
#             if isinstance(value, Exception):
#                 ex_type, ex, tb = exc_info()
#                 print_tb(tb)
#             print(ENDC, end='')
# 
# VERBOSE_1 = 3
# 
# VERBOSE_2 = 4


from threading import Thread
from time import sleep
from dizzy.tools import check_root
from dizzy.log import print_dizzy, VERBOSE_1, VERBOSE_2
            import pcapy
        Thread.__init__(self)
        try:
            self.pcap = pcapy
        except:
            print_dizzy("No usable pcap library found. Be sure you have pcapy installed!")
            print_dizzy("Pcap recording disabled!")
            self.pcap = None
            return
        self.interface = config.get("interface", "any")
        check_root("use the PCAP feature")
        print_dizzy("pcap/init: listening on interface '%s'." % self.interface, VERBOSE_1)
        if not self.interface is "any":
            if not self.interface in self.pcap.findalldevs():
                print_dizzy("Device '%s' not found, recording on _all_ interfaces.")
                self.interface = "any"
        self.filter = config.get("filter", "")
        if not self.filter is "":
            print_dizzy("pcap/init: using bpf '%s'." % self.filter, VERBOSE_1)
        self.snaplen = config.getint("snaplen", 8192)
        self.promisc = config.getboolean("promisc", True)
        self.to_ms = config.getint("to_ms", 10)
        self.cooldown = config.getint("cooldown", 0)
        self.filename = filename
        self.is_open = False

    def run(self):
        if self.pcap is None:
            return
        self.run = True
        self.pcap_object = self.pcap.open_live(self.interface, self.snaplen, self.promisc, self.to_ms)

# Path: dizzy/tools.py
# def check_root(text):
#     if hasattr(os, 'geteuid'):
#         if os.geteuid() != 0:
#             print_dizzy("You must be root to " + text + ".")
#             exit(1)
#     else:
#         if ctypes.windll.shell32.IsUserAnAdmin() != 1:
#             print_dizzy("You must be Admin to " + text + ".")
#             exit(1)
# 
# Path: dizzy/log.py
# def print_dizzy(value, level=NORMAL):
#     if print_level >= level:
#         with print_lock:
#             print(print_colors[level], end='')
#             print(value)
#             if isinstance(value, Exception):
#                 ex_type, ex, tb = exc_info()
#                 print_tb(tb)
#             print(ENDC, end='')
# 
# VERBOSE_1 = 3
# 
# VERBOSE_2 = 4


# Path: dizzy/pcap.py
from threading import Thread
from time import sleep
from dizzy.tools import check_root
from dizzy.log import print_dizzy, VERBOSE_1, VERBOSE_2
            import pcapy

        Thread.__init__(self)
        try:
            self.pcap = pcapy
        except:
            print_dizzy("No usable pcap library found. Be sure you have pcapy installed!")
            print_dizzy("Pcap recording disabled!")
            self.pcap = None
            return
        self.interface = config.get("interface", "any")
        check_root("use the PCAP feature")
        print_dizzy("pcap/init: listening on interface '%s'." % self.interface, VERBOSE_1)
        if not self.interface is "any":
            if not self.interface in self.pcap.findalldevs():
                print_dizzy("Device '%s' not found, recording on _all_ interfaces.")
                self.interface = "any"
        self.filter = config.get("filter", "")
        if not self.filter is "":
            print_dizzy("pcap/init: using bpf '%s'." % self.filter, VERBOSE_1)
        self.snaplen = config.getint("snaplen", 8192)
        self.promisc = config.getboolean("promisc", True)
        self.to_ms = config.getint("to_ms", 10)
        self.cooldown = config.getint("cooldown", 0)
        self.filename = filename
        self.is_open = False

    def run(self):
        if self.pcap is None:
            return
        self.run = True
        self.pcap_object = self.pcap.open_live(self.interface, self.snaplen, self.promisc, self.to_ms)

        print_dizzy("pcap/run: pcap object opened.", VERBOSE_2)