def introducer(reactor, temp_dir, flog_gatherer, request): config = ''' [node] nickname = introducer0 web.port = 4560 log_gatherer.furl = {log_furl} '''.format(log_furl=flog_gatherer) intro_dir = join(temp_dir, 'introducer') print("making introducer", intro_dir) if not exists(intro_dir): mkdir(intro_dir) done_proto = _ProcessExitedProtocol() reactor.spawnProcess( done_proto, sys.executable, ( sys.executable, '-m', 'allmydata.scripts.runner', 'create-introducer', '--listen=tcp', '--hostname=localhost', intro_dir, ), ) pytest.blockon(done_proto.done) # over-write the config file with our stuff with open(join(intro_dir, 'tahoe.cfg'), 'w') as f: f.write(config) # on windows, "tahoe start" means: run forever in the foreground, # but on linux it means daemonize. "tahoe run" is consistent # between platforms. protocol = _MagicTextProtocol('introducer running') process = reactor.spawnProcess( protocol, sys.executable, ( sys.executable, '-m', 'allmydata.scripts.runner', 'run', intro_dir, ), ) def cleanup(): try: process.signalProcess('TERM') pytest.blockon(protocol.exited) except ProcessExitedAlready: pass request.addfinalizer(cleanup) pytest.blockon(protocol.magic_seen) return process
def tor_introducer(reactor, temp_dir, flog_gatherer, request): config = ''' [node] nickname = introducer_tor web.port = 4561 log_gatherer.furl = {log_furl} '''.format(log_furl=flog_gatherer) intro_dir = join(temp_dir, 'introducer_tor') print("making introducer", intro_dir) if not exists(intro_dir): mkdir(intro_dir) done_proto = _ProcessExitedProtocol() _tahoe_runner_optional_coverage( done_proto, reactor, request, ( 'create-introducer', '--tor-control-port', 'tcp:localhost:8010', '--listen=tor', intro_dir, ), ) pytest_twisted.blockon(done_proto.done) # over-write the config file with our stuff with open(join(intro_dir, 'tahoe.cfg'), 'w') as f: f.write(config) # on windows, "tahoe start" means: run forever in the foreground, # but on linux it means daemonize. "tahoe run" is consistent # between platforms. protocol = _MagicTextProtocol('introducer running') transport = _tahoe_runner_optional_coverage( protocol, reactor, request, ( 'run', intro_dir, ), ) def cleanup(): try: transport.signalProcess('TERM') pytest_twisted.blockon(protocol.exited) except ProcessExitedAlready: pass request.addfinalizer(cleanup) pytest_twisted.blockon(protocol.magic_seen) return transport
def tor_introducer(reactor, temp_dir, flog_gatherer, request): config = ''' [node] nickname = introducer_tor web.port = 4561 log_gatherer.furl = {log_furl} '''.format(log_furl=flog_gatherer) intro_dir = join(temp_dir, 'introducer_tor') print("making introducer", intro_dir) if not exists(intro_dir): mkdir(intro_dir) done_proto = _ProcessExitedProtocol() reactor.spawnProcess( done_proto, sys.executable, ( sys.executable, '-m', 'allmydata.scripts.runner', 'create-introducer', '--tor-control-port', 'tcp:localhost:8010', '--listen=tor', intro_dir, ), ) pytest.blockon(done_proto.done) # over-write the config file with our stuff with open(join(intro_dir, 'tahoe.cfg'), 'w') as f: f.write(config) # on windows, "tahoe start" means: run forever in the foreground, # but on linux it means daemonize. "tahoe run" is consistent # between platforms. protocol = _MagicTextProtocol('introducer running') process = reactor.spawnProcess( protocol, sys.executable, ( sys.executable, '-m', 'allmydata.scripts.runner', 'run', intro_dir, ), ) def cleanup(): try: process.signalProcess('TERM') pytest.blockon(protocol.exited) except ProcessExitedAlready: pass request.addfinalizer(cleanup) pytest.blockon(protocol.magic_seen) return process
def introducer(reactor, temp_dir, flog_gatherer, request): config = ''' [node] nickname = introducer0 web.port = 4560 log_gatherer.furl = {log_furl} tub.port = tcp:9321 tub.location = tcp:localhost:9321 '''.format(log_furl=flog_gatherer) intro_dir = join(temp_dir, 'introducer') print("making introducer", intro_dir) if not exists(intro_dir): mkdir(intro_dir) done_proto = _ProcessExitedProtocol() _tahoe_runner( done_proto, reactor, request, ( 'create-introducer', '--listen=tcp', '--hostname=localhost', intro_dir, ), ) pytest_twisted.blockon(done_proto.done) # over-write the config file with our stuff with open(join(intro_dir, 'tahoe.cfg'), 'w') as f: f.write(config) # on windows, "tahoe start" means: run forever in the foreground, # but on linux it means daemonize. "tahoe run" is consistent # between platforms. protocol = _MagicTextProtocol('introducer running') transport = _tahoe_runner( protocol, reactor, request, ( 'run', intro_dir, ), ) request.addfinalizer( partial(_cleanup_tahoe_process, transport, protocol.exited)) pytest_twisted.blockon(protocol.magic_seen) return TahoeProcess(transport, intro_dir)
def introducer(reactor, temp_dir, flog_gatherer, request): config = ''' [node] nickname = introducer0 web.port = 4560 log_gatherer.furl = {log_furl} '''.format(log_furl=flog_gatherer) intro_dir = join(temp_dir, 'introducer') print("making introducer", intro_dir) if not exists(intro_dir): mkdir(intro_dir) done_proto = _ProcessExitedProtocol() _tahoe_runner_optional_coverage( done_proto, reactor, request, ( 'create-introducer', '--listen=tcp', '--hostname=localhost', intro_dir, ), ) pytest_twisted.blockon(done_proto.done) # over-write the config file with our stuff with open(join(intro_dir, 'tahoe.cfg'), 'w') as f: f.write(config) # "tahoe run" is consistent across Linux/macOS/Windows, unlike the old # "start" command. protocol = _MagicTextProtocol('introducer running') transport = _tahoe_runner_optional_coverage( protocol, reactor, request, ( 'run', intro_dir, ), ) request.addfinalizer( partial(_cleanup_tahoe_process, transport, protocol.exited)) pytest_twisted.blockon(protocol.magic_seen) return TahoeProcess(transport, intro_dir)