Exemplo n.º 1
0
from config.settings import threadpool_executor
from core import toLog
from core.log_manager.log_levels import setup_logger

setup_logger('apscheduler', path_apscheduler, logging.DEBUG)

executors = {
    'default': ThreadPoolExecutor(threadpool_executor),
    'processpool': ProcessPoolExecutor(processpool_executor)
}

job_defaults = {'coalesce': coalesce, 'max_instances': max_instances}

scheduler = TwistedScheduler(timezone=local_tz)
scheduler.add_jobstore('mongodb',
                       host=MONGO_HOST_SELF,
                       port=MONGO_PORT_SELF,
                       collection=CORE_ID)

scheduler.add_executor(ThreadPoolExecutor(threadpool_executor), 'default')

scheduler.add_executor(ProcessPoolExecutor(processpool_executor),
                       'processpool')

scheduler.start()


def job_logger(event):
    if event.code > 512:
        toLog(
            'Job {}, code {}'.format(event.job_id,
                                     event_code_translator(event.code)),
Exemplo n.º 2
0
setup_logger('apscheduler', path_apscheduler, logging.DEBUG)

executors = {
    'default': ThreadPoolExecutor(threadpool_executor),
    'processpool': ProcessPoolExecutor(processpool_executor)
}

job_defaults = {
    'coalesce': coalesce,
    'max_instances': max_instances
}

scheduler = TwistedScheduler(timezone=local_tz)
scheduler.add_jobstore(
    'mongodb',
    host=MONGO_HOST_SELF,
    port=MONGO_PORT_SELF,
    collection=CORE_ID
)

scheduler.add_executor(
    ThreadPoolExecutor(threadpool_executor), 'default'
)

scheduler.add_executor(
    ProcessPoolExecutor(processpool_executor), 'processpool'
)

scheduler.start()


def job_logger(event):
Exemplo n.º 3
0
    for key, val in conf["saidas"].items() if type(val) == int
}
input_pins = {
    key: val
    for key, val in conf["entradas"].items() if type(val) == int
}
estado = {x: False for x in conf["entradas"]}
sensor_pins = conf["sensores"]

gpio = None

# criação do scheduler
scheduler = TwistedScheduler()
# configurações do scheduler
scheduler = scheduler
scheduler.add_jobstore('sqlalchemy', engine=db.engine)


# configurações para o raspi
def configGPIO():
    import RPi.GPIO as GPIO
    global gpio
    gpio = GPIO

    gpio.setmode(gpio.BCM)
    for pin in output_pins:
        gpio.setup(output_pins[pin], gpio.OUT, initial=gpio.HIGH)
    for pin in input_pins:
        gpio.setup(input_pins[pin], gpio.IN, pull_up_down=gpio.PUD_UP)
    for pin in estado:
        if pin in input_pins: