Exemple #1
0
 def run(self):
     print 'starting %s ....' % PROGNAME
     logger.info('starting %s ....' % PROGNAME)
     config = SkyPunchConfig(logger)	
     targetmodel = TargetModel(logger,config)
     notifiermodel = NotifierModel(logger,config)
     puncher = Puncher(logger,targetmodel,notifiermodel)
     try:
         while True:
             ids = targetmodel.get_ids()
             for id in ids:
                 target = targetmodel.get(id)
                 if target.enabled:
                     puncher.punch(target)
             time.sleep(config.getint(skypunchconfig.SETTINGS,skypunchconfig.MAINLOOPTOV))
     except SystemExit, e:
         sys.exit(e)
Exemple #2
0
 def run(self):
     print 'starting %s ....' % PROGNAME
     logger.info('starting %s ....' % PROGNAME)
     config = SkyPunchConfig(logger)
     targetmodel = TargetModel(logger, config)
     notifiermodel = NotifierModel(logger, config)
     puncher = Puncher(logger, targetmodel, notifiermodel)
     try:
         while True:
             ids = targetmodel.get_ids()
             for id in ids:
                 target = targetmodel.get(id)
                 if target.enabled:
                     puncher.punch(target)
             time.sleep(
                 config.getint(skypunchconfig.SETTINGS,
                               skypunchconfig.MAINLOOPTOV))
     except SystemExit, e:
         sys.exit(e)
Exemple #3
0
                                  skypunchconfig.MAINLOOPTOV))
        except SystemExit, e:
            sys.exit(e)

    # shutdown
    def stop(self, signum, frame):
        print 'shutting down %s ...' % PROGNAME
        logger.info('shutting down %s ....' % PROGNAME)
        sys.exit(0)


# start, stop or respond to command
if __name__ == "__main__":
    # set up logging
    logger = logging.getLogger(PROGNAME)
    config = SkyPunchConfig(logger)
    hdlr = logging.FileHandler(
        config.getstr(skypunchconfig.SETTINGS, skypunchconfig.LOGFILEPATH))
    formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
    hdlr.setFormatter(formatter)
    logger.addHandler(hdlr)
    logger.setLevel(logging.INFO)

    # set up CLI processor
    cli = SkyPunchCLI(logger, config)
    options = skypunchcli.COMMANDS

    if len(sys.argv) == 1:
        prog_options = 'usage: %s %s | %s ' % (PROGNAME, START, STOP)
        for option in options:
            prog_options += ' | %s' % option
Exemple #4
0
                time.sleep(config.getint(skypunchconfig.SETTINGS,skypunchconfig.MAINLOOPTOV))
        except SystemExit, e:
            sys.exit(e)


    # shutdown
    def stop(self,signum,frame):
        print 'shutting down %s ...' % PROGNAME
        logger.info('shutting down %s ....' % PROGNAME)
        sys.exit(0)

# start, stop or respond to command
if __name__ == "__main__":
    # set up logging
    logger = logging.getLogger(PROGNAME)
    config = SkyPunchConfig(logger)
    hdlr = logging.FileHandler(config.getstr(skypunchconfig.SETTINGS,skypunchconfig.LOGFILEPATH))
    formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
    hdlr.setFormatter(formatter)
    logger.addHandler(hdlr)
    logger.setLevel(logging.INFO)

    # set up CLI processor
    cli = SkyPunchCLI(logger,config) 
    options = skypunchcli.COMMANDS

    if len(sys.argv) == 1:
        prog_options = 'usage: %s %s | %s ' % (PROGNAME,START,STOP)
        for option in options:
             prog_options += ' | %s' % option
        print 'version: %s' % __version__