Пример #1
0
    def next_time(self):
        lasttime = self.lasttime
        if lasttime == '':
            # let it be one year ago (we can schedule 1 month maximum) and one day
            lasttime = str(time.time() - 366 * 24 * 60 * 60)

        try:
            # turned off - return -1
            if self.type in ['none', 'disabled']:
                return -1

            # every N seconds
            elif self.type == 'continuously':
                return maths.shedule_continuously(lasttime, int(self.interval),)

            # every N hours, exactly when hour begins, minutes and seconds are 0
            elif self.type == 'hourly':
                return maths.shedule_next_hourly(lasttime, int(self.interval),)

            # every N days, at given time
            elif self.type == 'daily':
                return maths.shedule_next_daily(lasttime, self.interval, self.daytime)

            # every N weeks, at given time and selected week days
            elif self.type == 'weekly':
                week_days = self.details.split(' ')
                week_day_numbers = []
                week_day_names = list(calendar.day_name)
                for week_label in week_days:
                    try:
                        i = week_day_names.index(week_label)
                    except:
                        continue
                    week_day_numbers.append(i)
                return maths.shedule_next_weekly(lasttime, self.interval, self.daytime, week_day_numbers)

            # monthly, at given time and day
            elif self.type == 'monthly':
                month_dates = self.details.split(' ')
                return maths.shedule_next_monthly(lasttime, self.interval, self.daytime, month_dates)

            # yearly, at given time and month, day, NOT DONE YET!
            elif self.type == 'yearly':
                months_labels = self.details.split(' ')
                months_numbers = []
                months_names = list(calendar.month_name)
                for month_label in months_labels:
                    try:
                        i = months_names.index(month_label)
                    except:
                        continue
                    months_numbers.append(i)
                return maths.shedule_next_monthly(lasttime, self.interval, self.daytime, months_numbers)

            else:
                lg.out(1, 'schedule.next_time ERROR wrong schedule type: ' + self.type)
                return None
        except:
            lg.exc()
            return None
Пример #2
0
    def next_time(self):
        lasttime = self.lasttime
        if lasttime == '':
            # let it be one year ago (we can schedule 1 month maximum) and one day
            lasttime = str(time.time() - 366 * 24 * 60 * 60)

        try:
            # turned off - return -1
            if self.type in ['none', 'disabled']:
                return -1

            # every N seconds
            elif self.type == 'continuously':
                return maths.shedule_continuously(lasttime, int(self.interval),)

            # every N hours, exactly when hour begins, minutes and seconds are 0
            elif self.type == 'hourly':
                return maths.shedule_next_hourly(lasttime, int(self.interval),)

            # every N days, at given time
            elif self.type == 'daily':
                return maths.shedule_next_daily(lasttime, self.interval, self.daytime)

            # every N weeks, at given time and selected week days
            elif self.type == 'weekly':
                week_days = self.details.split(' ')
                week_day_numbers = []
                week_day_names = list(calendar.day_name)
                for week_label in week_days:
                    try:
                        i = week_day_names.index(week_label)
                    except:
                        continue
                    week_day_numbers.append(i)
                return maths.shedule_next_weekly(lasttime, self.interval, self.daytime, week_day_numbers)

            # monthly, at given time and day
            elif self.type == 'monthly':
                month_dates = self.details.split(' ')
                return maths.shedule_next_monthly(lasttime, self.interval, self.daytime, month_dates)

            # yearly, at given time and month, day, NOT DONE YET!
            elif self.type == 'yearly':
                months_labels = self.details.split(' ')
                months_numbers = []
                months_names = list(calendar.month_name)
                for month_label in months_labels:
                    try:
                        i = months_names.index(month_label)
                    except:
                        continue
                    months_numbers.append(i)
                return maths.shedule_next_monthly(lasttime, self.interval, self.daytime, months_numbers)

            else:
                lg.out(1, 'schedule.next_time ERROR wrong schedule type: ' + self.type)
                return None
        except:
            lg.exc()
            return None
Пример #3
0
def next(d):
    lasttime = d.get('lasttime', '').strip()
    if lasttime == '':
        # let it be one year ago (we can shedule 1 month maximum)
        lasttime = str(time.time() - 365 * 24 * 60 * 60)

    if d['type'] in ['none', 'disabled']:
        return -1

    elif d['type'] == 'continuously':
        return maths.shedule_continuously(
            lasttime,
            d['interval'],
        )

    elif d['type'] == 'hourly':
        return maths.shedule_next_hourly(lasttime, d['interval'])

    elif d['type'] == 'daily':
        return maths.shedule_next_daily(lasttime, d['interval'], d['daytime'])

    elif d['type'] == 'weekly':
        week_days = d['details'].split(' ')
        week_day_numbers = []
        week_day_names = list(calendar.day_name)
        for week_label in week_days:
            try:
                i = week_day_names.index(week_label)
            except:
                continue
            week_day_numbers.append(i)
        return maths.shedule_next_weekly(lasttime, d['interval'], d['daytime'],
                                         week_day_numbers)

    elif d['type'] == 'monthly':
        month_dates = d['details'].split(' ')
        return maths.shedule_next_monthly(lasttime, d['interval'],
                                          d['daytime'], month_dates)


#        months_labels = d['details'].split(' ')
#        months_numbers = []
#        months_names = list(calendar.month_name)
#        for month_label in months_labels:
#            try:
#                i = months_names.index(month_label)
#            except:
#                continue
#            months_numbers.append(i)
#        return maths.shedule_next_monthly(lasttime, d['interval'], d['daytime'], months_numbers)

    else:
        lg.out(1, 'os_windows_update.loop ERROR wrong shedule type')
        return None
Пример #4
0
def next(d):
    lasttime = d.get('lasttime', '').strip()
    if lasttime == '':
        # let it be one year ago (we can shedule 1 month maximum)
        lasttime = str(time.time() - 365 * 24 * 60 * 60)

    if d['type'] in ['none', 'disabled']:
        return -1

    elif d['type'] == 'continuously':
        return maths.shedule_continuously(lasttime, d['interval'],)

    elif d['type'] == 'hourly':
        return maths.shedule_next_hourly(lasttime, d['interval'])

    elif d['type'] == 'daily':
        return maths.shedule_next_daily(lasttime, d['interval'], d['daytime'])

    elif d['type'] == 'weekly':
        week_days = d['details'].split(' ')
        week_day_numbers = []
        week_day_names = list(calendar.day_name)
        for week_label in week_days:
            try:
                i = week_day_names.index(week_label)
            except:
                continue
            week_day_numbers.append(i)
        return maths.shedule_next_weekly(lasttime, d['interval'], d['daytime'], week_day_numbers)

    elif d['type'] == 'monthly':
        month_dates = d['details'].split(' ')
        return maths.shedule_next_monthly(lasttime, d['interval'], d['daytime'], month_dates)
#        months_labels = d['details'].split(' ')
#        months_numbers = []
#        months_names = list(calendar.month_name)
#        for month_label in months_labels:
#            try:
#                i = months_names.index(month_label)
#            except:
#                continue
#            months_numbers.append(i)
#        return maths.shedule_next_monthly(lasttime, d['interval'], d['daytime'], months_numbers)

    else:
        lg.out(1, 'os_windows_update.loop ERROR wrong shedule type')
        return None