Skip to content

Commit

Permalink
reenable matlab
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Jul 15, 2019
1 parent 7e757d9 commit bc8f187
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
23 changes: 23 additions & 0 deletions archive/coro.py
@@ -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
5 changes: 2 additions & 3 deletions archive/findssh.m → findssh.m
Expand Up @@ -17,9 +17,8 @@
validateattributes(service, {'string', 'char'}, {'scalartext'})
validateattributes(timeout, {'numeric'}, {'real', 'nonnegative'})

% Matlab R2018b didn't like ThreadPoolExectutor
servers = py.findssh.main('', port, service, timeout);
net = py.findssh.netfromaddress(py.findssh.getLANip());

hosts = cellfun(@char, cell(servers), 'uniformoutput', false);
hosts = cell(py.findssh.threadpool.get_hosts(net, uint8(port), service, timeout));

end
22 changes: 22 additions & 0 deletions tests/test_matlab.py
@@ -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__])

0 comments on commit bc8f187

Please sign in to comment.