Navneet Sajwan
10/12/2021, 12:54 PMsandy
10/12/2021, 11:01 PMArt
10/13/2021, 1:26 AMsubprocess.Popen
to monitor stdout of a long-running external program (see below). It's pretty crufty though, is there a better way @sandy?cmd = ["julia", "--project=.", line_coupling, branch_geo_file, input_dir, output_dir]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while True:
line = p.stdout.readline()
if line:
<http://context.log.info|context.log.info>(line.decode("utf-8").rstrip())
else:
break
for err in p.stderr.readlines():
context.log.error(err.decode("utf-8").rstrip())
Navneet Sajwan
10/13/2021, 4:05 AMsandy
10/13/2021, 3:23 PM"output_logging": Field(
Enum(
name="OutputType",
enum_values=[
EnumValue("STREAM", description="Stream script stdout/stderr."),
EnumValue(
"BUFFER",
description="Buffer shell script stdout/stderr, then log upon completion.",
),
EnumValue("NONE", description="No logging"),
],
),
is_required=False,
default_value="BUFFER",
),
you could do my_shell_solid_with_stream_logging = my_shell_solid.configured({"output_logging": "STREAM"})
Navneet Sajwan
11/02/2021, 5:29 PM"output_logging": Field(
Enum(
name="OutputType",
enum_values=[
EnumValue("STREAM", description="Stream script stdout/stderr."),
EnumValue(
"BUFFER",
description="Buffer shell script stdout/stderr, then log upon completion.",
),
EnumValue("NONE", description="No logging"),
],
),
is_required=False,
default_value="BUFFER",
),
sandy
11/02/2021, 5:53 PMmy_shell_solid_with_stream_logging = my_shell_solid.configured({"output_logging": "STREAM"})
Navneet Sajwan
11/02/2021, 7:05 PMmy_shell_solid_with_stream_logging = my_shell_solid.configured({"output_logging": "STREAM"}, name="solid_name")