Skip to content

Commit

Permalink
add macOS support
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Aug 30, 2019
1 parent b082761 commit 91b7b7f
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 65 deletions.
35 changes: 28 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,45 @@
language: python
matrix:
include:
- python: 2.7
- os: osx
language: generic
env: TOXENV=py3
- os: linux
python: 2.7
env: TOXENV=py27
- python: 3.3
env: TOXENV=py33
- python: 3.4
- os: linux
python: 3.4
env: TOXENV=py34
- python: 3.5
- os: linux
python: 3.5
env: TOXENV=py35
- python: 3.6
- os: linux
python: 3.6
env: TOXENV=py36
- os: linux
python: 3.7
env: TOXENV=py37
dist: xenial
- os: linux
python: 3.8-dev
env: TOXENV=py38
dist: xenial
- os: windows
language: minimal
env: TOXENV=py3
before_install:
- choco install python3
- export PATH="/c/Python37:/c/Python37/Scripts:$PATH"


# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install:
- sudo apt-get install iputils-ping
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install iputils-ping; fi
- pip install -U tox
- pip install tox codecov coveralls
- pip install -r requirements.txt
- pip install pytest-cov
- if [[ $TRAVIS_PYTHON_VERSION == 3.3 ]]; then pip install virtualenv==15.2.0 tox==3.1.3; fi

# command to run tests, e.g. python setup.py test
script:
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Reads IP addresses and domains from a CSV file and gives two lists of accessible
- output - `json` or `csv`

## Support
- Currently Windows and Linux are supported.
- Windows, Linux and macOS are supported.
- Supports both IPv4 and IPv6 IPs, and domain names.
```csv
# Examples
Expand All @@ -39,21 +39,21 @@ $ pip install ippy
## Usage
```python
# Create IPpy instance
ippt = ippy.Ippy()
ippy_obj = ippy.Ippy()

# Set config - verbose, output, num_workers
# verbose - True or False
# output - csv or json
ippt.set_config(True, 'csv', 4)
ippy_obj.set_config(True, 'csv', 4)

# Set Input File
ippt.set_file(file='ip_list.csv')
ippy_obj.set_file(file='ip_list.csv')

# Run IPpy
ippt.run()
ippy_obj.run()

