Skip to content

Commit

Permalink
use __main__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Mar 12, 2020
1 parent 6f80043 commit 0b45dde
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 24 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ on:
paths:
- "**.py"
pull_request:
paths:
- "**.py"
release:

jobs:

Expand All @@ -21,9 +20,13 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- run: pip install .[tests,lint]

- run: flake8
- run: mypy .

- run: pytest
- run: findssh


integration:
runs-on: ${{ matrix.os }}
Expand All @@ -35,5 +38,8 @@ jobs:
- uses: actions/setup-python@v1
with:
python-version: '3.x'

- run: pip install .[tests]

- run: pytest
- run: findssh
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ Although speed advantages weren't seen in our testing, `findssh` works with PyPy

## Install

Just run `FindSSH.py` directly.
To allow use from other programs, you can install by:

```sh
pip install findssh
```
Expand All @@ -40,6 +37,12 @@ from command line:
findssh
```

or

```sh
python -m findssh
```

### Command line options

* `-s` check the string from the server to attempt to verify the correct service has been found
Expand Down
11 changes: 5 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = findssh
version = 1.3.1
version = 1.4.0
author = Michael Hirsch, Ph.D.
author_email = [email protected]
url = https://github.com/scivision/findssh
Expand Down Expand Up @@ -37,15 +37,17 @@ python_requires = >= 3.5
packages = find:
zip_safe = False
include_package_data = True
scripts =
FindSSH.py
install_requires =
package_dir=
=src

[options.packages.find]
where=src

[options.entry_points]
console_scripts =
findssh = findssh.__main__:main

[options.extras_require]
tests =
pytest
Expand All @@ -56,9 +58,6 @@ lint =
flake8-blind-except
mypy

[options.entry_points]
console_scripts =
findssh = FindSSH:main

[flake8]
max-line-length = 132
Expand Down
1 change: 1 addition & 0 deletions src/findssh/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .coro import get_hosts
from .base import netfromaddress, getLANip
from .runner import runner
12 changes: 6 additions & 6 deletions FindSSH.py → src/findssh/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import ipaddress as ip
from argparse import ArgumentParser

from findssh.base import getLANip, netfromaddress
from findssh.runner import runner
import findssh.coro as coro
import findssh.threadpool as threadpool
from .base import getLANip, netfromaddress
from .runner import runner
from .coro import get_hosts as coro_get_hosts
from .threadpool import get_hosts as threadpool_get_hosts

PORT = 22
TIMEOUT = 1.0
Expand Down Expand Up @@ -50,9 +50,9 @@ def main():
print("searching", net)

if P.threadpool or isinstance(net, ip.IPv6Network):
hosts = threadpool.get_hosts(net, P.port, P.service, P.timeout, debug=P.verbose)
hosts = threadpool_get_hosts(net, P.port, P.service, P.timeout, debug=P.verbose)
else:
hosts = runner(coro.get_hosts, net, P.port, P.service, P.timeout)
hosts = runner(coro_get_hosts, net, P.port, P.service, P.timeout)

for host, svc in hosts:
print(host, svc)
Expand Down
8 changes: 1 addition & 7 deletions src/findssh/tests/test_coro.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
#!/usr/bin/env python
import pytest
import subprocess
import ipaddress

import findssh
from findssh.runner import runner

PORT = 22
SERVICE = ""
TIMEOUT = 1.0


def test_script():
subprocess.check_call(["FindSSH"])


def test_coroutine():
net = findssh.netfromaddress(findssh.getLANip())
hosts = runner(findssh.get_hosts, net, PORT, SERVICE, TIMEOUT)
hosts = findssh.runner(findssh.get_hosts, net, PORT, SERVICE, TIMEOUT)
if len(hosts) > 0:
host = hosts[0]
assert isinstance(host[0], ipaddress.IPv4Address)
Expand Down

0 comments on commit 0b45dde

Please sign in to comment.