class TestEntry(object):
    """"""

    #----------------------------------------------------------------------
    def __init__(self):
        """Constructor"""
        self.ID = 0
        self.Name = None
        self.Priority = 0
        self.CronTimeStr = None
        self.RunTime = None
        self.LastRunTime = 0
        self.Enabled = True
        self.Args = {}
        self.RunFlag = False

        self.parser = CronParser()
        self.RunTime = self._CronTime()

    def __str__(self):
        return "(id=%d, name=%s, args=%s, cron_time=\"%s\", last_run_time=%s, "\
               "priority=%d, enabled=%s)" % \
               (self.ID,
                self.Name,
                self.Args,
                self.CronTimeStr,
                self.LastRunTime,
                self.Priority,
                self.Enabled)

    def set_run_time(self, cron_time):
        time_ = cron_time.split()
        try:
            self.RunTime.minute = self.parser.parse_minute(time_[0])
            self.RunTime.hour = self.parser.parse_hour(time_[1])
            self.RunTime.day = self.parser.parse_day(time_[2])
            self.RunTime.month = self.parser.parse_month(time_[3])
            self.RunTime.weekday = self.parser.parse_weekday(time_[4])
        except:
            g_logger.error("Error in parsing cron time: %s" % cron_time)
        self.CronTimeStr = cron_time

    def time_to_run(self, cur_time):
        if cur_time.tm_min in self.RunTime.minute and \
           cur_time.tm_hour in self.RunTime.hour and \
           cur_time.tm_mday in self.RunTime.day and \
           cur_time.tm_mon in self.RunTime.month and \
           cur_time.tm_wday in self.RunTime.weekday:
            g_logger.debug("It's time to run '%s'" % self)
            return True
        else:
            return False

    class _CronTime(object):
        minute = None
        hour = None
        day = None
        month = None
        weekday = None
    def __init__(self):
        """Constructor"""
        self.ID = 0
        self.Name = None
        self.Priority = 0
        self.CronTimeStr = None
        self.RunTime = None
        self.LastRunTime = 0
        self.Enabled = True
        self.Args = {}
        self.RunFlag = False

        self.parser = CronParser()
        self.RunTime = self._CronTime()
    def __init__(self):
        """Constructor"""
        self.ID = 0
        self.Name = None
        self.Priority = 0
        self.CronTimeStr = None
        self.RunTime = None
        self.LastRunTime = 0
        self.Enabled = True
        self.Args = {}
        self.RunFlag = False

        self.parser = CronParser()
        self.RunTime = self._CronTime()
class TestEntry(object):
    """"""

    # ----------------------------------------------------------------------
    def __init__(self):
        """Constructor"""
        self.ID = 0
        self.Name = None
        self.Priority = 0
        self.CronTimeStr = None
        self.RunTime = None
        self.LastRunTime = 0
        self.Enabled = True
        self.Args = {}
        self.RunFlag = False

        self.parser = CronParser()
        self.RunTime = self._CronTime()

    def __str__(self):
        return '(id=%d, name=%s, args=%s, cron_time="%s", last_run_time=%s, ' "priority=%d, enabled=%s)" % (
            self.ID,
            self.Name,
            self.Args,
            self.CronTimeStr,
            self.LastRunTime,
            self.Priority,
            self.Enabled,
        )

    def set_run_time(self, cron_time):
        time_ = cron_time.split()
        try:
            self.RunTime.minute = self.parser.parse_minute(time_[0])
            self.RunTime.hour = self.parser.parse_hour(time_[1])
            self.RunTime.day = self.parser.parse_day(time_[2])
            self.RunTime.month = self.parser.parse_month(time_[3])
            self.RunTime.weekday = self.parser.parse_weekday(time_[4])
        except:
            g_logger.error("Error in parsing cron time: %s" % cron_time)
        self.CronTimeStr = cron_time

    def time_to_run(self, cur_time):
        if (
            cur_time.tm_min in self.RunTime.minute
            and cur_time.tm_hour in self.RunTime.hour
            and cur_time.tm_mday in self.RunTime.day
            and cur_time.tm_mon in self.RunTime.month
            and cur_time.tm_wday in self.RunTime.weekday
        ):
            g_logger.debug("It's time to run '%s'" % self)
            return True
        else:
            return False

    class _CronTime(object):
        minute = None
        hour = None
        day = None
        month = None
        weekday = None