| OLD | NEW | 
|    1 # Copyright 2017 The Chromium Authors. All rights reserved. |    1 # Copyright 2017 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  |    4  | 
|    5 """Start and stop Web Page Replay.""" |    5 """Start and stop Web Page Replay.""" | 
|    6  |    6  | 
|    7 from py_utils import atexit_with_log |    7 from py_utils import atexit_with_log | 
|    8 import logging |    8 import logging | 
|    9 import os |    9 import os | 
|   10 import re |   10 import re | 
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  263     """ |  263     """ | 
|  264     is_posix = sys.platform.startswith('linux') or sys.platform == 'darwin' |  264     is_posix = sys.platform.startswith('linux') or sys.platform == 'darwin' | 
|  265     logging.info('Starting Web-Page-Replay: %s', self._cmd_line) |  265     logging.info('Starting Web-Page-Replay: %s', self._cmd_line) | 
|  266     self._CreateTempLogFilePath() |  266     self._CreateTempLogFilePath() | 
|  267     with open(self._temp_log_file_path, 'w') as log_fh: |  267     with open(self._temp_log_file_path, 'w') as log_fh: | 
|  268       self.replay_process = subprocess.Popen( |  268       self.replay_process = subprocess.Popen( | 
|  269           self._cmd_line, stdout=log_fh, stderr=subprocess.STDOUT, |  269           self._cmd_line, stdout=log_fh, stderr=subprocess.STDOUT, | 
|  270           preexec_fn=(_ResetInterruptHandler if is_posix else None)) |  270           preexec_fn=(_ResetInterruptHandler if is_posix else None)) | 
|  271     try: |  271     try: | 
|  272       py_utils.WaitFor(self._IsStarted, 30) |  272       py_utils.WaitFor(self._IsStarted, 30) | 
|  273       logging.info('WPR ports: %s' % self._started_ports) |  273       print 'WPR ports: %s' % self._started_ports | 
|  274       atexit_with_log.Register(self.StopServer) |  274       atexit_with_log.Register(self.StopServer) | 
|  275       return forwarders.PortSet( |  275       return forwarders.PortSet( | 
|  276           self._started_ports['http'], |  276           self._started_ports['http'], | 
|  277           self._started_ports['https'], |  277           self._started_ports['https'], | 
|  278           self._started_ports.get('dns'),  # None if unused |  278           self._started_ports.get('dns'),  # None if unused | 
|  279           ) |  279           ) | 
|  280     except py_utils.TimeoutException: |  280     except py_utils.TimeoutException: | 
|  281       raise ReplayNotStartedError( |  281       raise ReplayNotStartedError( | 
|  282           'Web Page Replay failed to start. Log output:\n%s' % |  282           'Web Page Replay failed to start. Log output:\n%s' % | 
|  283           ''.join(self._LogLines())) |  283           ''.join(self._LogLines())) | 
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  382   On posix system, running this function before starting replay fixes a |  382   On posix system, running this function before starting replay fixes a | 
|  383   bug that shows up when Telemetry is run as a background command from a |  383   bug that shows up when Telemetry is run as a background command from a | 
|  384   script. https://crbug.com/254572. |  384   script. https://crbug.com/254572. | 
|  385  |  385  | 
|  386   Background: Signal masks on Linux are inherited from parent |  386   Background: Signal masks on Linux are inherited from parent | 
|  387   processes. If anything invoking us accidentally masks SIGINT |  387   processes. If anything invoking us accidentally masks SIGINT | 
|  388   (e.g. by putting a process in the background from a shell script), |  388   (e.g. by putting a process in the background from a shell script), | 
|  389   sending a SIGINT to the child will fail to terminate it. |  389   sending a SIGINT to the child will fail to terminate it. | 
|  390   """ |  390   """ | 
|  391   signal.signal(signal.SIGINT, signal.SIG_DFL) |  391   signal.signal(signal.SIGINT, signal.SIG_DFL) | 
| OLD | NEW |