Example #1
0
    def terminate():

        logger.warn("finish produce")
        Produce.stop()

        logger.warn("finish %d drivers", len(running_drivers))
        for d in running_drivers:
            try:
                d.stop()
            except:
                pass

        logger.warn("finish %d tasks", len(running_tasks))
        for t in running_tasks:
            if processes_type == "process":
                try:
                    t.terminate()
                except:
                    pass
            else:
                # daemon threads
                pass
Example #2
0
    # logging level
    print_debug_level()

    # init logging
    print_with_time("starting sniffer")

    # init config
    print_with_time("start to init config")
    init_config()

    # init sentry
    print_with_time("start to init sentry")
    init_sentry()

    print_with_time("start to init Produce")
    Produce.start()

    # init redis
    print_with_time("start to init redis")
    init_redis()

    # init metrics
    print_with_time("start to init metrics")
    init_metrics()

    # init auto parser
    init_autoparser()

    # start the program
    print_with_time("start to processing")
    start()
Example #3
0
from adafruit_magtag.magtag import MagTag
from produce import Produce


# CONFIGURABLE SETTINGS and ONE-TIME INITIALIZATION ------------------------

TWELVE_HOUR = True # If set, show 12-hour vs 24-hour (e.g. 3:00 vs 15:00)
DD_MM = False      # If set, show DD/MM instead of MM/DD dates
# Location of produce data (file:// or http:// or https://):
JSON_URL = 'https://raw.githubusercontent.com/adafruit/Adafruit_Learning_System_Guides/master/MagTag_Seasonal_Produce/produce.json'

# Location is configured in secrets.py. If location is not contained there,
# default value below will be used.
LOCATION = secrets.get('location', 'NY') # default to 'NY'

PRODUCE = Produce(JSON_URL, LOCATION)
MAGTAG = MagTag(rotation=0) # Portrait (vertical) display


# SOME UTILITY FUNCTIONS ---------------------------------------------------

def hh_mm(time_struct, twelve_hour=True):
    """ Given a time.struct_time, return a string as H:MM or HH:MM, either
        12- or 24-hour style depending on twelve_hour flag.
    """
    if twelve_hour:
        if time_struct.tm_hour > 12:
            hour_string = str(time_struct.tm_hour - 12) # 13-23 -> 1-11 (pm)
        elif time_struct.tm_hour > 0:
            hour_string = str(time_struct.tm_hour) # 1-12
        else: