OLD | NEW |
1 # | 1 # |
2 # Copyright 2008 Google Inc. Released under the GPL v2 | 2 # Copyright 2008 Google Inc. Released under the GPL v2 |
3 | 3 |
4 import os, pickle, random, re, resource, select, shutil, signal, StringIO | 4 import os, pickle, random, re, resource, select, shutil, signal, StringIO |
5 import socket, struct, subprocess, sys, time, textwrap, urlparse | 5 import socket, struct, subprocess, sys, time, textwrap, urlparse |
6 import warnings, smtplib, logging, urllib2 | 6 import warnings, smtplib, logging, urllib2 |
7 from threading import Thread, Event | 7 from threading import Thread, Event |
8 try: | 8 try: |
9 import hashlib | 9 import hashlib |
10 except ImportError: | 10 except ImportError: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 self.string_stdin = stdin | 68 self.string_stdin = stdin |
69 stdin = subprocess.PIPE | 69 stdin = subprocess.PIPE |
70 else: | 70 else: |
71 self.string_stdin = None | 71 self.string_stdin = None |
72 | 72 |
73 if verbose: | 73 if verbose: |
74 logging.debug("Running '%s'" % command) | 74 logging.debug("Running '%s'" % command) |
75 self.sp = subprocess.Popen(command, stdout=subprocess.PIPE, | 75 self.sp = subprocess.Popen(command, stdout=subprocess.PIPE, |
76 stderr=subprocess.PIPE, | 76 stderr=subprocess.PIPE, |
77 preexec_fn=self._reset_sigpipe, shell=True, | 77 preexec_fn=self._reset_sigpipe, shell=True, |
78 executable="/bin/bash", | 78 |
| 79 # Default shell in ChromeOS test image is |
| 80 # already bash. We're seeing shell-init |
| 81 # errors if this value is set. |
| 82 |
| 83 #executable="/bin/bash", |
79 stdin=stdin) | 84 stdin=stdin) |
80 | 85 |
81 | 86 |
82 def output_prepare(self, stdout_file=None, stderr_file=None): | 87 def output_prepare(self, stdout_file=None, stderr_file=None): |
83 self.stdout_file = stdout_file | 88 self.stdout_file = stdout_file |
84 self.stderr_file = stderr_file | 89 self.stderr_file = stderr_file |
85 | 90 |
86 | 91 |
87 def process_output(self, stdout=True, final_read=False): | 92 def process_output(self, stdout=True, final_read=False): |
88 """output_prepare must be called prior to calling this""" | 93 """output_prepare must be called prior to calling this""" |
(...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 s.close() | 1706 s.close() |
1702 | 1707 |
1703 # On the 2.6 kernel, calling try_bind() on UDP socket returns the | 1708 # On the 2.6 kernel, calling try_bind() on UDP socket returns the |
1704 # same port over and over. So always try TCP first. | 1709 # same port over and over. So always try TCP first. |
1705 while True: | 1710 while True: |
1706 # Ask the OS for an unused port. | 1711 # Ask the OS for an unused port. |
1707 port = try_bind(0, socket.SOCK_STREAM, socket.IPPROTO_TCP) | 1712 port = try_bind(0, socket.SOCK_STREAM, socket.IPPROTO_TCP) |
1708 # Check if this port is unused on the other protocol. | 1713 # Check if this port is unused on the other protocol. |
1709 if port and try_bind(port, socket.SOCK_DGRAM, socket.IPPROTO_UDP): | 1714 if port and try_bind(port, socket.SOCK_DGRAM, socket.IPPROTO_UDP): |
1710 return port | 1715 return port |
OLD | NEW |