blob: 0342b0695b67cfa59777cfa7ac6fa9e3a5d767a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
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)
|