From 539039a2830011276e69226fcc5b47be1fccf61c Mon Sep 17 00:00:00 2001 From: cjerrington Date: Tue, 12 May 2020 15:17:48 -0500 Subject: [PATCH] PyPi version 0.0.7 --- .gitignore | 3 +- README.md | 31 ++++++++++++++----- netutils/__init__.py | 72 -------------------------------------------- setup.py | 6 ++-- 4 files changed, 29 insertions(+), 83 deletions(-) delete mode 100644 netutils/__init__.py diff --git a/.gitignore b/.gitignore index 6136fa7..6aff19e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build/ dist/ -netutils.egg-info \ No newline at end of file +netutil.egg-info +.pypirc \ No newline at end of file diff --git a/README.md b/README.md index cf28816..02a478e 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,34 @@ -# netutils +# netutil - Checking Port Status -Python module to check the status of ports for local and websites. +Python module to check the status of ports for local and websites the easy way. # Install -pip install netutils +```shell +pip install netutil +``` # Usage ```python -import netutils -google = netutils.PortCheck("google.com", 443) -google.isOpen() +import netutil +google = netutil.PortCheck("google.com", 443) +print(google.domain) +print(google.port) +print(google.isOpen()) +``` + +This will show: +```shell +google.com +443 +True ``` +Check out the tests\main.py for more examples. + For extra help I've added in variables to find the hostname and local IP address. - To get hostname: netutils.host_name -- To get Local IP: netutils.host_ip \ No newline at end of file +- To get Local IP: netutils.host_ip + +# Links +- [PyPi](https://pypi.org/project/netutil/) +- [GitHub](https://github.com/cjerrington/netutils) \ No newline at end of file diff --git a/netutils/__init__.py b/netutils/__init__.py deleted file mode 100644 index e14f7a9..0000000 --- a/netutils/__init__.py +++ /dev/null @@ -1,72 +0,0 @@ -import socket, time - - -__all__ = ['netutils'] -__version__ = "0.0.6" -__author__ = "Clayton Errington" - - -class PortCheck: - def __init__(self, domain, port): - self.domain = domain - self.port = port - self.retry = 1 - self.delay = 5 - self.timeout = 3 - - - def __call__(self, domain, port): - self.domain = domain - self.port = port - - - def checkOpen(self): - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.settimeout(self.timeout) - try: - s.connect((self.domain, int(self.port))) - s.shutdown(socket.SHUT_RDWR) - s.close() - return True - except: - return False - finally: - s.close() - - - def checkHost(self): - ipup = False - for i in range(self.retry): - if self.checkOpen(): - ipup = True - break - else: - time.sleep(self.delay) - return ipup - - - def isOpen(self): - if self.checkHost(): - # If connects, then we are true - return True - else: - # If connection fails, we are false - return False - - - def domain(self): - # Allow for domain to be returned - return self.domain - - - def port(self): - # Allow for port to be returned - return self.port - - -# return variables for use -host_name = socket.gethostname() -host_ip = socket.gethostbyname(host_name) -isOpen = PortCheck.isOpen -domain = PortCheck.domain -port = PortCheck.port \ No newline at end of file diff --git a/setup.py b/setup.py index 523a18a..535e1d2 100644 --- a/setup.py +++ b/setup.py @@ -4,14 +4,14 @@ long_description = fh.read() setuptools.setup( - name="netutils", - version="0.0.6", + name="netutil", + version="0.0.7", author="Clayton Errington", author_email="me@claytonerrington.com", description="Simplified way to get networking port status", long_description=long_description, long_description_content_type="text/markdown", - url="https://github.com/pypa/sampleproject", + url="https://github.com/cjerrington/netutils", packages=setuptools.find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), classifiers=[ "Programming Language :: Python :: 3",