andrewp-as-is / connection.py Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://github42.com/andrewp-as-is/
License: The Unlicense
Home Page: https://github42.com/andrewp-as-is/
License: The Unlicense
from connection import check_connection
ImportError: cannot import name 'check_connection' from 'connection' (/home/nim1com/.local/lib/python3.9/site-packages/connection/init.py)
how do i fix it and why is it appearing?
I have a good idea for making the package better by editing the init.py to this:
import requests
TIMEOUT = 5
URL='http://www.google.com/'
def check(timeout=None, url=None):
"""return True if connection is ok, else False"""
if not timeout:
timeout = TIMEOUT
if not url:
url=URL
try:
requests.get(url=URL, timeout=timeout)
return True
except requests.ConnectionError:
return False
except requests.exceptions.ReadTimeout:
False
return False
Then you can choose url to fetch and the default url is still 'http://www.google.com/' so you can check connection to other urls!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.