예제 #1
0
def timeOffsetFromTimeTuple(time_tuple, minutes_offset):
    if minutes_offset == 0:
        return time_tuple
    else:
        mutable_time_instance = MutableTimeInstance.createInstanceByTimeTuple(time_tuple)
        mutable_time_instance.incrementSeconds(minutes_offset*60)
        return (mutable_time_instance.getMonth(), mutable_time_instance.getDayOfMonth(), mutable_time_instance.getHour(), mutable_time_instance.getMinute())
예제 #2
0
def timeOffsetFromTimeTuple(time_tuple, minutes_offset):
    if minutes_offset == 0:
        return time_tuple
    else:
        mutable_time_instance = MutableTimeInstance.createInstanceByTimeTuple(
            time_tuple)
        mutable_time_instance.incrementSeconds(minutes_offset * 60)
        return (mutable_time_instance.getMonth(),
                mutable_time_instance.getDayOfMonth(),
                mutable_time_instance.getHour(),
                mutable_time_instance.getMinute())
예제 #3
0
def runCommandInBackground(command):
    command = parseCommandToList(command)
    subprocess.Popen(command)


if __name__ == "__main__":
    CRON_FILE = sys.argv[1]
    cron_parser = CronParser()
    cron_rules = cron_parser.readCrontabFile(CRON_FILE)
    prayer_time_getter = PrayerTimesGetter()
    now = None
    current_day = 0
    today_and_tomorrow_prayer_times = None
    daily_cron_rules = None
    i = 0
    now = MutableTimeInstance()
    while i < 527040:
        if current_day != now.getDayOfMonth():
            current_day = now.getDayOfMonth()
            today_and_tomorrow_prayer_times = prayer_time_getter.getPrayerTimesForTodayAndTomorrow(
                now)
            daily_cron_rules = applyCronRules(cron_rules,
                                              today_and_tomorrow_prayer_times,
                                              now)
        key = now.getTimeTuple()
        commands = daily_cron_rules.get(key, [])
        if commands != []:
            for command in commands:
                runCommandInBackground(command)
        now.incrementSeconds(60)
        i += 1
예제 #4
0
def runCommandInBackground(command):
    command = parseCommandToList(command)
    subprocess.Popen(command)


if __name__ == "__main__":
    CRON_FILE = sys.argv[1]
    cron_parser = CronParser()
    cron_rules = cron_parser.readCrontabFile(CRON_FILE)
    prayer_time_getter = PrayerTimesGetter()
    now = None
    current_day = 0
    today_and_tomorrow_prayer_times = None
    daily_cron_rules = None
    i = 0
    now = MutableTimeInstance()
    while i < 527040:
        if current_day != now.getDayOfMonth():
            current_day = now.getDayOfMonth()
            today_and_tomorrow_prayer_times = prayer_time_getter.getPrayerTimesForTodayAndTomorrow(now)
            daily_cron_rules = applyCronRules(cron_rules, today_and_tomorrow_prayer_times, now)
        key = now.getTimeTuple()
        commands = daily_cron_rules.get(key, [])
        if commands != []:
            for command in commands:
                runCommandInBackground(command)
        now.incrementSeconds(60)
        i += 1
        #time.sleep(1)