Ejemplo n.º 1
0
def main():
    """
    The entry point for our program
    """
    logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)
    logging.info('Started')
    stopper = threading.Event()
    adc_queue = Queue.Queue(10)

    # Setup our input threads
    adc_thread = Adc(adc_queue, 0.3, stopper)

    # create our signal handler and connect it
    handler = SignalHandler(stopper, [adc_thread])
    signal.signal(signal.SIGINT, handler)

    adc_thread.start()

    while True:
        logging.info("running in main loop...")
        try:
            logging.debug(adc_queue.qsize())
            adc_values = adc_queue.get_nowait()
            logging.info(values_to_voltages(adc_values))
        except Queue.Empty:
            logging.debug("adcQueue is empty")
        sleep(0.5)
Ejemplo n.º 2
0
def main():
    print('MAIN: Start...')
    sig = SignalHandler((signal.SIGINT, signal.SIGTERM))
    loader = Loader(init_cfg=get_cfg(),
                    init_state=get_state(),
                    path=get_path(HOME),
                    sig=sig)
    try:
        loader.start_all_systems()
    except RuntimeError:
        pass
    else:
        sig.sleep(None)
    loader.stop_all_systems()
    print('MAIN: bye.')
    return loader.reload
Ejemplo n.º 3
0
def main():
    print('MAIN: Start...')
    sig = SignalHandler((signal.SIGINT, signal.SIGTERM))
    loader = Loader(init_cfg=CFG.copy(),
                    path=get_path(HOME),
                    die_in=sig.die_in)
    loader.start()
    while not sig.interrupted():
        sig.sleep(100)
    sig.stop()
    loader.stop()
    print('MAIN: bye.')
    return loader.reload
Ejemplo n.º 4
0
                if args.verbose > 1:
                    print blue("Whitelisted IPs:")
                for item in content:
                    if args.verbose > 1:
                        print blue("\t" + item)
                whitelist = content
        except Exception as e:
            print blue("Whitelist file '{}' not found!".format(args.whitelist))

    # Create the thread and start it
    processorThread = Processor(queue, timedelta(minutes=args.width),
                                args.datawhois, args.verbose, args.amount,
                                args.dontdetect, args.threshold, args.debug,
                                whitelist, args.sdw_width, config,
                                parsingfunction)
    SH = SignalHandler(processorThread)
    SH.register_signal(signal.SIGINT)
    processorThread.start()

    if args.filepath:
        if args.verbose > 2:
            print 'Working with the file {} as parameter'.format(args.filepath)
        f = open(args.filepath)
        line = f.readline()
        while line:
            queue.put(line)
            line = f.readline()
        f.close()
        if args.verbose > 2:
            print "Finished reading the file. "
        time.sleep(1)
Ejemplo n.º 5
0
import time
from prawcore.exceptions import RequestException, ServerError
from Reddit import reddit
from configs import configs
from utils import (
    isVideoOfAccepatableLength,
    SignalHandler,
    debugPrint,
)

signalHandler = SignalHandler()


def main():

    MULTI_REDDIT = configs["MULTI_REDDIT"]
    for submission in reddit.subreddit(MULTI_REDDIT).stream.submissions():

        if submission.saved:
            debugPrint("Skipping Saved: " + submission.id)
            continue

        signalHandler.loopStart()

        debugPrint()
        print("Discovered: " + submission.id)

        if not submission.is_self:
            config = configs[submission.subreddit.display_name.lower()]
            if not isVideoOfAccepatableLength(submission, config):
                submission.mod.remove(reason_id=config.REASON_ID)