Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(820)

Side by Side Diff: telemetry/telemetry/core/cros_interface.py

Issue 2982743002: webrtc: Fix missing port forwarding on CrOS (Closed)
Patch Set: webrtc: Fix missing port forwarding on CrOS and android Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 """A wrapper around ssh for common operations on a CrOS-based device""" 4 """A wrapper around ssh for common operations on a CrOS-based device"""
5 import logging 5 import logging
6 import os 6 import os
7 import re 7 import re
8 import shutil 8 import shutil
9 import stat 9 import stat
10 import subprocess 10 import subprocess
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return not self._hostname 135 return not self._hostname
136 136
137 @property 137 @property
138 def hostname(self): 138 def hostname(self):
139 return self._hostname 139 return self._hostname
140 140
141 @property 141 @property
142 def ssh_port(self): 142 def ssh_port(self):
143 return self._ssh_port 143 return self._ssh_port
144 144
145 def FormSSHCommandLine(self, args, extra_ssh_args=None): 145 def FormSSHCommandLine(self, args, extra_ssh_args=None, port_forward=False):
146 """Constructs a subprocess-suitable command line for `ssh'. 146 """Constructs a subprocess-suitable command line for `ssh'.
147 """ 147 """
148 if self.local: 148 if self.local:
149 # We run the command through the shell locally for consistency with 149 # We run the command through the shell locally for consistency with
150 # how commands are run through SSH (crbug.com/239161). This work 150 # how commands are run through SSH (crbug.com/239161). This work
151 # around will be unnecessary once we implement a persistent SSH 151 # around will be unnecessary once we implement a persistent SSH
152 # connection to run remote commands (crbug.com/239607). 152 # connection to run remote commands (crbug.com/239607).
153 return ['sh', '-c', " ".join(args)] 153 return ['sh', '-c', " ".join(args)]
154 154
155 full_args = ['ssh', '-o ForwardX11=no', '-o ForwardX11Trusted=no', '-n', 155 full_args = ['ssh', '-o ForwardX11=no', '-o ForwardX11Trusted=no', '-n']
156 '-S', self._ssh_control_file] + self._ssh_args 156 # As remote port forwarding might conflict with the control socket
157 # sharing, skip the control socket args if it is for remote port forwarding.
158 if not port_forward:
159 full_args += ['-S', self._ssh_control_file]
160 full_args += self._ssh_args
157 if self._ssh_identity is not None: 161 if self._ssh_identity is not None:
158 full_args.extend(['-i', self._ssh_identity]) 162 full_args.extend(['-i', self._ssh_identity])
159 if extra_ssh_args: 163 if extra_ssh_args:
160 full_args.extend(extra_ssh_args) 164 full_args.extend(extra_ssh_args)
161 full_args.append('root@%s' % self._hostname) 165 full_args.append('root@%s' % self._hostname)
162 full_args.append('-p%d' % self._ssh_port) 166 full_args.append('-p%d' % self._ssh_port)
163 full_args.extend(args) 167 full_args.extend(args)
164 return full_args 168 return full_args
165 169
166 def _FormSCPCommandLine(self, src, dst, extra_scp_args=None): 170 def _FormSCPCommandLine(self, src, dst, extra_scp_args=None):
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 else: 565 else:
562 self.RunCmdOnDevice(start_cmd) 566 self.RunCmdOnDevice(start_cmd)
563 567
564 def CloseConnection(self): 568 def CloseConnection(self):
565 if not self.local: 569 if not self.local:
566 with open(os.devnull, 'w') as devnull: 570 with open(os.devnull, 'w') as devnull:
567 subprocess.call( 571 subprocess.call(
568 self.FormSSHCommandLine(['-O', 'exit', self._hostname]), 572 self.FormSSHCommandLine(['-O', 'exit', self._hostname]),
569 stdout=devnull, 573 stdout=devnull,
570 stderr=devnull) 574 stderr=devnull)
OLDNEW
« no previous file with comments | « no previous file | telemetry/telemetry/core/platform.py » ('j') | telemetry/telemetry/internal/platform/platform_backend.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698