Package: reptaskorg
REPeated TASK ORGanizer - reptaskorgLibary for repeated execution of functions at specific times.Examples:Every minute, when seconds 5 and 34 are reached:task=RepTaskOrg(second=[5,34])# 00:00:05, 00:00:34, 00:01:05, ...Every day, when hours 2, 8 and 12 and seconds 5 and 34 are reached:task=RepTaskOrg(hour=[2,8,12],second=[5,34])# 02:00:05, 02:00:34, 08:00:05, ...Every year, at the first second of may:task=RepTaskOrg(month=[5])# 2021.05.01 00:00:00, 2022.05.01 00:00:00, ...Every monday at 8 am:task=RepTaskOrg(weekday=[0],hour=[8])# 2021.05.03 08:00:00, 2022.05.10 08:00:00, ...Every day in week 18 at 8 am:task=RepTaskOrg(week=[18],hour=[8])# 2021.05.03 08:00:00, 2022.05.04 08:00:00, ...Table of ContentsREPeated TASK ORGanizer - reptaskorgTable of ContentsInstallUsageWithout threadingWith threadingOther featuresArgumentsRepTaskOrgRepTaskOrgTHRelease Notes1.0.11.0.00.2.30.2.20.2.10.20.1.10.1InstallFor installation usePypi:pip install reptaskorgorpip3 install reptaskorgUsageWithout threadingIf you have no time-consuming tasks in your main loop RapTaskOrg is a good solution.importdatetimeimporttimefromreptaskorgimportRepTaskOrgdefdo_something(alarm_number):print('{}- ALARM{}'.format(datetime.datetime.now().strftime('%H:%M:%S:%f'),alarm_number))defmain():# Define tasks with desired time stamps.task_1=RepTaskOrg(second=[0,10,20,30,40,50])task_2=RepTaskOrg(minute=[37,39],second=[0,10,20,30,40,50])# Call Task repeatedly to keep it up to date.whileTrue:# Outputs true as soon as the target time is reachediftask_1.check_task():do_something(1)iftask_2.check_task():do_something(2)time.sleep(0.001)if__name__=="__main__":main()With threadingIf you have time-consuming tasks in your main loop use RepTaskOrgTH. Here a separate thread is started for each task.importdatetimeimporttimefromreptaskorgimportRepTaskOrgTHdefdo_something(alarm_number):"""Function which should be executed repeatedly."""print('{}- ALARM{}'.format(datetime.datetime.now().strftime('%H:%M:%S:%f'),alarm_number))defdo_anotherthing(alarm_number,alarm_comment):"""Function which should be executed repeatedly with multiple arguments."""print('{}- ALARM{}{}'.format(datetime.datetime.now().strftime('%H:%M:%S:%f'),alarm_number,alarm_comment))defmain():"""Main-Function."""# Define tasks with desired time stamps.task_1=RepTaskOrgTH(do_something,1,second=[0,10,20,30,40,50])# Define multiple arguments for given function at tasktask_2=RepTaskOrgTH(do_anotherthing,2,'test_2',minute=[33,34,36],second=[0,10,20,30,40,50])# Main-loop for other taskswhileTrue:time.sleep(0.001)if__name__=="__main__":main()Other featuresYou can stop and restart task-threads by:# stop tasktask.stop_task()# restart tasktask.restart_task()Information on the set timer are showed by:# show one parameterprint(task.every_year)print(task.every_month)print(task.every_week)print(task.every_weekday)print(task.every_day)print(task.every_hour)print(task.every_minute)print(task.every_second)# show all set parametersprint(task.set_time)By default, the Libary uses the current system time. You can set a UTC-time-offset by:# UTCtask_1=RepTaskOrg(second=[0,10,20,30,40,50],offset_hour=0,offset_minute=0)task_2=RepTaskOrgTH(do_something,1,second=[0,10,20,30,40,50],offset_hour=0,offset_minute=0)# United States (Pacific Time Zone) = UTC -08:00task_3=RepTaskOrg(second=[0,10,20,30,40,50],offset_hour=-8,offset_minute=0)task_4=RepTaskOrgTH(do_something,1,second=[0,10,20,30,40,50],offset_hour=-8,offset_minute=0)ArgumentsYou can define a task with the arguments in the following chapters.RepTaskOrgArgs:
    year (list, optional): valid year. Defaults to None.
    month (list, optional): valid month. Defaults to None.
    week (set, optional): valide week. Defaults to None.
    weekday (set, optional): valide day of week. Defaults to None.
    day (list, optional): valid day. Defaults to None.
    hour (list, optional): valid hours. Defaults to None.
    minute (list, optional): valid minute. Defaults to None.
    second (list, optional): valid second. Defaults to None.
    offset_hour (int, optional): valide hour for offset. Defaults to 0.
    offset_minute (int, optional): valide minute for offset. Defaults to 0.RepTaskOrgTHArgs:
    function (function): function to execute.
    function_arguments (tuple): parameters of the given function.
    year (set, optional): valid year. Defaults to None.
    month (set, optional): valid month. Defaults to None.
    week (set, optional): valide week. Defaults to None.
    weekday (set, optional): valide day of week. Defaults to None.
    day (set, optional): valid day. Defaults to None.
    hour (set, optional): valid hour. Defaults to None.
    minute (set, optional): valid minute. Defaults to None.
    second (set, optional): valid second. Defaults to None.
    offset_hour (int, optional): valide hour for offset. Defaults to 0.
    offset_minute (int, optional): valide minute for offset. Defaults to 0.Release Notes1.0.1Fix typoCheck current run-statusTesting implemented1.0.0Stable ReleaseException TimemachineError introducedMinor changes of the documentation in the code0.2.3Show all set parameters with task.set_timer0.2.2Bugfix if only weekday was setIntroduction weeks as argument0.2.1Introduction weekday as argument0.2Introduction UTC - offset as argument0.1.1Revision of the documentation0.1Initial releaseMIT LicenseCopyright (c) 2021 Cedric Klimt