Ejemplo n.º 1
0
    def __init__(self, pidfile, stdin='/dev/null', stdout='/dev/null',
                 stderr='/dev/null', logfile='/dev/null'):

        self.stdin = stdin
        self.stdout = logfile
        self.stderr = logfile
        self.pidfile = pidfile

        # Setup log file
        setup_logger(self.__class__.__name__, logfile, self.DEF_LOG_LEVEL)
        self.log = getLogger(self.__class__.__name__)
Ejemplo n.º 2
0
if __name__ == "__main__":

    #def_log_file = BASE_LOG + 'update_stats.log'
    def_log_file = '/dev/stout'

    parser = argparse.ArgumentParser()

    parser.add_argument(
        "--days", required=False, nargs='?', default=2,
        help="Numero di giorni a partire dalla data di oggi da elaborare")

    parser.add_argument(
        "--log", required=False, nargs='?',
        default='/dev/stdout', help="LOG file")

    args = parser.parse_args()

    # Setup log file
    setup_logger('update_stats', args.log, INFO)
    log = getLogger('update_stats')

    st = UpdateStats(log=log)
    try:
        dates = st.getDates(args.days)
        exit(0 if st.updateStats(dates) else 1)
    except Exception as err:
        log.error("Impossibile aggiornare statistiche")
        log.error(traceback.format_exc())
        exit(1)
Ejemplo n.º 3
0
from smac_utils import setup_logger
from logging import getLogger
from sys import exit


if __name__ == "__main__":

    parser = argparse.ArgumentParser()

    cmd_list = ['state', 'reload', 'on', 'off']

    parser.add_argument("command", choices=cmd_list,
                        help="Comando da inviare allo switcher")

    args = parser.parse_args()

    # Setup log file su null handler. Lo Swich vuole un
    # oggetto q log, gliene passo uno fittizio
    setup_logger('switcher_communicator', log_file=None)
    log = getLogger('switcher_communicator')

    try:
        cmd = args.command
        sw = Switch(log)
        res = getattr(sw,  cmd)()
        print(res)
        exit(0)
    except Exception as e:
        print(repr(e))
        exit(1)