Skip to content

Commit

Permalink
feat: check for internet connection
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveitaly committed Jun 27, 2023
1 parent dc15f9b commit c3fc729
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions todoist_scheduler/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,21 @@
log_level = os.environ.get("LOG_LEVEL", "INFO")
logger.setLevel(getattr(logging, log_level.upper(), logging.INFO))

def is_internet_connected():
import socket
s = socket.socket(socket.AF_INET)
try:
s.connect(("google.com",80))
return True
except socket.error as e: return False

def apply_todoist_filters(
task_limit, api_key, rules, dry_run, punt_time, default_filter
):
if not is_internet_connected():
print("internet is not connected")
return

api = TodoistAPI(api_key)

if not default_filter:
Expand Down

0 comments on commit c3fc729

Please sign in to comment.