MCPcopy Create free account
hub / github.com/InternScience/SciReason / check_url_accessibility

Function check_url_accessibility

opencompass/utils/network.py:119–142  ·  view source on GitHub ↗

Check if a specific URL is accessible through optional proxy. Args: url: str, target URL to check timeout: float, timeout in seconds (default: 3) proxies: Optional[Dict[str, str]], proxy configuration (default: None) Example: { 'http': 'http:/

(
        url: str,
        timeout: float = 3,
        proxies: Optional[Dict[str,
                               str]] = None)

Source from the content-addressed store, hash-verified

117
118
119def check_url_accessibility(
120 url: str,
121 timeout: float = 3,
122 proxies: Optional[Dict[str,
123 str]] = None) -> Tuple[bool, Optional[int]]:
124 """Check if a specific URL is accessible through optional proxy.
125
126 Args:
127 url: str, target URL to check
128 timeout: float, timeout in seconds (default: 3)
129 proxies: Optional[Dict[str, str]], proxy configuration (default: None)
130 Example: {
131 'http': 'http://proxy:8080',
132 'https': 'https://proxy:8080'}
133
134 Returns:
135 Tuple[bool, Optional[int]]: (is_accessible, status_code)
136 """
137 try:
138 response = requests.get(url, timeout=timeout, proxies=proxies)
139 return True, response.status_code
140 except requests.RequestException as e:
141 logger.error(f'Failed to access URL {url}: {str(e)}')
142 return False, None

Callers 1

scoreMethod · 0.90

Calls 1

getMethod · 0.80

Tested by

no test coverage detected