OLD | NEW |
1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 class ServerProcess(object): | 55 class ServerProcess(object): |
56 """This class provides a wrapper around a subprocess that | 56 """This class provides a wrapper around a subprocess that |
57 implements a simple request/response usage model. The primary benefit | 57 implements a simple request/response usage model. The primary benefit |
58 is that reading responses takes a deadline, so that we don't ever block | 58 is that reading responses takes a deadline, so that we don't ever block |
59 indefinitely. The class also handles transparently restarting processes | 59 indefinitely. The class also handles transparently restarting processes |
60 as necessary to keep issuing commands.""" | 60 as necessary to keep issuing commands.""" |
61 | 61 |
62 def __init__(self, port_obj, name, cmd, env=None, universal_newlines=False,
treat_no_data_as_crash=False): | 62 def __init__(self, port_obj, name, cmd, env=None, universal_newlines=False,
treat_no_data_as_crash=False): |
63 self._port = port_obj | 63 self._port = port_obj |
64 self._name = name # Should be the command name (e.g. DumpRenderTree, Im
ageDiff) | 64 self._name = name # Should be the command name (e.g. content_shell, Ima
geDiff) |
65 self._cmd = cmd | 65 self._cmd = cmd |
66 self._env = env | 66 self._env = env |
67 # Set if the process outputs non-standard newlines like '\r\n' or '\r'. | 67 # Set if the process outputs non-standard newlines like '\r\n' or '\r'. |
68 # Don't set if there will be binary data or the data must be ASCII encod
ed. | 68 # Don't set if there will be binary data or the data must be ASCII encod
ed. |
69 self._universal_newlines = universal_newlines | 69 self._universal_newlines = universal_newlines |
70 self._treat_no_data_as_crash = treat_no_data_as_crash | 70 self._treat_no_data_as_crash = treat_no_data_as_crash |
71 self._host = self._port.host | 71 self._host = self._port.host |
72 self._pid = None | 72 self._pid = None |
73 self._reset() | 73 self._reset() |
74 | 74 |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 self._proc.wait() | 366 self._proc.wait() |
367 | 367 |
368 def replace_outputs(self, stdout, stderr): | 368 def replace_outputs(self, stdout, stderr): |
369 assert self._proc | 369 assert self._proc |
370 if stdout: | 370 if stdout: |
371 self._proc.stdout.close() | 371 self._proc.stdout.close() |
372 self._proc.stdout = stdout | 372 self._proc.stdout = stdout |
373 if stderr: | 373 if stderr: |
374 self._proc.stderr.close() | 374 self._proc.stderr.close() |
375 self._proc.stderr = stderr | 375 self._proc.stderr = stderr |
OLD | NEW |