OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS 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 | 4 |
5 """Common python commands used by various build scripts.""" | 5 """Common python commands used by various build scripts.""" |
6 | 6 |
7 import inspect | 7 import inspect |
8 import os | 8 import os |
9 import re | 9 import re |
10 import subprocess | 10 import subprocess |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 249 |
250 | 250 |
251 def GetIPAddress(device='eth0'): | 251 def GetIPAddress(device='eth0'): |
252 """Returns the IP Address for a given device using ifconfig. | 252 """Returns the IP Address for a given device using ifconfig. |
253 | 253 |
254 socket.gethostname() is insufficient for machines where the host files are | 254 socket.gethostname() is insufficient for machines where the host files are |
255 not set up "correctly." Since some of our builders may have this issue, | 255 not set up "correctly." Since some of our builders may have this issue, |
256 this method gives you a generic way to get the address so you are reachable | 256 this method gives you a generic way to get the address so you are reachable |
257 either via a VM or remote machine on the same network. | 257 either via a VM or remote machine on the same network. |
258 """ | 258 """ |
259 ifconfig_output = RunCommand(['sudo', 'ifconfig', device], | 259 ifconfig_output = RunCommand(['/sbin/ifconfig', device], |
260 redirect_stdout=True, print_cmd=False) | 260 redirect_stdout=True, print_cmd=False) |
261 match = re.search('.*inet addr:(\d+\.\d+\.\d+\.\d+).*', ifconfig_output) | 261 match = re.search('.*inet addr:(\d+\.\d+\.\d+\.\d+).*', ifconfig_output) |
262 if match: | 262 if match: |
263 return match.group(1) | 263 return match.group(1) |
264 else: | 264 else: |
265 Warning('Failed to find ip address in %s' % ifconfig_output) | 265 Warning('Failed to find ip address in %s' % ifconfig_output) |
266 return None | 266 return None |
OLD | NEW |