Skip to content
This repository was archived by the owner on Feb 14, 2025. It is now read-only.

Commit 84525ac

Browse files
authored
Merge pull request #86 from crytic/ganache-cmd
Ganache cmd
2 parents fc1a6da + 205752b commit 84525ac

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

etheno/__main__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def main(argv=None):
6363
help='Arguments to pass to truffle (default=migrate)')
6464
parser.add_argument('-g', '--ganache', action='store_true', default=False,
6565
help='Run Ganache as a master JSON RPC client (cannot be used in conjunction with --master)')
66+
parser.add_argument('--ganache-cmd', type=str, default=None, help='Specify a command that runs Ganache '
67+
'(default="/usr/bin/env ganache-cli")')
6668
parser.add_argument('--ganache-args', type=str, default=None,
6769
help='Additional arguments to pass to Ganache')
6870
parser.add_argument('--ganache-port', type=int, default=None,
@@ -239,7 +241,7 @@ def main(argv=None):
239241
if args.ganache_args is not None:
240242
ganache_args += shlex.split(args.ganache_args)
241243

242-
ganache_instance = ganache.Ganache(args=ganache_args, port=args.ganache_port)
244+
ganache_instance = ganache.Ganache(cmd=args.ganache_cmd, args=ganache_args, port=args.ganache_port)
243245

244246
ETHENO.master_client = ganache.GanacheClient(ganache_instance)
245247

etheno/ganache.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
#!/usr/bin/env python3
22

33
import atexit
4+
import shlex
45
import shutil
56
import subprocess
67
import time
78

89
from .client import RpcHttpProxy, SelfPostingClient
910
from .logger import PtyLogger
1011
from .utils import is_port_free
12+
from .etheno import ETHENO
1113

1214

1315
class Ganache(RpcHttpProxy):
14-
def __init__(self, args=None, port=8546):
16+
def __init__(self, cmd=None, args=None, port=8546):
1517
super().__init__("http://127.0.0.1:%d/" % port)
1618
self.port = port
19+
if cmd is not None:
20+
cmd = shlex.split(cmd)
21+
else:
22+
cmd = ['/usr/bin/env', 'ganache-cli']
1723
if args is None:
1824
args = []
19-
self.args = ['/usr/bin/env', 'ganache-cli', '-d', '-p', str(port)] + args
25+
self.args = cmd + ['-d', '-p', str(port)] + args
2026
self.ganache = None
2127
self._client = None
2228

@@ -34,6 +40,7 @@ def ganache_errored() -> int:
3440
return self.ganache.exitstatus
3541
return 0
3642
else:
43+
ETHENO.logger.debug(f"Running ganache: {self.args}")
3744
self.ganache = subprocess.Popen(self.args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=1)
3845

3946
def ganache_errored():

0 commit comments

Comments
 (0)