Skip to content

Commit

Permalink
fix(wokwi): pexpect.spawn not working on windows. use subprocess instead
Browse files Browse the repository at this point in the history
  • Loading branch information
hfudev committed Aug 19, 2024
1 parent e1dda11 commit 008444f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pytest-embedded-wokwi/pytest_embedded_wokwi/wokwi_cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import json
import logging
import os
import re
import shutil
import subprocess
import typing as t
from pathlib import Path

Expand Down Expand Up @@ -59,11 +61,10 @@ def __init__(
if shutil.which('wokwi-cli') is None:
raise RuntimeError('Please install wokwi-cli, by running: curl -L https://wokwi.com/ci/install.sh | sh')

child = pexpect.spawn('wokwi-cli --help')
output = subprocess.check_output(['wokwi-cli', '--help'])
try:
child.expect(r'Wokwi CLI v(\d+\.\d+\.\d+)', timeout=1)
wokwi_cli_version = child.match.group(1).decode('utf-8')
except pexpect.TIMEOUT:
wokwi_cli_version = re.match(r'Wokwi CLI v(\d+\.\d+\.\d+)', output.decode('utf-8')).group(1)
except AttributeError:
logging.warning('Failed to get wokwi-cli version, assume version requirements satisfied')
else:
if Version(wokwi_cli_version) < Version(WOKWI_CLI_MINIMUM_VERSION):
Expand Down

0 comments on commit 008444f

Please sign in to comment.