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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/system/executive_mock.py

Issue 2188623002: Change logging statements to not use the "%" operator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 (C) 2011 Google Inc. All rights reserved. 1 # Copyright (C) 2011 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 def check_running_pid(self, pid): 78 def check_running_pid(self, pid):
79 return pid in self._running_pids.values() 79 return pid in self._running_pids.values()
80 80
81 def running_pids(self, process_name_filter): 81 def running_pids(self, process_name_filter):
82 running_pids = [] 82 running_pids = []
83 for process_name, process_pid in self._running_pids.iteritems(): 83 for process_name, process_pid in self._running_pids.iteritems():
84 if process_name_filter(process_name): 84 if process_name_filter(process_name):
85 running_pids.append(process_pid) 85 running_pids.append(process_pid)
86 86
87 _log.info("MOCK running_pids: %s" % running_pids) 87 _log.info("MOCK running_pids: %s", running_pids)
88 return running_pids 88 return running_pids
89 89
90 def command_for_printing(self, args): 90 def command_for_printing(self, args):
91 string_args = map(unicode, args) 91 string_args = map(unicode, args)
92 return " ".join(string_args) 92 return " ".join(string_args)
93 93
94 def run_command(self, 94 def run_command(self,
95 args, 95 args,
96 cwd=None, 96 cwd=None,
97 input=None, 97 input=None,
98 error_handler=None, 98 error_handler=None,
99 return_exit_code=False, 99 return_exit_code=False,
100 return_stderr=True, 100 return_stderr=True,
101 decode_output=False, 101 decode_output=False,
102 env=None, 102 env=None,
103 debug_logging=False): 103 debug_logging=False):
104 104
105 self.calls.append(args) 105 self.calls.append(args)
106 106
107 assert isinstance(args, list) or isinstance(args, tuple) 107 assert isinstance(args, list) or isinstance(args, tuple)
108 if self._should_log: 108 if self._should_log:
109 env_string = "" 109 env_string = ""
110 if env: 110 if env:
111 env_string = ", env=%s" % env 111 env_string = ", env=%s" % env
112 input_string = "" 112 input_string = ""
113 if input: 113 if input:
114 input_string = ", input=%s" % input 114 input_string = ", input=%s" % input
115 _log.info("MOCK run_command: %s, cwd=%s%s%s" % (args, cwd, env_strin g, input_string)) 115 _log.info("MOCK run_command: %s, cwd=%s%s%s", args, cwd, env_string, input_string)
116 output = "MOCK output of child process" 116 output = "MOCK output of child process"
117 117
118 if self._should_throw_when_run.intersection(args): 118 if self._should_throw_when_run.intersection(args):
119 raise ScriptError("Exception for %s" % args, output="MOCK command ou tput") 119 raise ScriptError("Exception for %s" % args, output="MOCK command ou tput")
120 120
121 if self._should_throw: 121 if self._should_throw:
122 raise ScriptError("MOCK ScriptError", output=output) 122 raise ScriptError("MOCK ScriptError", output=output)
123 123
124 if return_exit_code and self._should_return_zero_when_run.intersection(a rgs): 124 if return_exit_code and self._should_return_zero_when_run.intersection(a rgs):
125 return 0 125 return 0
(...skipping 11 matching lines...) Expand all
137 137
138 def popen(self, args, cwd=None, env=None, **kwargs): 138 def popen(self, args, cwd=None, env=None, **kwargs):
139 self.calls.append(args) 139 self.calls.append(args)
140 if self._should_log: 140 if self._should_log:
141 cwd_string = "" 141 cwd_string = ""
142 if cwd: 142 if cwd:
143 cwd_string = ", cwd=%s" % cwd 143 cwd_string = ", cwd=%s" % cwd
144 env_string = "" 144 env_string = ""
145 if env: 145 if env:
146 env_string = ", env=%s" % env 146 env_string = ", env=%s" % env
147 _log.info("MOCK popen: %s%s%s" % (args, cwd_string, env_string)) 147 _log.info("MOCK popen: %s%s%s", args, cwd_string, env_string)
148 if not self._proc: 148 if not self._proc:
149 self._proc = MockProcess() 149 self._proc = MockProcess()
150 return self._proc 150 return self._proc
151 151
152 def call(self, args, **kwargs): 152 def call(self, args, **kwargs):
153 self.calls.append(args) 153 self.calls.append(args)
154 _log.info('Mock call: %s' % args) 154 _log.info('Mock call: %s', args)
155 155
156 def run_in_parallel(self, commands): 156 def run_in_parallel(self, commands):
157 assert len(commands) 157 assert len(commands)
158 158
159 num_previous_calls = len(self.calls) 159 num_previous_calls = len(self.calls)
160 command_outputs = [] 160 command_outputs = []
161 for cmd_line, cwd in commands: 161 for cmd_line, cwd in commands:
162 command_outputs.append([0, self.run_command(cmd_line, cwd=cwd), '']) 162 command_outputs.append([0, self.run_command(cmd_line, cwd=cwd), ''])
163 163
164 new_calls = self.calls[num_previous_calls:] 164 new_calls = self.calls[num_previous_calls:]
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 if self._run_command_fn: 201 if self._run_command_fn:
202 return self._run_command_fn(args) 202 return self._run_command_fn(args)
203 if return_exit_code: 203 if return_exit_code:
204 return self._exit_code 204 return self._exit_code
205 if self._exit_code and error_handler: 205 if self._exit_code and error_handler:
206 script_error = ScriptError(script_args=args, exit_code=self._exit_co de, output=self._output) 206 script_error = ScriptError(script_args=args, exit_code=self._exit_co de, output=self._output)
207 error_handler(script_error) 207 error_handler(script_error)
208 if return_stderr: 208 if return_stderr:
209 return self._output + self._stderr 209 return self._output + self._stderr
210 return self._output 210 return self._output
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698