Skip to content

Commit 874eb87

Browse files
committed
Try stderr, I guess
1 parent 8d519b5 commit 874eb87

File tree

2 files changed

+38
-17
lines changed

2 files changed

+38
-17
lines changed

src/source_repo/svn.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,8 @@ def _test_connection_and_credentials(ctx: Context, commands: dict) -> bool:
374374
password,
375375
quiet = False,
376376
name = f"svn_info_{tries_attempted}",
377-
expect = expect
377+
expect = expect,
378+
stderr = "stderr",
378379
)
379380

380381
svn_output = svn_info["output"]

src/utils/cmd.py

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,42 @@ def run_subprocess(
377377

378378
log(ctx, "with sub_process")
379379

380+
if sub_process.stderr:
381+
382+
log(ctx, "if sub_process.stderr")
383+
384+
for std_err_line in sub_process.stderr:
385+
386+
log(ctx, f"for std_err_line {std_err_line} in sub_process.stderr {sub_process.stderr}")
387+
388+
# Remove whitespaces, and skip empty lines
389+
std_err_line = std_err_line.strip()
390+
if not std_err_line:
391+
continue
392+
393+
std_err_list.append(std_err_line)
394+
log(ctx, f"std_err_list {std_err_list}.append(std_err_line {std_err_line})")
395+
396+
# Loop through the list of tuples passed in to the expect parameter
397+
for prompt, response in expect:
398+
399+
log(ctx, f"for prompt {prompt}, response {response} in expect {expect}")
400+
401+
# If the first part of the tuple is found in the output line
402+
if prompt in std_err_line:
403+
404+
log(ctx, f"prompt {prompt} is in std_err_line {std_err_line}")
405+
406+
# Send the second part into stdin
407+
sub_process.stdin.write(f"{response}\n")
408+
409+
# And flush the buffer
410+
sub_process.stdin.flush()
411+
412+
else:
413+
log(ctx, f"prompt {prompt} is NOT in std_err_line {std_err_line}")
414+
415+
380416
for std_out_line in sub_process.stdout:
381417

382418
log(ctx, f"std_out_line: {std_out_line}")
@@ -408,22 +444,6 @@ def run_subprocess(
408444
else:
409445
log(ctx, f"prompt {prompt} is NOT in std_out_line {std_out_line}")
410446

411-
if sub_process.stderr:
412-
413-
log(ctx, "if sub_process.stderr")
414-
415-
for std_err_line in sub_process.stderr:
416-
417-
log(ctx, f"for std_err_line {std_err_line} in sub_process.stderr {sub_process.stderr}")
418-
419-
# Remove whitespaces, and skip empty lines
420-
std_err_line = std_err_line.strip()
421-
if not std_err_line:
422-
continue
423-
424-
std_err_list.append(std_err_line)
425-
log(ctx, f"std_err_list {std_err_list}.append(std_err_line {std_err_line})")
426-
427447

428448
elif password:
429449

0 commit comments

Comments
 (0)