Merge lp:~le-chi-thu/lava-dispatcher/improve-logging into lp:lava-dispatcher
- improve-logging
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 119 |
Proposed branch: | lp:~le-chi-thu/lava-dispatcher/improve-logging |
Merge into: | lp:lava-dispatcher |
Diff against target: |
531 lines (+113/-25) (has conflicts) 14 files modified
.bzrignore (+1/-0) lava-dispatch (+18/-1) lava_dispatcher/actions/android_0xbench.py (+3/-2) lava_dispatcher/actions/android_basic.py (+2/-1) lava_dispatcher/actions/android_deploy.py (+8/-6) lava_dispatcher/actions/boot_control.py (+4/-0) lava_dispatcher/actions/deploy.py (+24/-2) lava_dispatcher/actions/launch_control.py (+31/-5) lava_dispatcher/actions/lava-test.py (+4/-0) lava_dispatcher/android_client.py (+6/-4) lava_dispatcher/client.py (+4/-3) lava_dispatcher/config.py (+2/-1) lava_dispatcher/default-config/lava-dispatcher/README (+4/-0) lava_dispatcher/default-config/lava-dispatcher/lava-dispatcher.conf (+2/-0) Text conflict in lava_dispatcher/actions/deploy.py Text conflict in lava_dispatcher/actions/launch_control.py |
To merge this branch: | bzr merge lp:~le-chi-thu/lava-dispatcher/improve-logging |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Paul Larson (community) | Approve | ||
Le Chi Thu | Pending | ||
Review via email: mp+76548@code.launchpad.net |
This proposal supersedes a proposal from 2011-08-10.
Commit message
Description of the change
All print outs from lava-dispatcher are prefix with <<LAVA_
Replaced the python configuration file with one option in lava-dispatcher
# Enable python logging level to debug. 0 - logging level is INFO, 1- logging level is DEBUG
LOGGING_LEVEL_DEBUG = 0
Spring Zhang (qzhang) wrote : Posted in a previous version of this proposal | # |
Paul Larson (pwlars) wrote : Posted in a previous version of this proposal | # |
Good idea to improve the logging in the dispatcher, but if we are going to go to the trouble of doing, let's really improve it and use python.logging.
Spring Zhang (qzhang) wrote : Posted in a previous version of this proposal | # |
Actually, I have a bp on: https:/
Le Chi Thu (le-chi-thu) wrote : Posted in a previous version of this proposal | # |
Spring: Let abandon this MP and go ahead improve the logging with python
logging lib.
On 12 August 2011 04:28, Spring Zhang <email address hidden> wrote:
> Actually, I have a bp on:
> https:/
> I'll start after milestone 11.08 soon. I will get your prefix in it too.
> --
>
> https:/
> You are the owner of lp:~le-chi-thu/lava-dispatcher/improve-logging.
>
Le Chi Thu (le-chi-thu) wrote : Posted in a previous version of this proposal | # |
Hi
I replaced the print statements with python standard logging library. Please review.
BR
/Chi Thu
Paul Larson (pwlars) wrote : Posted in a previous version of this proposal | # |
8 +./.idea
What's this for?
31 +# load logging configuration file
32 +for directory in load_config_
33 + path = os.path.
34 + if os.path.
35 + logging.
36 + break
You should be able to just use get_config() for this (see lava_dispatcher
477 +[formatters]
478 +keys: detailed,simple
479 +
480 +[handlers]
481 +keys: console
482 +
483 +[loggers]
484 +keys: root
485 +
486 +[formatter_simple]
487 +format:
488 +datefmt:%Y-%m-%d %I:%M:%S %p
489 +
490 +[formatter_
491 +format:
492 +datefmt:%Y-%m-%d %I:%M:%S %p
493 +
494 +[handler_console]
495 +class: StreamHandler
496 +args: []
497 +formatter: simple
498 +
499 +[logger_root]
500 +level: DEBUG
501 +name: LAVA_DISPATCHER
502 +handlers: console
Perhaps I'm just tired and missing it, but I don't see where you are actually using all these options. Also, I think it's overkill. I don't think we should really need to specify anything other than the log level, and I'm thinking perhaps it should be set to some default value in the main dispatcher config file, but be something we can override with an option passed to the job.
Otherwise, looking much better!
Le Chi Thu (le-chi-thu) wrote : Posted in a previous version of this proposal | # |
>8 +./.idea
>What's this for?
.idea is created by the IDE (PyCharm) I use containing PyCharm project
files..
> You should be able to just use get_config() for this (see
> lava_dispatcher
>
> I saw and understand the get_config method in config.py but It does not fit
the need of logging.
I need to pass the url of the configuration file to the python logging
library. So I use the load_config_paths to search for that file.
get_config get keys and values inside the configuration file.
477 +[formatters]
> 478 +keys: detailed,simple
>
> 502 +handlers: console
> Perhaps I'm just tired and missing it, but I don't see where you are
> actually using all these options. Also, I think it's overkill. I don't
> think we should really need to specify anything other than the log level,
> and I'm thinking perhaps it should be set to some default value in the main
> dispatcher config file, but be something we can override with an option
> passed to the job.
>
This is how python logging configuration commonl done. This file is a simple
template and can be override by copy the file to users lava-dispatcher
configuration directories and modify the content.
See example in http://
> Otherwise, looking much better!
> --
>
> https:/
> You are the owner of lp:~le-chi-thu/lava-dispatcher/improve-logging.
>
Michael Hudson-Doyle (mwhudson) wrote : Posted in a previous version of this proposal | # |
Hi, overall the change looks good. I share Paul's concerns about the configuration though -- in particular, it's not possible to 'stack' configurations as it is with the other configuration files we now have. This is in large part because logging.config basically sucks (if you could pass a ConfigParser instance to a function to configure the logging, there wouldn't be this problem).
Also, in my experience, people don't actually use fileConfig (I don't think I've worked on a single project that uses it in fact). I agree with Paul that we should start simple, and just allow a key 'log_level' in the general lava-dispatcher
Le Chi Thu (le-chi-thu) wrote : Posted in a previous version of this proposal | # |
Just updated to simplify the configuration of logging level.
- 118. By Paul Larson
-
Support lava-android-test in lava-dispatcher for android testing
Paul Larson (pwlars) wrote : | # |
As discussed earlier today, I changed this slightly to make the option use the python logging module levels, and just called the option LOGGING_LEVEL.
Also, please make sure to select linaro-validation when requesting merge proposals so that everyone see it :)
- 119. By Paul Larson
-
Merge python logging branch from ChiThu
Preview Diff
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2011-09-09 00:57:07 +0000 |
3 | +++ .bzrignore 2011-09-22 10:41:46 +0000 |
4 | @@ -6,3 +6,4 @@ |
5 | ./dist |
6 | ./lava_dispatcher.egg-info |
7 | ./build |
8 | +./.idea |
9 | \ No newline at end of file |
10 | |
11 | === modified file 'lava-dispatch' |
12 | --- lava-dispatch 2011-08-17 00:52:46 +0000 |
13 | +++ lava-dispatch 2011-09-22 10:41:46 +0000 |
14 | @@ -22,9 +22,11 @@ |
15 | import optparse |
16 | import os |
17 | import sys |
18 | +import logging.config |
19 | |
20 | from lava_dispatcher import LavaTestJob |
21 | - |
22 | +from lava_dispatcher.config import load_config_paths |
23 | +from lava_dispatcher.config import get_config |
24 | |
25 | parser = optparse.OptionParser('%prog: lava-dispatch <json job file>') |
26 | parser.add_option( |
27 | @@ -32,6 +34,7 @@ |
28 | |
29 | (options, args) = parser.parse_args() |
30 | |
31 | + |
32 | if len(args) != 1: |
33 | parser.print_help() |
34 | sys.exit(1) |
35 | @@ -44,6 +47,20 @@ |
36 | with open(args[0]) as fd: |
37 | jobdata = fd.read() |
38 | |
39 | +# config the python logging |
40 | + |
41 | +FORMAT = '<LAVA_DISPATCHER>%(asctime)s %(levelname)s: %(message)s' |
42 | +DATEFMT= '%Y-%m-%d %I:%M:%S %p' |
43 | +logging.basicConfig(format=FORMAT,datefmt=DATEFMT) |
44 | + |
45 | +config = get_config("lava-dispatcher") |
46 | +logging_debug = config.get("LOGGING_LEVEL_DEBUG") |
47 | +if (logging_debug == "1"): |
48 | + logging.root.setLevel(logging.DEBUG) |
49 | +else: |
50 | + logging.root.setLevel(logging.INFO) |
51 | + |
52 | job = LavaTestJob(jobdata, oob_file) |
53 | + |
54 | #FIXME Return status |
55 | job.run() |
56 | |
57 | === modified file 'lava_dispatcher/actions/android_0xbench.py' |
58 | --- lava_dispatcher/actions/android_0xbench.py 2011-07-20 06:53:10 +0000 |
59 | +++ lava_dispatcher/actions/android_0xbench.py 2011-09-22 10:41:46 +0000 |
60 | @@ -22,6 +22,7 @@ |
61 | from lava_dispatcher.actions import BaseAndroidAction |
62 | import time |
63 | import pexpect |
64 | +import logging |
65 | |
66 | class cmd_test_android_0xbench(BaseAndroidAction): |
67 | def run(self): |
68 | @@ -30,7 +31,7 @@ |
69 | time.sleep(30) |
70 | if not self.check_sys_bootup(): |
71 | # TODO: Fetch the logcat message as attached |
72 | - print "0xbench Test: sys bootup fail, aborted" |
73 | + logging.warning("0xbench Test: sys bootup fail, aborted") |
74 | return |
75 | |
76 | self.client.android_logcat_clear() |
77 | @@ -46,7 +47,7 @@ |
78 | try: |
79 | self.client.android_logcat_monitor(pattern, timeout = 1200) |
80 | except pexpect.TIMEOUT: |
81 | - print "0xbench Test: TIMEOUT Fail" |
82 | + logging.warning("0xbench Test: TIMEOUT Fail") |
83 | raise |
84 | finally: |
85 | self.client.android_logcat_stop() |
86 | |
87 | === modified file 'lava_dispatcher/actions/android_basic.py' |
88 | --- lava_dispatcher/actions/android_basic.py 2011-09-05 22:39:47 +0000 |
89 | +++ lava_dispatcher/actions/android_basic.py 2011-09-22 10:41:46 +0000 |
90 | @@ -24,6 +24,7 @@ |
91 | import time |
92 | import pexpect |
93 | import sys |
94 | +import logging |
95 | from datetime import datetime |
96 | from lava_dispatcher.android_util import savebundlefile |
97 | |
98 | @@ -34,7 +35,7 @@ |
99 | time.sleep(30) |
100 | if not self.check_sys_bootup(): |
101 | # TODO: Fetch the logcat message as attachment |
102 | - print "monkey run test skipped: sys bootup fail" |
103 | + logging.warning("monkey run test skipped: sys bootup fail") |
104 | return |
105 | |
106 | TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ' |
107 | |
108 | === modified file 'lava_dispatcher/actions/android_deploy.py' |
109 | --- lava_dispatcher/actions/android_deploy.py 2011-09-14 04:18:40 +0000 |
110 | +++ lava_dispatcher/actions/android_deploy.py 2011-09-22 10:41:46 +0000 |
111 | @@ -24,6 +24,8 @@ |
112 | import sys |
113 | import shutil |
114 | import traceback |
115 | +import logging |
116 | + |
117 | from tempfile import mkdtemp |
118 | from lava_dispatcher.utils import download, download_with_cache |
119 | from lava_dispatcher.client import CriticalError |
120 | @@ -33,14 +35,14 @@ |
121 | LAVA_IMAGE_TMPDIR = self.context.lava_image_tmpdir |
122 | LAVA_IMAGE_URL = self.context.lava_image_url |
123 | client = self.client |
124 | - print "deploying Android on %s" % client.hostname |
125 | - print " boot: %s" % boot |
126 | - print " system: %s" % system |
127 | - print " data: %s" % data |
128 | - print "Booting master image" |
129 | + logging.info("deploying Android on %s" % client.hostname) |
130 | + logging.info(" boot: %s" % boot) |
131 | + logging.info(" system: %s" % system) |
132 | + logging.info(" data: %s" % data) |
133 | + logging.info("Booting master image") |
134 | client.boot_master_image() |
135 | |
136 | - print "Waiting for network to come up" |
137 | + logging.info("Waiting for network to come up") |
138 | try: |
139 | client.wait_network_up() |
140 | except: |
141 | |
142 | === modified file 'lava_dispatcher/actions/boot_control.py' |
143 | --- lava_dispatcher/actions/boot_control.py 2011-09-16 02:37:57 +0000 |
144 | +++ lava_dispatcher/actions/boot_control.py 2011-09-22 10:41:46 +0000 |
145 | @@ -20,6 +20,8 @@ |
146 | # along |
147 | # with this program; if not, see <http://www.gnu.org/licenses>. |
148 | |
149 | +import logging |
150 | + |
151 | from lava_dispatcher.actions import BaseAction, BaseAndroidAction |
152 | from lava_dispatcher.client import CriticalError |
153 | |
154 | @@ -44,6 +46,7 @@ |
155 | client.proc.sendline("") |
156 | status = 'pass' |
157 | try: |
158 | + logging.info("Boot Linaro image") |
159 | client.boot_linaro_image() |
160 | except: |
161 | status = 'fail' |
162 | @@ -56,4 +59,5 @@ |
163 | """ |
164 | def run(self): |
165 | client = self.client |
166 | + logging.info("Boot Master image") |
167 | client.boot_master_image() |
168 | |
169 | === modified file 'lava_dispatcher/actions/deploy.py' |
170 | --- lava_dispatcher/actions/deploy.py 2011-09-16 02:37:57 +0000 |
171 | +++ lava_dispatcher/actions/deploy.py 2011-09-22 10:41:46 +0000 |
172 | @@ -24,6 +24,7 @@ |
173 | import shutil |
174 | import traceback |
175 | from tempfile import mkdtemp |
176 | +import logging |
177 | |
178 | from lava_dispatcher.actions import BaseAction |
179 | from lava_dispatcher.utils import download, download_with_cache |
180 | @@ -35,15 +36,22 @@ |
181 | LAVA_IMAGE_TMPDIR = self.context.lava_image_tmpdir |
182 | LAVA_IMAGE_URL = self.context.lava_image_url |
183 | client = self.client |
184 | +<<<<<<< TREE |
185 | print "deploying on %s" % client.hostname |
186 | print " hwpack: %s" % hwpack |
187 | print " rootfs: %s" % rootfs |
188 | if kernel_matrix: |
189 | print " package: %s" % kernel_matrix[0] |
190 | print "Booting master image" |
191 | +======= |
192 | + logging.info("deploying on %s" % client.hostname) |
193 | + logging.info(" hwpack: %s" % hwpack) |
194 | + logging.info(" rootfs: %s" % rootfs) |
195 | + logging.info("Booting master image") |
196 | +>>>>>>> MERGE-SOURCE |
197 | client.boot_master_image() |
198 | |
199 | - print "Waiting for network to come up" |
200 | + logging.info("Waiting for network to come up") |
201 | try: |
202 | client.wait_network_up() |
203 | except: |
204 | @@ -51,6 +59,7 @@ |
205 | client.sio.write(tb) |
206 | raise CriticalError("Unable to reach LAVA server, check network") |
207 | |
208 | +<<<<<<< TREE |
209 | if kernel_matrix: |
210 | hwpack = self.refresh_hwpack(kernel_matrix, hwpack, use_cache) |
211 | #make new hwpack downloadable |
212 | @@ -59,6 +68,10 @@ |
213 | LAVA_IMAGE_URL, hwpack]) |
214 | print " hwpack with new kernel: %s" % hwpack |
215 | |
216 | +======= |
217 | + logging.info("About to handle with the build") |
218 | + |
219 | +>>>>>>> MERGE-SOURCE |
220 | try: |
221 | boot_tgz, root_tgz = self.generate_tarballs(hwpack, rootfs, |
222 | use_cache) |
223 | @@ -131,16 +144,24 @@ |
224 | os.chmod(tarball_dir, 0755) |
225 | #fix me: if url is not http-prefix, copy it to tarball_dir |
226 | if use_cache: |
227 | + logging.info("Downloading the %s file using cache" % hwpack_url) |
228 | hwpack_path = download_with_cache(hwpack_url, tarball_dir, lava_cachedir) |
229 | + |
230 | + logging.info("Downloading the %s file using cache" % rootfs_url) |
231 | rootfs_path = download_with_cache(rootfs_url, tarball_dir, lava_cachedir) |
232 | else: |
233 | + logging.info("Downloading the %s file" % hwpack_url) |
234 | hwpack_path = download(hwpack_url, tarball_dir) |
235 | + |
236 | + logging.info("Downloading the %s file" % rootfs_url) |
237 | rootfs_path = download(rootfs_url, tarball_dir) |
238 | |
239 | image_file = os.path.join(tarball_dir, "lava.img") |
240 | cmd = ("sudo linaro-media-create --hwpack-force-yes --dev %s " |
241 | "--image_file %s --binary %s --hwpack %s --image_size 3G" % |
242 | (client.device_type, image_file, rootfs_path, hwpack_path)) |
243 | + logging.info("Executing the linaro-media-create command") |
244 | + logging.info(cmd) |
245 | rc, output = getstatusoutput(cmd) |
246 | if rc: |
247 | shutil.rmtree(tarball_dir) |
248 | @@ -163,7 +184,7 @@ |
249 | |
250 | def deploy_linaro_rootfs(self, rootfs): |
251 | client = self.client |
252 | - print "Deploying linaro image" |
253 | + logging.info("Deploying linaro image") |
254 | client.run_cmd_master('umount /dev/disk/by-label/testrootfs') |
255 | client.run_cmd_master( |
256 | 'mkfs.ext3 -q /dev/disk/by-label/testrootfs -L testrootfs') |
257 | @@ -189,6 +210,7 @@ |
258 | |
259 | def deploy_linaro_bootfs(self, bootfs): |
260 | client = self.client |
261 | + logging.info("Deploying linaro bootfs") |
262 | client.run_cmd_master('umount /dev/disk/by-label/testboot') |
263 | client.run_cmd_master( |
264 | 'mkfs.vfat /dev/disk/by-label/testboot -n testboot') |
265 | |
266 | === modified file 'lava_dispatcher/actions/launch_control.py' |
267 | --- lava_dispatcher/actions/launch_control.py 2011-09-20 02:35:31 +0000 |
268 | +++ lava_dispatcher/actions/launch_control.py 2011-09-22 10:41:46 +0000 |
269 | @@ -23,6 +23,8 @@ |
270 | import os |
271 | import shutil |
272 | import tarfile |
273 | +import logging |
274 | + |
275 | from lava_dispatcher.actions import BaseAction |
276 | from lava_dispatcher.client import OperationFailed |
277 | from lava_dispatcher.utils import download |
278 | @@ -33,8 +35,16 @@ |
279 | |
280 | class cmd_submit_results_on_host(BaseAction): |
281 | def run(self, server, stream): |
282 | +<<<<<<< TREE |
283 | dashboard = _get_dashboard(server) |
284 | |
285 | +======= |
286 | + logging.info("Executing submit_results_on_host command") |
287 | + xmlrpc_url = "%s/xml-rpc/" % server |
288 | + srv = xmlrpclib.ServerProxy(xmlrpc_url, |
289 | + allow_none=True, use_datetime=True) |
290 | + |
291 | +>>>>>>> MERGE-SOURCE |
292 | #Upload bundle files to dashboard |
293 | bundle_list = os.listdir("/tmp/%s" % self.context.lava_result_dir) |
294 | for bundle_name in bundle_list: |
295 | @@ -47,9 +57,9 @@ |
296 | print >> self.context.oob_file, 'dashboard-put-result:', \ |
297 | dashboard.put_ex(content, job_name, stream) |
298 | except xmlrpclib.Fault, err: |
299 | - print "xmlrpclib.Fault occurred" |
300 | - print "Fault code: %d" % err.faultCode |
301 | - print "Fault string: %s" % err.faultString |
302 | + logging.warning("xmlrpclib.Fault occurred") |
303 | + logging.warning("Fault code: %d" % err.faultCode) |
304 | + logging.warning("Fault string: %s" % err.faultString) |
305 | |
306 | # After uploading, remove the bundle file at the host side |
307 | os.remove(bundle) |
308 | @@ -63,8 +73,18 @@ |
309 | :param server: URL of the lava-dashboard server RPC endpoint |
310 | :param stream: Stream on the lava-dashboard server to save the result to |
311 | """ |
312 | +<<<<<<< TREE |
313 | #Create l-d server connection |
314 | dashboard = _get_dashboard(server) |
315 | +======= |
316 | + #Create l-c server connection |
317 | + xmlrpc_url = "%s/xml-rpc/" % server |
318 | + |
319 | + logging.info("Executing submit_results command to server "+xmlrpc_url) |
320 | + |
321 | + srv = xmlrpclib.ServerProxy(xmlrpc_url, |
322 | + allow_none=True, use_datetime=True) |
323 | +>>>>>>> MERGE-SOURCE |
324 | |
325 | client = self.client |
326 | try: |
327 | @@ -82,6 +102,7 @@ |
328 | client.run_cmd_master('umount /mnt/root') |
329 | |
330 | #Create tarball of all results |
331 | + logging.info("Creating lava results tarball") |
332 | client.run_cmd_master('cd /tmp') |
333 | client.run_cmd_master( |
334 | 'tar czf /tmp/lava_results.tgz -C /tmp/%s .' % self.context.lava_result_dir) |
335 | @@ -101,6 +122,8 @@ |
336 | |
337 | # download test result with a retry mechanism |
338 | # set retry timeout to 2mins |
339 | + |
340 | + logging.info("About to download the result tarball to host") |
341 | now = time.time() |
342 | timeout = 120 |
343 | try: |
344 | @@ -111,9 +134,10 @@ |
345 | if time.time() >= now+timeout: |
346 | raise |
347 | except: |
348 | - print traceback.format_exc() |
349 | + logging.warning(traceback.format_exc()) |
350 | status = 'fail' |
351 | err_msg = err_msg + " Can't retrieve test case results." |
352 | + logging.warning(err_msg) |
353 | |
354 | client.run_cmd_master('kill %1') |
355 | |
356 | @@ -127,15 +151,17 @@ |
357 | self.all_bundles.append(json.loads(content)) |
358 | tar.close() |
359 | except: |
360 | - print traceback.format_exc() |
361 | + logging.warning(traceback.format_exc()) |
362 | status = 'fail' |
363 | err_msg = err_msg + " Some test case result appending failed." |
364 | + logging.warning(err_msg) |
365 | finally: |
366 | shutil.rmtree(tarball_dir) |
367 | else: |
368 | status = 'fail' |
369 | err_msg = err_msg + "Getting master image IP address failed, \ |
370 | no test case result retrived." |
371 | + logging.warning(err_msg) |
372 | |
373 | #flush the serial log |
374 | client.run_shell_command("") |
375 | |
376 | === modified file 'lava_dispatcher/actions/lava-test.py' |
377 | --- lava_dispatcher/actions/lava-test.py 2011-09-16 02:37:57 +0000 |
378 | +++ lava_dispatcher/actions/lava-test.py 2011-09-22 10:41:46 +0000 |
379 | @@ -22,6 +22,8 @@ |
380 | |
381 | from datetime import datetime |
382 | import traceback |
383 | +import logging |
384 | + |
385 | from lava_dispatcher.actions import BaseAction |
386 | from lava_dispatcher.client import OperationFailed, CriticalError |
387 | |
388 | @@ -77,6 +79,7 @@ |
389 | |
390 | class cmd_lava_test_run(BaseAction): |
391 | def run(self, test_name, timeout=-1): |
392 | + logging.info("Executing lava_test_run %s command" % test_name) |
393 | #Make sure in test image now |
394 | client = self.client |
395 | client.in_test_shell() |
396 | @@ -96,6 +99,7 @@ |
397 | lava-test deployment to test image rootfs by chroot |
398 | """ |
399 | def run(self, tests, install_python = None, register = None, timeout=2400): |
400 | + logging.info("Executing lava_test_install (%s) command" % ",".join(tests)) |
401 | client = self.client |
402 | |
403 | _setup_testrootfs(client) |
404 | |
405 | === modified file 'lava_dispatcher/android_client.py' |
406 | --- lava_dispatcher/android_client.py 2011-09-08 04:28:39 +0000 |
407 | +++ lava_dispatcher/android_client.py 2011-09-22 10:41:46 +0000 |
408 | @@ -19,6 +19,8 @@ |
409 | |
410 | import pexpect |
411 | import sys |
412 | +import logging |
413 | + |
414 | from lava_dispatcher.client import LavaClient, OperationFailed |
415 | from utils import string_to_list |
416 | |
417 | @@ -80,7 +82,7 @@ |
418 | |
419 | def android_logcat_stop(self): |
420 | self.proc.sendcontrol('C') |
421 | - print "logcat cancelled" |
422 | + logging.info("logcat cancelled") |
423 | |
424 | # adb cound be connected through network |
425 | def android_adb_connect(self, dev_ip): |
426 | @@ -108,7 +110,7 @@ |
427 | self.run_cmd_tester( |
428 | 'netcfg %s dhcp' % network_interface, timeout=60) |
429 | except: |
430 | - print "netcfg %s dhcp exception" % network_interface |
431 | + logging.warning("netcfg %s dhcp exception" % network_interface) |
432 | return False |
433 | |
434 | # Check network ip and setup adb connection |
435 | @@ -119,7 +121,7 @@ |
436 | try: |
437 | id = self.proc.expect([ip_pattern, pexpect.EOF], timeout=60) |
438 | except: |
439 | - print "ifconfig can not match ip pattern" |
440 | + logging.warning("ifconfig can not match ip pattern") |
441 | return False |
442 | if id == 0: |
443 | match_group = self.proc.match.groups() |
444 | @@ -127,7 +129,7 @@ |
445 | device_ip = match_group[0] |
446 | adb_status, dev_name = self.android_adb_connect(device_ip) |
447 | if adb_status == True: |
448 | - print "dev_name = " + dev_name |
449 | + logging.info("dev_name = " + dev_name) |
450 | result = self.run_adb_shell_command(dev_name, "echo 1", "1") |
451 | self.android_adb_disconnect(device_ip) |
452 | return result |
453 | |
454 | === modified file 'lava_dispatcher/client.py' |
455 | --- lava_dispatcher/client.py 2011-09-15 07:02:08 +0000 |
456 | +++ lava_dispatcher/client.py 2011-09-22 10:41:46 +0000 |
457 | @@ -24,6 +24,7 @@ |
458 | from cStringIO import StringIO |
459 | import traceback |
460 | from utils import string_to_list |
461 | +import logging |
462 | |
463 | class LavaClient(object): |
464 | def __init__(self, context, config): |
465 | @@ -203,7 +204,7 @@ |
466 | try: |
467 | self.wait_network_up() |
468 | except: |
469 | - print traceback.format_exc() |
470 | + logging.warning(traceback.format_exc()) |
471 | return None |
472 | #tty device uses minimal match, see pexpect wiki |
473 | #pattern1 = ".*\n(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})" |
474 | @@ -215,10 +216,10 @@ |
475 | #self.proc.sendline("") |
476 | id = self.proc.expect([pattern1, pexpect.EOF, |
477 | pexpect.TIMEOUT], timeout=5) |
478 | - print "\nmatching pattern is %s" % id |
479 | + logging.info("\nmatching pattern is %s" % id) |
480 | if id == 0: |
481 | ip = self.proc.match.groups()[0] |
482 | - print "Master IP is %s" % ip |
483 | + logging.info("Master IP is %s" % ip) |
484 | return ip |
485 | else: |
486 | return None |
487 | |
488 | === modified file 'lava_dispatcher/config.py' |
489 | --- lava_dispatcher/config.py 2011-09-09 00:52:17 +0000 |
490 | +++ lava_dispatcher/config.py 2011-09-22 10:41:46 +0000 |
491 | @@ -21,6 +21,7 @@ |
492 | from ConfigParser import ConfigParser |
493 | import os |
494 | import StringIO |
495 | +import logging |
496 | |
497 | |
498 | default_config_path = os.path.join( |
499 | @@ -60,7 +61,7 @@ |
500 | config_files.reverse() |
501 | if cp is None: |
502 | cp = ConfigParser() |
503 | - print "About to read %s" % str(config_files) |
504 | + logging.debug("About to read %s" % str(config_files)) |
505 | for path in config_files: |
506 | _read_into(path, cp) |
507 | return cp |
508 | |
509 | === modified file 'lava_dispatcher/default-config/lava-dispatcher/README' |
510 | --- lava_dispatcher/default-config/lava-dispatcher/README 2011-09-08 23:35:05 +0000 |
511 | +++ lava_dispatcher/default-config/lava-dispatcher/README 2011-09-22 10:41:46 +0000 |
512 | @@ -39,3 +39,7 @@ |
513 | a line "device_type = <device type>", although other settings can |
514 | be included here. You will definitely need to tell lava-dispatcher |
515 | about the devices you have! |
516 | + |
517 | +* logging.conf |
518 | + |
519 | + This file defines settings for Python logging |
520 | \ No newline at end of file |
521 | |
522 | === modified file 'lava_dispatcher/default-config/lava-dispatcher/lava-dispatcher.conf' |
523 | --- lava_dispatcher/default-config/lava-dispatcher/lava-dispatcher.conf 2011-09-08 23:35:05 +0000 |
524 | +++ lava_dispatcher/default-config/lava-dispatcher/lava-dispatcher.conf 2011-09-22 10:41:46 +0000 |
525 | @@ -17,3 +17,5 @@ |
526 | # Location for caching downloaded artifacts such as hwpacks and images |
527 | LAVA_CACHEDIR = /linaro/images/cache |
528 | |
529 | +# Enable python logging level to debug. 0 - logging level is INFO, 1- logging level is DEBUG |
530 | +LOGGING_LEVEL_DEBUG = 0 |
531 | \ No newline at end of file |
9 +def dispatcher_ print(msg) : DISPATCHER> > %s"%msg
10 + print "\n<<LAVA_
do you consider if some message will redirect to sys.stderr? Currently there is no such statement.
There are also android_0xbench.py and android_basic.py existing print statements if you want to make all actions use the function.