Exemple #1
0
    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)
Exemple #2
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)