Skip to content

Commit

Permalink
Remove timezone warning by setting tz in cron-trigger. (#8)
Browse files Browse the repository at this point in the history
* Remove timezone warning by setting tz in cron-trigger.

* 🎨 Format Python code with psf/black (#9)

Co-authored-by: Johannes11833 <Johannes11833@users.noreply.github.com>

Co-authored-by: Johannes11833 <Johannes11833@users.noreply.github.com>
  • Loading branch information
Johannes11833 and Johannes11833 authored Nov 14, 2022
1 parent 02e5b56 commit 04d6db4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/.env
/data/
/output/
/.idea/
/.venv/
**.pyc
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def main(force_update: bool = False):
ts = TimeScheduler()
if config["ILIAS_DOWNLOADER_UPLOAD_TIMES"] is not None:
upload_times = config["ILIAS_DOWNLOADER_UPLOAD_TIMES"].split()
logging.info(f"Scheduling daily event(s) @ {upload_times}")
logging.info(f"Scheduling daily event(s) @ {', '.join(upload_times)}")

for t in upload_times:
ts.add(DailyTask(t, download_ilias_data))
Expand Down
11 changes: 9 additions & 2 deletions scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import logging
from typing import Dict, Callable
from abc import ABC, abstractmethod

import tzlocal
from dateutil import tz

from apscheduler.schedulers.background import BackgroundScheduler
Expand All @@ -20,7 +22,6 @@ def __init__(self, function: Callable, args: Dict | None = None) -> None:

@abstractmethod
def create_trigger(self) -> CronTrigger:

return NotImplemented


Expand All @@ -35,7 +36,12 @@ def __init__(

def create_trigger(self) -> CronTrigger:
t = datetime.time.fromisoformat(self.target_time)
return CronTrigger(hour=t.hour, minute=t.minute, second=t.second)
return CronTrigger(
hour=t.hour,
minute=t.minute,
second=t.second,
timezone=str(tzlocal.get_localzone()),
)


class SingularTask(Task):
Expand All @@ -58,6 +64,7 @@ def create_trigger(self) -> CronTrigger:
hour=self.target_time.hour,
minute=self.target_time.minute,
second=self.target_time.second,
timezone=str(tzlocal.get_localzone()),
)


Expand Down
2 changes: 1 addition & 1 deletion setup_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setup_ilias_downloader(logging, exec_path: Path):
elif (unix_like() and Path(exec_path, "KIT-ILIAS-downloader").is_file()) or (
not unix_like() and Path(exec_path, "KIT-ILIAS-downloader.exe").is_file()
):
print(f"KIT-ILIAS-downloader executable found (Unix = {unix_like()}).")
logging.info(f"KIT-ILIAS-downloader executable found (Unix = {unix_like()}).")
return

# get the newest release of the KIT-ILIAS-downloader through the GitHub api.
Expand Down

0 comments on commit 04d6db4

Please sign in to comment.