Exemple #1
0
def main(argv):
    """
    Main driver for Update DB
    """
    log_level = logging.WARNING
    config = get_config(path='/var/opt/cuadrnt', file_name='cuadrnt.cfg')
    try:
        opts, args = getopt.getopt(argv, 'h', ['help', 'log='])
    except getopt.GetoptError:
        print "usage: update_db.py [--log=notset|debug|info|warning|error|critical]"
        print "   or: update_db.py --help"
        sys.exit()
    for opt, arg in opts:
        if opt in ('-h', '--help'):
            print "usage: update_db.py [--log=notset|debug|info|warning|error|critical]"
            print "   or: update_db.py --help"
            sys.exit()
        elif opt in ('--log'):
            log_level = getattr(logging, arg.upper())
            if not isinstance(log_level, int):
                print "%s is not a valid log level" % (str(arg))
                print "usage: update_db.py [--log=notset|debug|info|warning|error|critical]"
                print "   or: update_db.py --help"
                sys.exit()
        else:
            print "usage: update_db.py [--log=notset|debug|info|warning|error|critical]"
            print "   or: update_db.py --help"
            print "error: option %s not recognized" % (str(opt))
            sys.exit()

    log_path = config['paths']['log']
    log_file = 'update_db.log'
    file_name = '%s/%s' % (log_path, log_file)
    logger = logging.getLogger()
    logger.setLevel(log_level)
    handler = TimedRotatingFileHandler(file_name,
                                       when='midnight',
                                       interval=1,
                                       backupCount=6)
    formatter = logging.Formatter(
        '%(asctime)s [%(levelname)s] %(name)s:%(funcName)s:%(lineno)d: %(message)s',
        datefmt='%H:%M')
    handler.setFormatter(formatter)
    logger.addHandler(handler)
    update_db = UpdateDB(config)
    update_db.start()
Exemple #2
0
def main(argv):
    """
    Main driver for Update DB
    """
    log_level = logging.WARNING
    config = get_config(path="/var/opt/cuadrnt", file_name="update_db.cfg")
    try:
        opts, args = getopt.getopt(argv, "h", ["help", "log="])
    except getopt.GetoptError:
        print "usage: update_db.py [--log=notset|debug|info|warning|error|critical]"
        print "   or: update_db.py --help"
        sys.exit()
    for opt, arg in opts:
        if opt in ("-h", "--help"):
            print "usage: update_db.py [--log=notset|debug|info|warning|error|critical]"
            print "   or: update_db.py --help"
            sys.exit()
        elif opt in ("--log"):
            log_level = getattr(logging, arg.upper())
            if not isinstance(log_level, int):
                print "%s is not a valid log level" % (str(arg))
                print "usage: update_db.py [--log=notset|debug|info|warning|error|critical]"
                print "   or: update_db.py --help"
                sys.exit()
        else:
            print "usage: update_db.py [--log=notset|debug|info|warning|error|critical]"
            print "   or: update_db.py --help"
            print "error: option %s not recognized" % (str(opt))
            sys.exit()

    log_path = config["paths"]["log"]
    log_file = "update_db.log"
    file_name = "%s/%s" % (log_path, log_file)
    logger = logging.getLogger()
    logger.setLevel(log_level)
    handler = TimedRotatingFileHandler(file_name, when="midnight", interval=1, backupCount=10)
    formatter = logging.Formatter(
        "%(asctime)s [%(levelname)s] %(name)s:%(funcName)s:%(lineno)d: %(message)s", datefmt="%H:%M"
    )
    handler.setFormatter(formatter)
    logger.addHandler(handler)
    update_db = UpdateDB(config)
    update_db.start()
Exemple #3
0
def main(argv):
    """
    Main driver for Data Analysis
    """
    log_level = logging.WARNING
    config = get_config(path='/var/opt/cuadrnt', file_name='data_analysis.cfg')
    try:
        opts, args = getopt.getopt(argv, 'h', ['help', 'log='])
    except getopt.GetoptError:
        print "usage: data_analysis.py [--log=notset|debug|info|warning|error|critical]"
        print "   or: data_analysis.py --help"
        sys.exit()
    for opt, arg in opts:
        if opt in ('-h', '--help'):
            print "usage: data_analysis.py [--log=notset|debug|info|warning|error|critical]"
            print "   or: data_analysis.py --help"
            sys.exit()
        elif opt in ('--log'):
            log_level = getattr(logging, arg.upper())
            if not isinstance(log_level, int):
                print "%s is not a valid log level" % (str(arg))
                print "usage: data_analysis.py [--log=notset|debug|info|warning|error|critical]"
                print "   or: data_analysis.py --help"
                sys.exit()
        else:
            print "usage: data_analysis.py [--log=notset|debug|info|warning|error|critical]"
            print "   or: data_analysis.py --help"
            print "error: option %s not recognized" % (str(opt))
            sys.exit()

    log_path = config['paths']['log']
    log_file = 'data_analysis.log'
    file_name = '%s/%s' % (log_path, log_file)
    logger = logging.getLogger()
    logger.setLevel(log_level)
    handler = TimedRotatingFileHandler(file_name, when='midnight', interval=1, backupCount=10)
    formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(name)s:%(funcName)s:%(lineno)d: %(message)s', datefmt='%H:%M')
    handler.setFormatter(formatter)
    logger.addHandler(handler)
    data_analysis = DataAnalysis(config)
    data_analysis.start()
Exemple #4
0
 def setUp(self):
     "Set up for test"
     self.config = get_config(path=opt_path, file_name='test.cfg')
Exemple #5
0
 def setUp(self):
     "Set up for test"
     self.config = get_config(path=opt_path, file_name='test.cfg')
Exemple #6
0
 def setUp(self):
     "Set up for test"
     self.config = get_config(path=opt_path, file_name='test.cfg')
     self.storage = StorageManager(config=self.config)
     self.storage.drop_db()