summaryrefslogtreecommitdiff
path: root/inbox_for_todoist.widget/online.py
diff options
context:
space:
mode:
authorBenjamin Chausse <19275615+ChausseBenjamin@users.noreply.github.com>2018-11-04 18:37:47 -0500
committerGitHub <noreply@github.com>2018-11-04 18:37:47 -0500
commitb600abd2d091dddbd6692b54a7e29962ce047ef9 (patch)
tree0f62064273c41b78b1fe7f31d278409269a31437 /inbox_for_todoist.widget/online.py
parent47864b50790f52544873173780bb40ea1ea3e5bf (diff)
parentac75b762ed0d98ab4bd7ab6c47b1d947c7ee6388 (diff)
Merge pull request #2 from ChausseBenjamin/offline-cache
Offline cache
Diffstat (limited to 'inbox_for_todoist.widget/online.py')
-rw-r--r--inbox_for_todoist.widget/online.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/inbox_for_todoist.widget/online.py b/inbox_for_todoist.widget/online.py
new file mode 100644
index 0000000..6fb471b
--- /dev/null
+++ b/inbox_for_todoist.widget/online.py
@@ -0,0 +1,19 @@
+# -*-coding:utf-8 -*
+from urllib.error import URLError
+import urllib.request
+
+def main():
+ loop_value = 0
+ while loop_value < 5:
+ try:
+ urllib.request.urlopen("http://www.google.com")
+ loop_value = 6 # Loops ends, cant +1 up to 6, online must be true
+ except URLError as e:
+ loop_value += 1 # Loops ends, all attempts are out, online must be false
+ if loop_value == 6:
+ return(True)
+ else:
+ return(False)
+
+if __name__ == '__main__':
+ main()