import os def start_server(ctx): # Declare Subplot library names. In the generated Python program, the # libraries will be included and can just be used via names, but to placate # automated checks that only see this file, get the names from globals() at # runtime. daemon_start_on_port = globals()["daemon_start_on_port"] runcmd_helper_srcdir_path = globals()["runcmd_helper_srcdir_path"] srcdir = globals()["srcdir"] # This installs srcdir in $PATH so that we can run the client and server # easily. runcmd_helper_srcdir_path(ctx) # Start server. server = os.path.join(srcdir, "server.py") daemon_start_on_port(ctx, path=server, args="", name="server", port=5000) def stop_server(ctx): daemon_stop = globals()["daemon_stop"] daemon_stop(ctx, name="server") def answer_is(ctx, index): assert_eq = globals()["assert_eq"] runcmd_get_stdout = globals()["runcmd_get_stdout"] stdout = runcmd_get_stdout(ctx) assert_eq(stdout.strip(), index)