# Get Results
output = ippt.result()
output = ippy_obj.result()
print(output)
```
## Tests
Expand Down
10 changes: 5 additions & 5 deletions examples/example1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@


def main():
ippt = ippy.Ippy()
ippt.set_config(True, 'csv', 4)
ippt.set_file(file='ip_list.csv')
ippt.run()
output = ippt.result()
ippy_obj = ippy.Ippy()
ippy_obj.set_config(True, 'csv', 4)
ippy_obj.set_file(file='ip_list.csv')
ippy_obj.run()
output = ippy_obj.result()
print(output)

if __name__ == "__main__":
Expand Down
10 changes: 5 additions & 5 deletions examples/example2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@


def main():
ippt = ippy.Ippy()
ippt.set_config(True, 'json', 4)
ippt.set_file(file='ip_list.csv')
ippt.run()
output = ippt.result()
ippy_obj = ippy.Ippy()
ippy_obj.set_config(True, 'json', 4)
ippy_obj.set_file(file='ip_list.csv')
ippy_obj.run()
output = ippy_obj.result()
print(output)

if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion ippy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

__author__ = """Shivam Mathur"""
__email__ = 'shivam_jpr@hotmail.com'
__version__ = '0.3.2'
__version__ = '0.3.3'

from .ippy import Ippy
2 changes: 2 additions & 0 deletions ippy/ippy.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def get_ping_args(platform_os=None):
ping_args = ["ping", "-n", "2", "-l", "1", "-w", "2000"]
elif plat == "Linux":
ping_args = ["ping", "-c", "2", "-l", "1", "-s", "1", "-W", "2"]
elif plat == "Darwin":
ping_args = ["ping", "-c", "2", "-l", "1", "-s", "1", "-W", "2000"]
else:
raise ValueError("Unknown platform")

Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@

pingparsing>=0.6.0

future>=0.16.0
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.3.2
current_version = 0.3.3
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

setup(
name='ippy',
version='0.3.2',
version='0.3.3',
description="Parallel testing of IP addresses and domains in python.",
author="Shivam Mathur",
author_email='shivam_jpr@hotmail.com',
Expand Down
74 changes: 37 additions & 37 deletions tests/test_ippy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,80 +24,80 @@


def test_config():
ippt = ippy.Ippy()
ippt.set_config(verbose_mode=False, output_mode='csv', num_workers=10)
ippy_obj = ippy.Ippy()
ippy_obj.set_config(verbose_mode=False, output_mode='csv', num_workers=10)

assert ippt.verbose is False
assert ippt.output == 'csv'
assert ippt.num_workers == 10
assert ippy_obj.verbose is False
assert ippy_obj.output == 'csv'
assert ippy_obj.num_workers == 10


def test_set_file():
ippt = ippy.Ippy()
ippy_obj = ippy.Ippy()
with pytest.raises(Exception):
ippt.set_file()
ippt.set_file('testfile')
ippy_obj.set_file()
ippy_obj.set_file('testfile')

assert ippt.file == 'testfile'
assert ippy_obj.file == 'testfile'


def test_ping_args():
ippt = ippy.Ippy()
ippy_obj = ippy.Ippy()

ping_args = ippt.get_ping_args("Windows")
ping_args = ippy_obj.get_ping_args("Windows")
assert ping_args == ["ping", "-n", "2", "-l", "1", "-w", "2000"]

ping_args = ippt.get_ping_args("Linux")
ping_args = ippy_obj.get_ping_args("Linux")
assert ping_args == ["ping", "-c", "2", "-l", "1", "-s", "1", "-W", "2"]

with pytest.raises(ValueError):
ippt.get_ping_args('Test')
ippy_obj.get_ping_args('Test')


def test_filepath():
ippt = ippy.Ippy()
ippy_obj = ippy.Ippy()
with pytest.raises(Exception):
ippt.get_filepath()
ippy_obj.get_filepath()

ippt.set_file('testfile')
file_path = ippt.get_filepath()
ippy_obj.set_file('testfile')
file_path = ippy_obj.get_filepath()

assert file_path == os.path.join(sys.path[0], "testfile")


def test_run():
ippt = ippy.Ippy()
ippt.set_config(True, 'csv', 10)
ippt.set_file(file='ip_list.csv')
ippt.run()
ippy_obj = ippy.Ippy()
ippy_obj.set_config(True, 'csv', 10)
ippy_obj.set_file(file='ip_list.csv')
ippy_obj.run()

assert property(ippt.get_accessible) is not None
assert property(ippt.get_not_accessible) is not None
assert property(ippt.get_results) is not None
assert property(ippy_obj.get_accessible) is not None
assert property(ippy_obj.get_not_accessible) is not None
assert property(ippy_obj.get_results) is not None


def test_empty_result():
ippt = ippy.Ippy()
ippt.set_config(False, 'test', 10)
ippt.set_file(file='ip_list.csv')
ippt.run()
ippy_obj = ippy.Ippy()
ippy_obj.set_config(False, 'test', 10)
ippy_obj.set_file(file='ip_list.csv')
ippy_obj.run()
with pytest.raises(ValueError):
ippt.result()
ippy_obj.result()


def test_json_result():
ippt = ippy.Ippy()
ippt.set_config(False, 'json', 10)
result = ippt.result()
ippy_obj = ippy.Ippy()
ippy_obj.set_config(False, 'json', 10)
result = ippy_obj.result()
assert json.loads(result) is not None


def test_csv_result():
ippt = ippy.Ippy()
ippt.set_config(False, 'csv', 10)
ippt.set_file(file='ip_list.csv')
ippt.run()
result = ippt.result()
ippy_obj = ippy.Ippy()
ippy_obj.set_config(False, 'csv', 10)
ippy_obj.set_file(file='ip_list.csv')
ippy_obj.run()
result = ippy_obj.result()
my_result = StringIO(result)
my_reader = reader(my_result, delimiter=str(','))
csv_result = ''
Expand Down

0 comments on commit 91b7b7f

Please sign in to comment.