mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-01-25 16:33:20 +08:00
moved efro.net functionality into efro.error
This commit is contained in:
parent
21d5cc28c0
commit
dde4f69d22
@ -3937,50 +3937,50 @@
|
||||
"assets/src/ba_data/python/ba/_generated/__init__.py": "https://files.ballistica.net/cache/ba1/ee/e8/cad05aa531c7faf7ff7b96db7f6e",
|
||||
"assets/src/ba_data/python/ba/_generated/enums.py": "https://files.ballistica.net/cache/ba1/72/82/86956fae909ac2fe2a1abd84a361",
|
||||
"ballisticacore-windows/Generic/BallisticaCore.ico": "https://files.ballistica.net/cache/ba1/89/c0/e32c7d2a35dc9aef57cc73b0911a",
|
||||
"build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/99/5f/402d8ccede14cf3662b749196a35",
|
||||
"build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/70/e0/d1f6e02c19b18f3d02b474e9d9c0",
|
||||
"build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/74/1d/fc9e33e565475daaac80da5252f0",
|
||||
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/6b/8b/ebc856f3100c32c790b06facf231",
|
||||
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/f2/0a/e33dba2bd26d802839993bc9e2d4",
|
||||
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/cf/e3/042b1f2d634aa6d61e361eeba41f",
|
||||
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/19/f5/83c7bb76dc79020ded2e53f25e09",
|
||||
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/6d/fb/51437a1f97e5cf466595e9b433c5",
|
||||
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/af/a4/09ce2c2cd53f46338e838958c58d",
|
||||
"build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/9c/7b/ac1a200be0f37078af0991faca3b",
|
||||
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b6/a7/76a39b05d1db2d49dc3335679573",
|
||||
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/79/56/a1576a8bee94a47cdd633aa86a3b",
|
||||
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/a3/47/4f0897f4a30b2f22ce9ee73f24d0",
|
||||
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/6a/b2/0d7498cfc3fd49dd4bdf64b22b11",
|
||||
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ec/ed/434ff203ce89602bd395944d33fe",
|
||||
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/6d/2f/c4cc9c7cb4589a50faf7db7f4c05",
|
||||
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/f6/99/b27c665fcf9f8548abf3f162a736",
|
||||
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/f6/e2/a712749d266aa8e6c6dade74f08d",
|
||||
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c2/70/3de0ba133d288111ae3fc386fbf5",
|
||||
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/0a/b8/9e6a5d93f61e30f817dc76fbe2e5",
|
||||
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/fa/2a/6b1a7111628941ff45a4bb6d941d",
|
||||
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/6c/3d/6d0a3cbe3ac46e43eb19ed30dcc6",
|
||||
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/59/2c/fd6ddf8cceee5900d68cd3da0435",
|
||||
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/a1/08/219321b9f73ebcd7e207587a7c14",
|
||||
"build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/1e/ef/7a8262418694d65b440984bd7a6e",
|
||||
"build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/70/93/b15380a02bb72a52a2b9f655f482",
|
||||
"build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/80/b2/9bb276e33ecbcc44d6a36d7cfcf5",
|
||||
"build/prefab/lib/linux_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/44/56/44ffa9866e2df7cf3545e2b93ee8",
|
||||
"build/prefab/lib/linux_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/5f/b0/4cd12e393365fb35409aa9296d3c",
|
||||
"build/prefab/lib/linux_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/3f/64/949588e4db6f5958bcd8f92e1da8",
|
||||
"build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/04/e6/2d4a50696f8e8c63d88fe099e5bf",
|
||||
"build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/62/d9/475a8f5f0300a33ce98b2bff5ca1",
|
||||
"build/prefab/lib/mac_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/f0/93/4846540264e3d4bd459f1c2cc5d1",
|
||||
"build/prefab/lib/mac_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/53/e9/7590d921630f3bf7e2b4033399d7",
|
||||
"build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/d7/96/8bd45dfb6ca6ddcd6ea72452df1d",
|
||||
"build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/8b/50/112bedfb0231ddd07f99af277600",
|
||||
"build/prefab/lib/mac_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/51/d8/2fe4ba3f4cbc99e3ae34589bd80d",
|
||||
"build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/fb/af/0523542964b3308114ff6fc40359",
|
||||
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/50/a7/6993a6a8e83d3d21f95209c93c9b",
|
||||
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/cf/e7/54d0c8f1460901fa217ffaf51663",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/6a/8e/37e1468bbdc68e6fae9336f18eb7",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/98/b7/4a2cda209924e0a7015d64812a34",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/d0/2d/1c59860ba3367e21b05340cd29c2",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/46/79/7113c0a9f1507bf83cf3c09d9e22",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/ba/60/50b6aa57af123014ed571e554164",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/9a/e9/5c01cec33f278b0f12c34cab37da",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/70/7b/3a749f597894ce7a78c062aa9179",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/63/5c/770f212a9653106111cfa50416ba",
|
||||
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/9c/4f/9b9276e8e2bf0d222ad1ee63a181",
|
||||
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/f5/80/5c0ddcd973674081a7d7abf71069",
|
||||
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/0c/6e/5910f4a9fd3cfab4464ddcc88557",
|
||||
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/c6/6f/d83b7dccd42e270e4e5cca582906",
|
||||
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b7/19/c2ac8cc74bbde244b762f6390757",
|
||||
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/14/64/3009cfea9985b63982bee437144b",
|
||||
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/bd/bf/d299472cdbe1778fc6bc6f6ca3cf",
|
||||
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/86/ec/8b92f4db81024cc3ba44ef6b8070",
|
||||
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/01/a3/7dd46627ff5606234eafa4cb37b8",
|
||||
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/85/73/eba334a349abc12cb873e1a45909",
|
||||
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/f2/92/d170f89127ce918ba89a8dfcde22",
|
||||
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/f5/f3/bc57353da277776fc7a923b27ae5",
|
||||
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/b7/c5/8e0d736ecd4eb1ca6a18e2b5bff4",
|
||||
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/84/de/d90837982093b0b5b2dd5a71e304",
|
||||
"build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/50/ae/d0dac8641dd0cddaf7eeb0c6d6bb",
|
||||
"build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/8c/e9/31e77a3d8ccf147372b30ca2005c",
|
||||
"build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/8c/86/edc44ed5f9206a9d538eaa39bb5e",
|
||||
"build/prefab/lib/linux_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ba/ca/4726eca2dc89e1f1faf08f34b635",
|
||||
"build/prefab/lib/linux_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/6d/46/1860beb33402ee3463e5870ffc6d",
|
||||
"build/prefab/lib/linux_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7a/17/1d6af884c0a77e339a888015fccd",
|
||||
"build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/fb/5e/f71252314b595fa089a70e84ae7d",
|
||||
"build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/5f/af/4029a33987647c355e8ea16ac327",
|
||||
"build/prefab/lib/mac_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/0f/bf/7feceed4f45860593f5abd547ef5",
|
||||
"build/prefab/lib/mac_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a4/ac/c9ab19889af2af351c35bbcc2ca6",
|
||||
"build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/bb/6d/3f795483eecf3b02b175d4e3ae95",
|
||||
"build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/59/5d/6c2a2faf66ce5cd37efbbd4ee531",
|
||||
"build/prefab/lib/mac_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/3b/73/083f29cf270f3701aee5d27fea70",
|
||||
"build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/51/21/ec73bfd77df70ff4d06ca2892505",
|
||||
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/dd/c4/76f367fa1cea9c720e79056afd20",
|
||||
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/58/90/dedfb364379229d8c64848b9435c",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/2b/50/7719ce17c926c2e77cfd86227b8f",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/4d/6e/07d81f2ecd4c6681d12f02bc4260",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/d5/dc/2b96b0f2dfaba1d9ff028105c2d6",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/6d/1c/b0965cabbdd209b35d24ceef4a31",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/37/86/b69055de8eb73e66505869ceec01",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/d6/07/430dbb5c7138fd972923bd495ae4",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/81/ba/ab192931bda7f54f09d4c4ab5ca1",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/65/d4/2ee62ace0f8b6b362fb1f4570af8",
|
||||
"src/ballistica/generated/python_embedded/binding.inc": "https://files.ballistica.net/cache/ba1/6c/63/2b8cbb65a0e1daa45d59e9f87e9a",
|
||||
"src/ballistica/generated/python_embedded/bootstrap.inc": "https://files.ballistica.net/cache/ba1/c0/2f/a8b50faad086fba4fe936e863c20"
|
||||
}
|
||||
@ -498,7 +498,6 @@
|
||||
"ba_data/python/efro/__pycache__/call.cpython-38.opt-1.pyc",
|
||||
"ba_data/python/efro/__pycache__/error.cpython-38.opt-1.pyc",
|
||||
"ba_data/python/efro/__pycache__/message.cpython-38.opt-1.pyc",
|
||||
"ba_data/python/efro/__pycache__/net.cpython-38.opt-1.pyc",
|
||||
"ba_data/python/efro/__pycache__/terminal.cpython-38.opt-1.pyc",
|
||||
"ba_data/python/efro/__pycache__/util.cpython-38.opt-1.pyc",
|
||||
"ba_data/python/efro/call.py",
|
||||
@ -518,7 +517,6 @@
|
||||
"ba_data/python/efro/dataclassio/extras.py",
|
||||
"ba_data/python/efro/error.py",
|
||||
"ba_data/python/efro/message.py",
|
||||
"ba_data/python/efro/net.py",
|
||||
"ba_data/python/efro/terminal.py",
|
||||
"ba_data/python/efro/util.py",
|
||||
"server/__pycache__/ballisticacore_server.cpython-38.opt-1.pyc",
|
||||
|
||||
@ -652,7 +652,6 @@ SCRIPT_TARGETS_PY_PUBLIC_TOOLS = \
|
||||
build/ba_data/python/efro/dataclassio/extras.py \
|
||||
build/ba_data/python/efro/error.py \
|
||||
build/ba_data/python/efro/message.py \
|
||||
build/ba_data/python/efro/net.py \
|
||||
build/ba_data/python/efro/terminal.py \
|
||||
build/ba_data/python/efro/util.py
|
||||
|
||||
@ -672,7 +671,6 @@ SCRIPT_TARGETS_PYC_PUBLIC_TOOLS = \
|
||||
build/ba_data/python/efro/dataclassio/__pycache__/extras.cpython-38.opt-1.pyc \
|
||||
build/ba_data/python/efro/__pycache__/error.cpython-38.opt-1.pyc \
|
||||
build/ba_data/python/efro/__pycache__/message.cpython-38.opt-1.pyc \
|
||||
build/ba_data/python/efro/__pycache__/net.cpython-38.opt-1.pyc \
|
||||
build/ba_data/python/efro/__pycache__/terminal.cpython-38.opt-1.pyc \
|
||||
build/ba_data/python/efro/__pycache__/util.cpython-38.opt-1.pyc
|
||||
|
||||
|
||||
@ -102,7 +102,7 @@ class MasterServerCallThread(threading.Thread):
|
||||
import urllib.error
|
||||
import json
|
||||
|
||||
from efro.net import is_urllib_network_error
|
||||
from efro.error import is_urllib_network_error
|
||||
from ba import _general
|
||||
try:
|
||||
self._data = _general.utf8_all(self._data)
|
||||
|
||||
@ -706,7 +706,7 @@ class ManualGatherTab(GatherTab):
|
||||
from_other_thread=True,
|
||||
)
|
||||
except Exception as exc:
|
||||
from efro.net import is_udp_network_error
|
||||
from efro.error import is_udp_network_error
|
||||
if is_udp_network_error(exc):
|
||||
ba.pushcall(ba.Call(
|
||||
_safe_set_text, self._checking_state_text,
|
||||
|
||||
@ -219,7 +219,7 @@ class AddrFetchThread(threading.Thread):
|
||||
sock.close()
|
||||
ba.pushcall(ba.Call(self._call, val), from_other_thread=True)
|
||||
except Exception as exc:
|
||||
from efro.net import is_udp_network_error
|
||||
from efro.error import is_udp_network_error
|
||||
# Ignore expected network errors; log others.
|
||||
if is_udp_network_error(exc):
|
||||
pass
|
||||
@ -271,7 +271,7 @@ class PingThread(threading.Thread):
|
||||
ping if accessible else None),
|
||||
from_other_thread=True)
|
||||
except Exception as exc:
|
||||
from efro.net import is_udp_network_error
|
||||
from efro.error import is_udp_network_error
|
||||
if is_udp_network_error(exc):
|
||||
pass
|
||||
else:
|
||||
|
||||
@ -63,3 +63,69 @@ class RemoteError(Exception):
|
||||
def __str__(self) -> str:
|
||||
s = ''.join(str(arg) for arg in self.args)
|
||||
return f'Remote Exception Follows:\n{s}'
|
||||
|
||||
|
||||
def is_urllib_network_error(exc: BaseException) -> bool:
|
||||
"""Is the provided exception from urllib a network-related error?
|
||||
|
||||
This should be passed an exception which resulted from opening or
|
||||
reading a urllib Request. It returns True for any errors that could
|
||||
conceivably arise due to unavailable/poor network connections,
|
||||
firewall/connectivity issues, etc. These issues can often be safely
|
||||
ignored or presented to the user as general 'network-unavailable'
|
||||
states.
|
||||
"""
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
import http.client
|
||||
import errno
|
||||
import socket
|
||||
if isinstance(
|
||||
exc,
|
||||
(urllib.error.URLError, ConnectionError, http.client.IncompleteRead,
|
||||
http.client.BadStatusLine, socket.timeout)):
|
||||
return True
|
||||
if isinstance(exc, OSError):
|
||||
if exc.errno == 10051: # Windows unreachable network error.
|
||||
return True
|
||||
if exc.errno in {
|
||||
errno.ETIMEDOUT,
|
||||
errno.EHOSTUNREACH,
|
||||
errno.ENETUNREACH,
|
||||
}:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def is_udp_network_error(exc: BaseException) -> bool:
|
||||
"""Is the provided exception a network-related error?
|
||||
|
||||
This should be passed an exception which resulted from creating and
|
||||
using a socket.SOCK_DGRAM type socket. It should return True for any
|
||||
errors that could conceivably arise due to unavailable/poor network
|
||||
connections, firewall/connectivity issues, etc. These issues can often
|
||||
be safely ignored or presented to the user as general
|
||||
'network-unavailable' states.
|
||||
"""
|
||||
import errno
|
||||
if isinstance(exc, ConnectionRefusedError):
|
||||
return True
|
||||
if isinstance(exc, OSError):
|
||||
if exc.errno == 10051: # Windows unreachable network error.
|
||||
return True
|
||||
if exc.errno in {
|
||||
errno.EADDRNOTAVAIL,
|
||||
errno.ETIMEDOUT,
|
||||
errno.EHOSTUNREACH,
|
||||
errno.ENETUNREACH,
|
||||
errno.EINVAL,
|
||||
errno.EPERM,
|
||||
errno.EACCES,
|
||||
# Windows 'invalid argument' error.
|
||||
10022,
|
||||
# Windows 'a socket operation was attempted to'
|
||||
# 'an unreachable network' error.
|
||||
10051,
|
||||
}:
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -1,75 +0,0 @@
|
||||
# Released under the MIT License. See LICENSE for details.
|
||||
#
|
||||
"""Network related functionality."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
|
||||
def is_urllib_network_error(exc: BaseException) -> bool:
|
||||
"""Is the provided exception from urllib a network-related error?
|
||||
|
||||
This should be passed an exception which resulted from opening or
|
||||
reading a urllib Request. It returns True for any errors that could
|
||||
conceivably arise due to unavailable/poor network connections,
|
||||
firewall/connectivity issues, etc. These issues can often be safely
|
||||
ignored or presented to the user as general 'network-unavailable'
|
||||
states.
|
||||
"""
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
import http.client
|
||||
import errno
|
||||
import socket
|
||||
if isinstance(
|
||||
exc,
|
||||
(urllib.error.URLError, ConnectionError, http.client.IncompleteRead,
|
||||
http.client.BadStatusLine, socket.timeout)):
|
||||
return True
|
||||
if isinstance(exc, OSError):
|
||||
if exc.errno == 10051: # Windows unreachable network error.
|
||||
return True
|
||||
if exc.errno in {
|
||||
errno.ETIMEDOUT,
|
||||
errno.EHOSTUNREACH,
|
||||
errno.ENETUNREACH,
|
||||
}:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def is_udp_network_error(exc: BaseException) -> bool:
|
||||
"""Is the provided exception a network-related error?
|
||||
|
||||
This should be passed an exception which resulted from creating and
|
||||
using a socket.SOCK_DGRAM type socket. It should return True for any
|
||||
errors that could conceivably arise due to unavailable/poor network
|
||||
connections, firewall/connectivity issues, etc. These issues can often
|
||||
be safely ignored or presented to the user as general
|
||||
'network-unavailable' states.
|
||||
"""
|
||||
import errno
|
||||
if isinstance(exc, ConnectionRefusedError):
|
||||
return True
|
||||
if isinstance(exc, OSError):
|
||||
if exc.errno == 10051: # Windows unreachable network error.
|
||||
return True
|
||||
if exc.errno in {
|
||||
errno.EADDRNOTAVAIL,
|
||||
errno.ETIMEDOUT,
|
||||
errno.EHOSTUNREACH,
|
||||
errno.ENETUNREACH,
|
||||
errno.EINVAL,
|
||||
errno.EPERM,
|
||||
errno.EACCES,
|
||||
# Windows 'invalid argument' error.
|
||||
10022,
|
||||
# Windows 'a socket operation was attempted to'
|
||||
# 'an unreachable network' error.
|
||||
10051,
|
||||
}:
|
||||
return True
|
||||
return False
|
||||
Loading…
x
Reference in New Issue
Block a user