-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import ipaddress as ip | ||
import typing | ||
import asyncio | ||
|
||
from findssh.coro import isportopen | ||
|
||
|
||
async def as_completed(net: ip.IPv4Network, | ||
port: int, | ||
service: str, | ||
timeout: float) -> typing.List[typing.Tuple[ip.IPv4Address, str]]: | ||
futures = [isportopen(host, port, service) for host in net.hosts()] | ||
hosts = [] | ||
for future in asyncio.as_completed(futures, timeout=timeout): | ||
try: | ||
res = await future | ||
except asyncio.TimeoutError: | ||
continue | ||
|
||
if res is not None: | ||
print(*res) | ||
hosts.append(res) | ||
return hosts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
import pytest | ||
import subprocess | ||
import shutil | ||
|
||
matlab = shutil.which('matlab') | ||
|
||
|
||
@pytest.mark.skipif(matlab is None, reason='Matlab not found') | ||
def test_matlab(): | ||
no_python = subprocess.run([matlab, '-batch', 'exit(isempty(pyversion))'], timeout=60).returncode | ||
|
||
if no_python: | ||
pytest.skip('python not setup in Matlab') | ||
|
||
ret = subprocess.check_output([matlab, '-batch', 'findssh'], | ||
universal_newlines=True, timeout=60) | ||
print(ret) | ||
|
||
|
||
if __name__ == '__main__': | ||
pytest.main(['-s', __file__]) |