From a6c52f566acfbff5b0f37158c0d33adf05d250e5 Mon Sep 17 00:00:00 2001 From: Joanna Wang Date: Thu, 3 Nov 2022 16:51:19 -0400 Subject: Set tracing to always on and save to .repo/TRACE_FILE. - add `--trace_to_stderr` option so stderr will include trace outputs and any other errors that get sent to stderr - while TRACE_FILE will only include trace outputs piggy-backing on: https://gerrit-review.googlesource.com/c/git-repo/+/349154 Change-Id: I3895a84de4b2784f17fac4325521cd5e72e645e2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/350114 Reviewed-by: LaMont Jones Tested-by: Joanna Wang --- ssh.py | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'ssh.py') diff --git a/ssh.py b/ssh.py index 450383dc..004fdbad 100644 --- a/ssh.py +++ b/ssh.py @@ -182,28 +182,29 @@ class ProxyManager: # be important because we can't tell that that 'git@myhost.com' is the same # as 'myhost.com' where "User git" is setup in the user's ~/.ssh/config file. check_command = command_base + ['-O', 'check'] - try: - Trace(': %s', ' '.join(check_command)) - check_process = subprocess.Popen(check_command, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - check_process.communicate() # read output, but ignore it... - isnt_running = check_process.wait() - - if not isnt_running: - # Our double-check found that the master _was_ infact running. Add to - # the list of keys. - self._master_keys[key] = True - return True - except Exception: - # Ignore excpetions. We we will fall back to the normal command and print - # to the log there. - pass + with Trace('Call to ssh (check call): %s', ' '.join(check_command)): + try: + check_process = subprocess.Popen(check_command, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + check_process.communicate() # read output, but ignore it... + isnt_running = check_process.wait() + + if not isnt_running: + # Our double-check found that the master _was_ infact running. Add to + # the list of keys. + self._master_keys[key] = True + return True + except Exception: + # Ignore excpetions. We we will fall back to the normal command and + # print to the log there. + pass command = command_base[:1] + ['-M', '-N'] + command_base[1:] + p = None try: - Trace(': %s', ' '.join(command)) - p = subprocess.Popen(command) + with Trace('Call to ssh: %s', ' '.join(command)): + p = subprocess.Popen(command) except Exception as e: self._master_broken.value = True print('\nwarn: cannot enable ssh control master for %s:%s\n%s' -- cgit v1.2.3-54-g00ecf