Beispiel #1
0
    def runTest(self):
        """ verifies the dump_log_stats method of LogStat """
        # first remove everything in the table
        LogStat.deleteMany(None)
        # generate log_stats dict
        my_stats = {
            "test_stat_1": {
                "DEBUG": datetime.datetime.now(),
                "INFO": datetime.datetime.now(),
                "WARNING": datetime.datetime.now(),
                "ERROR": datetime.datetime.now(),
                "n_entries": 3
            },
            "test_stat_2": {
                "INFO": datetime.datetime.now(),
                "WARNING": datetime.datetime.now()
            }
        }
        my_stats["test_stat_1"]["last_activity"] = my_stats["test_stat_1"][
            "ERROR"]
        my_stats["test_stat_2"]["last_activity"] = my_stats["test_stat_2"][
            "WARNING"]
        # insert the stats in the database
        LogStat.dump_log_stats(my_stats)

        # add the n_entries attrbute which will be automaticcaly added by dump in its return value
        my_stats["test_stat_2"]["n_entries"] = 0

        # Now load the inserted stats and check that everything has been correctly loaded
        assert LogStat.load_log_stats() == my_stats
Beispiel #2
0
def create_database():
    Building.createTable()
    Channel.createTable()
    Plugin.createTable()
    User.createTable()
    PluginChannel.createTable()
    ChannelBundle.createTable()
    Role.createTable()
    Screen.createTable()
    ScreenMac.createTable()
    Subscription.createTable()
    Template.createTable()
    Asset.createTable()
    PluginParamAccessRights.createTable()
    LogStat.createTable()
    DBVersion.createTable()
    DBVersion(version=database_version)
    User(username="******", fullname="ICTV Admin", email="admin@ictv", super_admin=True, disabled=False)
Beispiel #3
0
    def runTest(self):
        """ verifies the dump_log_stats method of LogStat """
        # generate log_stats dict
        my_stats = {
            "test_stat_1": {
                "DEBUG": datetime.datetime.now(),
                "INFO": datetime.datetime.now(),
                "WARNING": datetime.datetime.now(),
                "ERROR": datetime.datetime.now(),
                "n_entries": 3
            },
            "test_stat_2": {
                "INFO": datetime.datetime.now(),
                "WARNING": datetime.datetime.now()
            }
        }
        my_stats["test_stat_1"]["last_activity"] = my_stats["test_stat_1"][
            "ERROR"]
        my_stats["test_stat_2"]["last_activity"] = my_stats["test_stat_2"][
            "WARNING"]
        LogStat.dump_log_stats(my_stats)
        test_stat_1 = LogStat.selectBy(logger_name="test_stat_1").getOne(None)
        test_stat_2 = LogStat.selectBy(logger_name="test_stat_2").getOne(None)
        assert test_stat_1 is not None
        assert test_stat_2 is not None
        assert test_stat_1.last_debug == my_stats["test_stat_1"]["DEBUG"]
        assert test_stat_1.last_info == my_stats["test_stat_1"]["INFO"]
        assert test_stat_1.last_warning == my_stats["test_stat_1"]["WARNING"]
        assert test_stat_1.last_error == my_stats["test_stat_1"]["ERROR"]
        assert test_stat_1.last_activity == my_stats["test_stat_1"][
            "last_activity"]
        assert test_stat_1.n_entries == my_stats["test_stat_1"]["n_entries"]

        assert test_stat_2.last_debug is None
        assert test_stat_2.last_info == my_stats["test_stat_2"]["INFO"]
        assert test_stat_2.last_warning == my_stats["test_stat_2"]["WARNING"]
        assert test_stat_2.last_error is None
        assert test_stat_2.last_activity == my_stats["test_stat_2"][
            "last_activity"]
        assert test_stat_2.n_entries == 0
Beispiel #4
0
def dump_log_stats():
    from ictv.common.logging import loggers_stats
    LogStat.dump_log_stats(loggers_stats)
Beispiel #5
0
def load_loggers_stats():
    """ return a dictionary containing the information concerning the loggers stored in database """
    for log_stat in LogStat.select():
        log_stat.n_entries = count_entries(log_stat.logger_name)
    loggers_stats.update(LogStat.load_log_stats())