mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 12:33:03 +00:00
add telemetry using posthog
+ move build variables into a python file + rewrite logic to check if there's an internet connection + move IS_BUILD into settings + update pyintaller to 6.0.0 + update other packages to latest
This commit is contained in:
+10
-12
@@ -1,19 +1,18 @@
|
||||
import requests
|
||||
import socket as Socket
|
||||
|
||||
|
||||
class Ping:
|
||||
def has_connection(host="8.8.8.8", port=53, timeout=3):
|
||||
"""
|
||||
Checks if there is a connection to the internet by pinging google.com
|
||||
Host: 8.8.8.8 (google-public-dns-a.google.com)
|
||||
OpenPort: 53/tcp
|
||||
Service: domain (DNS/TCP)
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def __call__() -> bool:
|
||||
try:
|
||||
requests.get("https://google.com", timeout=10)
|
||||
return True
|
||||
except (requests.exceptions.ConnectionError, requests.Timeout):
|
||||
return False
|
||||
try:
|
||||
Socket.setdefaulttimeout(timeout)
|
||||
Socket.socket(Socket.AF_INET, Socket.SOCK_STREAM).connect((host, port))
|
||||
return True
|
||||
except Socket.error as ex:
|
||||
return False
|
||||
|
||||
|
||||
def get_ip():
|
||||
@@ -26,4 +25,3 @@ def get_ip():
|
||||
soc.close()
|
||||
|
||||
return ip_address
|
||||
|
||||
|
||||
Reference in New Issue
Block a user