Добавлена возможность установки таймера
parent
9d2d66a40f
commit
9710fd0df9
|
@ -223,6 +223,8 @@ if __name__ == "__main__":
|
||||||
PATH_SCV = "List_groups.csv"
|
PATH_SCV = "List_groups.csv"
|
||||||
|
|
||||||
SEARCH_FREE_SAMBA = "dc=lenenergo,dc=ru"
|
SEARCH_FREE_SAMBA = "dc=lenenergo,dc=ru"
|
||||||
|
TIME_RUN = "13:43"
|
||||||
|
|
||||||
|
|
||||||
def run_script():
|
def run_script():
|
||||||
logging.info("> Run script <")
|
logging.info("> Run script <")
|
||||||
|
@ -254,16 +256,22 @@ if __name__ == "__main__":
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
|
|
||||||
|
|
||||||
scheduler = sched.scheduler(time.time, time.sleep)
|
def time_run(hour:int, minuts:int):
|
||||||
# задание времени выполнения функции
|
if isinstance(hour, int) and isinstance(minuts, int) is False:
|
||||||
event_time = datetime.datetime.now().replace(hour=12, minute=36, second=0, microsecond=0)
|
raise "Type error hour and minute is not int !!!!!"
|
||||||
# добавление задания в планировщик
|
try:
|
||||||
scheduler.enterabs(event_time.timestamp(), 1, run_script, ())
|
logging.info(f" -> The launch will be every day in {hour}:{minuts} <-")
|
||||||
# запуск планировщика
|
while True:
|
||||||
while True:
|
time.sleep(1)
|
||||||
try:
|
z = time.localtime()
|
||||||
scheduler.run()
|
if z.tm_hour == hour and z.tm_min == minuts and z.tm_sec == 0:
|
||||||
time.sleep(0.5)
|
logging.info(f"-> Run time {hour}:{minuts}")
|
||||||
except KeyboardInterrupt:
|
run_script()
|
||||||
print("exit")
|
logging.info(f" -> The launch will be every day in {hour}:{minuts} <-")
|
||||||
break
|
except KeyboardInterrupt:
|
||||||
|
logging.warning("ctr+c")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
|
||||||
|
time_data = TIME_RUN.split(":")
|
||||||
|
time_run(int(time_data[0]), int(time_data[1]))
|
||||||
|
|
Loading…
Reference in New Issue