Giter VIP home page Giter VIP logo

connection.py's People

Contributors

andrewp-as-is avatar dr-nugget avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

connection.py's Issues

problem

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?

Make the package better

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.