Skip to content

Commit

Permalink
Merge pull request #2455 from pyrevitlabs/fix/check_connection
Browse files Browse the repository at this point in the history
Update updater.py
  • Loading branch information
jmcouffin authored Nov 10, 2024
2 parents 0283bcb + 9fea0ba commit 2730052
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pyrevitlib/pyrevit/versionmgr/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pyrevit.userconfig import user_config
from pyrevit.extensions import extensionmgr

from System.Net.NetworkInformation import Ping, IPStatus
import socket

#pylint: disable=C0103,W0703
logger = get_logger(__name__)
Expand All @@ -30,13 +30,15 @@
'</div>'


def _check_connection(ip_address="8.8.8.8"):
ping_sender = Ping()
def _check_connection(host="8.8.8.8", port=53, timeout=3):
try:
reply = ping_sender.Send(ip_address)
except Exception:
socket.setdefaulttimeout(timeout)
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
logger.debug('Internet access detected.')
return True
except socket.error as ex:
logger.debug('No internet access detected. %s', ex)
return False
return reply.Status == IPStatus.Success


def _get_extension_credentials(repo_info):
Expand Down

0 comments on commit 2730052

Please sign in to comment.