# Path: src/apex/buffers.py
# class NonrepeatingBuffer(object):
#     def __init__(self, base_tnc, base_name, base_port=None, echo_packets=True, buffer_size=10000, buffer_time=30):
#         self.packet_cache = cachetools.TTLCache(buffer_size, buffer_time)
#         self.lock = threading.Lock()
#         self.base_tnc = base_tnc
#         self.base_port = base_port
#         self.base_name = base_name
#         self.echo_packets = echo_packets
# 
#     @property
#     def port(self):
#         return self.base_port
# 
#     @property
#     def name(self):
#         return self.base_name
# 
#     def connect(self, *args, **kwargs):
#         self.base_tnc.connect(*args, **kwargs)
# 
#     def close(self, *args, **kwargs):
#         self.base_tnc.close(*args, **kwargs)
# 
#     def write(self, frame, *args, **kwargs):
#         with self.lock:
#             frame_hash = str(aprs_util.hash_frame(frame))
#             if frame_hash not in self.packet_cache:
#                 self.packet_cache[frame_hash] = frame
#                 if self.base_port:
#                     self.base_tnc.write(frame, self.base_port)
#                 else:
#                     self.base_tnc.write(frame)
# 
#                 if self.echo_packets:
#                     echo_colorized_frame(frame, self.base_name, False)
# 
#     def read(self, *args, **kwargs):
#         with self.lock:
#             frame = self.base_tnc.read(*args, **kwargs)
#             if not frame:
#                 return frame
#             frame_hash = str(aprs_util.hash_frame(frame))
#             if frame_hash not in self.packet_cache:
#                 self.packet_cache[frame_hash] = frame
#                 if self.echo_packets:
#                     echo_colorized_frame(frame, self.base_name, True)
#                 return frame
#             else:
#                 return None
# 
# Path: src/apex/util.py
# def echo_colorized_error(text):
#     click.echo(click.style('Error: ', fg='red', bold=True, blink=True) + click.style(text, bold=True))
# 
# Path: src/apex/util.py
# def echo_colorized_warning(text):
#     click.echo(click.style('Warning: ', fg='yellow') + click.style(text))


import os
import signal
import sys
import threading
import time
import click
import six
import apex.aprs
import apex.buffers
    import ConfigParser  # noqa: F401
    import configparser
from apex.kiss import constants as kissConstants
from apex.plugin_loader import get_plugins
from apex.plugin_loader import load_plugin
from .buffers import NonrepeatingBuffer
from .util import echo_colorized_error
from .util import echo_colorized_warning
        if config.has_option('IGATE', 'password'):
            aprsis_password = config.get('IGATE', 'password')
        else:
            aprsis_password = -1
        aprsis_server = config.get('IGATE', 'server')
        aprsis_server_port = config.get('IGATE', 'server_port')
        aprsis_base = apex.buffers.ReconnectingPacketBuffer(apex.aprs.IGate(aprsis_callsign, aprsis_password))
        aprsis = NonrepeatingBuffer(aprsis_base, 'IGATE')
        aprsis.connect(aprsis_server, int(aprsis_server_port))

    return True


@click.command(context_settings=dict(auto_envvar_prefix='APEX'))
@click.option('-c',
              '--configfile',
              type=click.Path(exists=True, file_okay=True, dir_okay=False, readable=True, resolve_path=True),
              help='Configuration file for APEX.')
@click.option('-v', '--verbose', is_flag=True, help='Enables verbose mode.')
def main(verbose, configfile):
    # load the configuration, if it fails, exit
    if not configure(configfile, verbose):
        return

    click.echo("Press ctrl + c at any time to exit")

    # start the plugins
    try:
        plugin_loaders = get_plugins()
        if not len(plugin_loaders):

# Path: src/apex/buffers.py
# class NonrepeatingBuffer(object):
#     def __init__(self, base_tnc, base_name, base_port=None, echo_packets=True, buffer_size=10000, buffer_time=30):
#         self.packet_cache = cachetools.TTLCache(buffer_size, buffer_time)
#         self.lock = threading.Lock()
#         self.base_tnc = base_tnc
#         self.base_port = base_port
#         self.base_name = base_name
#         self.echo_packets = echo_packets
# 
#     @property
#     def port(self):
#         return self.base_port
# 
#     @property
#     def name(self):
#         return self.base_name
# 
#     def connect(self, *args, **kwargs):
#         self.base_tnc.connect(*args, **kwargs)
# 
#     def close(self, *args, **kwargs):
#         self.base_tnc.close(*args, **kwargs)
# 
#     def write(self, frame, *args, **kwargs):
#         with self.lock:
#             frame_hash = str(aprs_util.hash_frame(frame))
#             if frame_hash not in self.packet_cache:
#                 self.packet_cache[frame_hash] = frame
#                 if self.base_port:
#                     self.base_tnc.write(frame, self.base_port)
#                 else:
#                     self.base_tnc.write(frame)
# 
#                 if self.echo_packets:
#                     echo_colorized_frame(frame, self.base_name, False)
# 
#     def read(self, *args, **kwargs):
#         with self.lock:
#             frame = self.base_tnc.read(*args, **kwargs)
#             if not frame:
#                 return frame
#             frame_hash = str(aprs_util.hash_frame(frame))
#             if frame_hash not in self.packet_cache:
#                 self.packet_cache[frame_hash] = frame
#                 if self.echo_packets:
#                     echo_colorized_frame(frame, self.base_name, True)
#                 return frame
#             else:
#                 return None
# 
# Path: src/apex/util.py
# def echo_colorized_error(text):
#     click.echo(click.style('Error: ', fg='red', bold=True, blink=True) + click.style(text, bold=True))
# 
# Path: src/apex/util.py
# def echo_colorized_warning(text):
#     click.echo(click.style('Warning: ', fg='yellow') + click.style(text))


# Path: src/apex/cli.py
import os
import signal
import sys
import threading
import time
import click
import six
import apex.aprs
import apex.buffers
    import ConfigParser  # noqa: F401
    import configparser
from apex.kiss import constants as kissConstants
from apex.plugin_loader import get_plugins
from apex.plugin_loader import load_plugin
from .buffers import NonrepeatingBuffer
from .util import echo_colorized_error
from .util import echo_colorized_warning

        if config.has_option('IGATE', 'password'):
            aprsis_password = config.get('IGATE', 'password')
        else:
            aprsis_password = -1
        aprsis_server = config.get('IGATE', 'server')
        aprsis_server_port = config.get('IGATE', 'server_port')
        aprsis_base = apex.buffers.ReconnectingPacketBuffer(apex.aprs.IGate(aprsis_callsign, aprsis_password))
        aprsis = NonrepeatingBuffer(aprsis_base, 'IGATE')
        aprsis.connect(aprsis_server, int(aprsis_server_port))

    return True


@click.command(context_settings=dict(auto_envvar_prefix='APEX'))
@click.option('-c',
              '--configfile',
              type=click.Path(exists=True, file_okay=True, dir_okay=False, readable=True, resolve_path=True),
              help='Configuration file for APEX.')
@click.option('-v', '--verbose', is_flag=True, help='Enables verbose mode.')
def main(verbose, configfile):
    # load the configuration, if it fails, exit
    if not configure(configfile, verbose):
        return

    click.echo("Press ctrl + c at any time to exit")

    # start the plugins
    try:
        plugin_loaders = get_plugins()
        if not len(plugin_loaders):

            echo_colorized_warning('No plugins were able to be discovered, will only display incoming messages.')