Skip to content

Commit

Permalink
Skip internet check after 5 tries
Browse files Browse the repository at this point in the history
  • Loading branch information
suchmememanyskill committed Aug 12, 2024
1 parent 56cb497 commit f5609b9
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

ALWAYS_RUN_SERVER = False
IS_STANDALONE = False
GOOGLE_PING_COUNT = 0

try:
if not store_or_file_config("no_redirect_logs"):
Expand All @@ -28,17 +29,22 @@
SUCCESSFUL_FETCH_THIS_RUN = False

async def fetch_class_mappings(css_translations_path : str, loader : Loader):
global SUCCESSFUL_FETCH_THIS_RUN
global SUCCESSFUL_FETCH_THIS_RUN, GOOGLE_PING_COUNT

if SUCCESSFUL_FETCH_THIS_RUN:
return

try:
socket.setdefaulttimeout(3)
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect(("8.8.8.8", 53))
except:
Log("No internet connection. Not fetching css translations")
return
if GOOGLE_PING_COUNT < 5:
try:
socket.setdefaulttimeout(3)
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect(("8.8.8.8", 53))
except Exception as e:
Log(f"No internet connection. Not fetching css translations. (Error: {str(e)})")
GOOGLE_PING_COUNT += 1
return
else:
Log("Skipping internet check...")


setting = util_store_read("beta_translations")

Expand Down

0 comments on commit f5609b9

Please sign in to comment.