Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions scripts/riskeycap_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,27 @@

SEM = asyncio.Semaphore(MAX_RUNNERS)


if hasattr(asyncio, 'coroutine'):
from asyncio import coroutine
else:
# For compatibility with Python 3.10+
# define the coroutine wrapper
# References:
# https://discuss.python.org/t/deprecation-of-asyncio-coroutine/4461/3
def coroutine(fn):
import inspect
import functools
if inspect.iscoroutinefunction(fn):
return fn

@functools.wraps(fn)
async def _wrapper(*args, **kwargs):
return fn(*args, **kwargs)

return _wrapper


def run_command(cmd: str) -> str:
"""
Run prepared behave command in shell and return its output.
Expand All @@ -84,7 +105,7 @@ def run_command(cmd: str) -> str:
return output


# @asyncio.coroutine
# @coroutine
async def run_command_on_loop(loop: asyncio.AbstractEventLoop, command: str) -> bool:
"""
Run test for one particular feature, check its result and return report.
Expand All @@ -99,7 +120,7 @@ async def run_command_on_loop(loop: asyncio.AbstractEventLoop, command: str) ->
return output


@asyncio.coroutine
@coroutine
def run_all_commands(command_list: Sequence[str] = COMMANDS) -> None:
"""
Run all commands in a list
Expand All @@ -112,7 +133,7 @@ def run_all_commands(command_list: Sequence[str] = COMMANDS) -> None:
ensure_future(process_result(result))


@asyncio.coroutine
@coroutine
def process_result(result: Any):
"""
Do something useful with result of the commands
Expand Down