From c636750e35ede431a93a05e1cd0d1bc10533c067 Mon Sep 17 00:00:00 2001 From: Daniel Van Der Maden Date: Fri, 3 Jan 2020 16:41:41 -0800 Subject: [PATCH] [cli] Add check for path in `set_binary` --- pyhmy/cli.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyhmy/cli.py b/pyhmy/cli.py index b165596..cf00e41 100644 --- a/pyhmy/cli.py +++ b/pyhmy/cli.py @@ -173,6 +173,7 @@ def set_binary(path): """ global _binary_path path = os.path.realpath(path) + assert os.path.exists(path) os.chmod(path, os.stat(path).st_mode | stat.S_IEXEC) if not is_valid_binary(path): return False @@ -307,6 +308,6 @@ def expect_call(command, timeout=60): if os.path.exists(f"{get_gopath()}/src/github.com/harmony-one/bls") \ and os.path.exists(f"{get_gopath()}/src/github.com/harmony-one/mcl"): # Check prevents needless import fails. _environment.update(get_bls_build_variables()) # Needed if using dynamically linked CLI binary. -default_bin_path = _get_default_hmy_binary_path() -if default_bin_path: # Check prevents needless import fails. - set_binary(default_bin_path) +_default_bin_path = _get_default_hmy_binary_path() +if _default_bin_path: # Check prevents needless import fails. + set_binary(_default_bin_path)