# log dir is subdir of script
    if DEBUGGING_MODE:
        LOG_DIR = os.path.join(sys.path[0],
                               "logs_debugging/" + __name__ + "_log")
    else:
        LOG_DIR = "logs/" + __name__ + "_log"

    if not os.path.exists(LOG_DIR):
        os.makedirs(LOG_DIR)

    LOG_NAME = __name__ + "_log"
    LOG_DATE_TIME_FORMAT = "%Y-%m-%d"
    if DEBUGGING_MODE:
        logger = logger_setup.setup(__name__,
                                    LOG_DIR,
                                    LOG_NAME,
                                    LOG_DATE_TIME_FORMAT,
                                    console_output_on=True,
                                    console_output_level="DEBUG")
    else:
        logger = logger_setup.setup(__name__,
                                    LOG_DIR,
                                    LOG_NAME,
                                    LOG_DATE_TIME_FORMAT,
                                    console_output_on=False,
                                    console_output_level="DEBUG")
else:
    # If logger is to be disabled, create dummy logger and disable it
    logger = logging.getLogger()
    logger.disabled = True

#STAR_POP_DIR = os.path.join(sys.path[0], "star_population_tables")
import mail_notification

# if already running, return
if os.popen("ps -Af").read().count(__file__) > 1:
    mail_notification.send_notification(
        "ROGUE code exited because it was already running", "ROGUE code exited", ["*****@*****.**"]
    )
    sys.exit(0)

# create and set up filepath and directory for logs -
# log dir is subdir of script
# LOG_DIR = os.path.join(sys.path[0], "logs/run_ROGUE_and_TAP_recorder_log")
LOG_DIR = "/science/robonet/rob/Operations/Logs/2016"
LOG_NAME = "run_ROGUE_and_TAP_recorder_log"
LOG_DATE_TIME_FORMAT = "%Y-%m-%d"
logger = logger_setup.setup(__name__, LOG_DIR, LOG_NAME, LOG_DATE_TIME_FORMAT)


def run_ROGUE_and_TAP_recorder():
    logger.info("----------------------------------------------------------------")
    try:
        logger.info("Running TAP table recorder...")
        TAP_table_recording.update_and_save_table()
    except Exception as ex:
        logger.warning("Exception recording TAP table.")
        logger.warning(ex)

    try:
        logger.info("Running ROGUE short duration microlensing alert system...")
        ROGUE.run_ROGUE()
    except Exception as ex:
if LOGGER_ON:
    # create and set up filepath and directory for logs -
    # log dir is subdir of script
    if DEBUGGING_MODE:
	    LOG_DIR = os.path.join(sys.path[0], "logs_debugging/" + __name__ + "_log")
    else:
	    LOG_DIR = "logs/" + __name__ + "_log"

    if not os.path.exists(LOG_DIR):
        os.makedirs(LOG_DIR)

    LOG_NAME = __name__ + "_log"
    LOG_DATE_TIME_FORMAT = "%Y-%m-%d"
    if DEBUGGING_MODE:
	    logger = logger_setup.setup(__name__, LOG_DIR, LOG_NAME, LOG_DATE_TIME_FORMAT, console_output_on=True, console_output_level = "DEBUG")
    else:
	    logger = logger_setup.setup(__name__, LOG_DIR, LOG_NAME, LOG_DATE_TIME_FORMAT, console_output_on=True, console_output_level = "INFO")
else:
    # If logger is to be disabled, create dummy logger and disable it
    logger = logging.getLogger()
    logger.disabled = True

# default value constants
IMPACT_MIN_DEFAULT = 0.1
EINSTEIN_TIME_DEFAULT = 10 * units.d
TIME_MAX_DEFAULT = 15 * units.d
DURATION_DEFAULT = 2 * TIME_MAX_DEFAULT
PERIOD_DEFAULT = 17.7 * units.h
NIGHT_DURATION_DEFAULT = 10 * units.h
예제 #4
0
파일: airbot.py 프로젝트: alfredbox/airbot
import asyncio

import logger_setup
import state

import pm25_read
import publish_aq_data
import ifttt_notify
import size_dist
import time_series

# Logging
logger_setup.setup()
logger = logger_setup.get_logger()


def assemble_processes():
    # Initialize state
    s = state.State()
    # Configure processes.
    processes = []
    # PM2.5 sensot reader
    processes.append(pm25_read.PM25Read(s))
    # Publish sensor reading to dashboard
    processes.append(publish_aq_data.AQPublisher(s))
    # Send push notification via IFTTT
    processes.append(ifttt_notify.IFTTTNotify(s))
    # Plot size distribution to web
    processes.append(size_dist.PlotSizeDist(s))
    # Plot aqi time series to web
    processes.append(time_series.PlotTimeSeries(s))