Skip to content

Commit

Permalink
🐛 Fix LSP crashes on Windows by adding silent mode
Browse files Browse the repository at this point in the history
  • Loading branch information
michprev committed Dec 3, 2023
1 parent a4e8c0b commit aaf220c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
14 changes: 13 additions & 1 deletion wake/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ def excepthook(attach: bool, type, value, traceback):
default=False,
help="Set logging level to debug and attach debugger on exception.",
)
@click.option(
"--silent",
"-s",
is_flag=True,
default=False,
help="Disable all stdout output.",
)
@click.option(
"--profile", is_flag=True, default=False, help="Enable profiling using cProfile."
)
Expand All @@ -87,7 +94,9 @@ def excepthook(attach: bool, type, value, traceback):
)
@click.version_option(message="%(version)s", package_name="eth-wake")
@click.pass_context
def main(ctx: Context, debug: bool, profile: bool, config: Optional[str]) -> None:
def main(
ctx: Context, debug: bool, silent: bool, profile: bool, config: Optional[str]
) -> None:
from wake.migrations import run_woke_wake_migration, run_xdg_migration

if profile:
Expand Down Expand Up @@ -141,6 +150,9 @@ def exit():

os.environ["PYTHONBREAKPOINT"] = "ipdb.set_trace"

if silent:
console.file = open(os.devnull, "w")

run_xdg_migration()
run_woke_wake_migration()

Expand Down
2 changes: 1 addition & 1 deletion wake/cli/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def run_no_pytest(

if proc_count is None:
random.seed(random_seeds[0])
print(f"Using random seed {random_seeds[0].hex()}")
console.print(f"Using random seed {random_seeds[0].hex()}")

if debug:
set_exception_handler(attach_debugger)
Expand Down
3 changes: 2 additions & 1 deletion wake/development/chain_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from typing_extensions import Literal, TypedDict

from wake.cli.console import console
from wake.config import WakeConfig
from wake.utils.networking import get_free_port

Expand Down Expand Up @@ -189,7 +190,7 @@ def launch(
elif config.testing.cmd == "ganache":
args += ["-k", hardfork]

print(f"Launching {' '.join(args)}")
console.print(f"Launching {' '.join(args)}")
process = subprocess.Popen(args, stdout=subprocess.DEVNULL)

try:
Expand Down
2 changes: 1 addition & 1 deletion wake/testing/fuzzing/fuzzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _run_core(
cov_child_conn: multiprocessing.connection.Connection,
coverage: Optional[CoverageHandler],
):
print(f"Using random seed '{random_seed.hex()}' for process #{index}")
console.print(f"Using random seed '{random_seed.hex()}' for process #{index}")

fuzz_test()

Expand Down
6 changes: 4 additions & 2 deletions wake/testing/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ def coverage_callback() -> None:
for ctx_manager in ctx_managers:
ctx_manager.__enter__()

print(f"Using random seed '{random_seed.hex()}' for process #{index}")
console.print(
f"Using random seed '{random_seed.hex()}' for process #{index}"
)

for i, item in enumerate(session.items):
nextitem = session.items[i + 1] if i + 1 < len(session.items) else None
Expand Down Expand Up @@ -165,7 +167,7 @@ def _runtestloop_single(self, session: Session):
coverage = self._cov_proc_count == 1 or self._cov_proc_count == -1

random.seed(self._random_seeds[0])
print(f"Using random seed '{self._random_seeds[0].hex()}'")
console.print(f"Using random seed '{self._random_seeds[0].hex()}'")

if self._debug:
set_exception_handler(attach_debugger)
Expand Down

0 comments on commit aaf220c

Please sign in to comment.