def geth_wrapper(data_dir, popen_class=subprocess.Popen, cmd="geth", genesis_block=None, miner_threads='1', extra_args=None, max_peers='0', network_id='123456', no_discover=True, mine=False, nice=True, unlock='0', password=DEFAULT_PW_PATH, port=None, verbosity=None, logfile=None, ipcpath=None): if nice and is_nice_available(): command = ['nice', '-n', '20', cmd] else: command = [cmd] if genesis_block is None: genesis_block = get_genesis_block_path(data_dir) if not os.path.exists(genesis_block): genesis_block = os.path.join(POPULUS_DIR, 'genesis-test.json') if port is None: port = utils.get_open_port() if ipcpath is None: ipcpath = tempfile.NamedTemporaryFile().name command.extend(( '--genesis', genesis_block, '--datadir', data_dir, '--maxpeers', max_peers, '--networkid', network_id, '--port', port, '--ipcpath', ipcpath, )) if miner_threads is not None: command.extend(('--minerthreads', miner_threads)) if logfile is not None: command.extend(( '--logfile', logfile, )) if verbosity is not None: command.extend(( '--verbosity', verbosity, )) if unlock is not None: command.extend(( '--unlock', unlock, )) if password is not None: command.extend(( '--password', password, )) if no_discover: command.append('--nodiscover') if mine: if unlock is None: raise ValueError("Cannot mine without an unlocked account") command.append('--mine') if extra_args: command.extend(extra_args) proc = popen_class( command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=1, ) return command, proc
def open_port(): return get_open_port()
def geth_wrapper(data_dir, popen_class=subprocess.Popen, cmd="geth", genesis_block=None, miner_threads='1', extra_args=None, max_peers='0', network_id='123456', no_discover=True, mine=False, nice=True, unlock='0', password=DEFAULT_PW_PATH, port=None, verbosity=None, logfile=None, whisper=True, ipcpath=None): if nice and is_nice_available(): command = ['nice', '-n', '20', cmd] else: command = [cmd] if genesis_block is None: genesis_block = get_genesis_block_path(data_dir) if not os.path.exists(genesis_block): genesis_block = os.path.join(POPULUS_DIR, 'genesis-test.json') if port is None: port = utils.get_open_port() if ipcpath is None: ipcpath = tempfile.NamedTemporaryFile().name command.extend(( '--genesis', genesis_block, '--datadir', data_dir, '--maxpeers', max_peers, '--networkid', network_id, '--port', port, '--ipcpath', ipcpath, )) if whisper: command.append('--shh') command.extend(('--rpcapi', 'db,eth,net,web3,shh')) if miner_threads is not None: command.extend(('--minerthreads', miner_threads)) if verbosity is not None: command.extend(( '--verbosity', verbosity, )) if unlock is not None: command.extend(( '--unlock', unlock, )) if password is not None: command.extend(( '--password', password, )) if no_discover: command.append('--nodiscover') if mine: if unlock is None: raise ValueError("Cannot mine without an unlocked account") command.append('--mine') if extra_args: command.extend(extra_args) proc = popen_class( command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=1, ) return command, proc
def geth_wrapper( data_dir, popen_class=subprocess.Popen, cmd="geth", genesis_block=None, miner_threads="1", extra_args=None, max_peers="0", network_id="123456", no_discover=True, mine=False, nice=True, unlock="0", password=DEFAULT_PW_PATH, port=None, verbosity=None, logfile=None, ): if nice and is_nice_available(): command = ["nice", "-n", "20", cmd] else: command = [cmd] if genesis_block is None: genesis_block = get_genesis_block_path(data_dir) if not os.path.exists(genesis_block): genesis_block = os.path.join(POPULUS_DIR, "genesis-test.json") if port is None: port = utils.get_open_port() command.extend( ( "--genesis", genesis_block, "--datadir", data_dir, "--maxpeers", max_peers, "--networkid", network_id, "--port", port, ) ) if miner_threads is not None: command.extend(("--minerthreads", miner_threads)) if logfile is not None: command.extend(("--logfile", logfile)) if verbosity is not None: command.extend(("--verbosity", verbosity)) if unlock is not None: command.extend(("--unlock", unlock)) if password is not None: command.extend(("--password", password)) if no_discover: command.append("--nodiscover") if mine: if unlock is None: raise ValueError("Cannot mine without an unlocked account") command.append("--mine") if extra_args: command.extend(extra_args) proc = popen_class(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=1) return command, proc