10637.3.1
by Guilherme Salgado
Use the default python version instead of a hard-coded version |
1 |
#! /usr/bin/python -S
|
8687.15.4
by Karl Fogel
Add the copyright header block to more files; tweak format in a few files. |
2 |
#
|
3 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
|
|
4 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
5 |
||
8486.12.1
by Celso Providelo
Fixing the 'fixable' scripts and adding a checker with the really-broken ones blacklisted. |
6 |
"""Check that all the launchpad scripts and cronscripts run.
|
7 |
||
8 |
Usage hint:
|
|
9 |
||
10 |
% utilities/check-scripts.py
|
|
11 |
"""
|
|
8847.1.1
by Celso Providelo
Integrating the tree script checker into the test suite. |
12 |
# pylint: disable-msg=W0403
|
9641.1.4
by Gary Poster
more updates for _pythonpath. Still need to update all subprocess calls to python to use -S; still need to update z3c.recipe.filetemplate to provide sys.modules from -S run. |
13 |
import _pythonpath |
14 |
||
8486.12.1
by Celso Providelo
Fixing the 'fixable' scripts and adding a checker with the really-broken ones blacklisted. |
15 |
import os |
16 |
import sys |
|
17 |
||
8847.1.1
by Celso Providelo
Integrating the tree script checker into the test suite. |
18 |
from lp.services.scripts.tests import find_lp_scripts |
19 |
from lp.testing import run_script |
|
8486.12.1
by Celso Providelo
Fixing the 'fixable' scripts and adding a checker with the really-broken ones blacklisted. |
20 |
|
21 |
||
22 |
def check_script(script_path): |
|
23 |
"""Run the given script in a subprocess and report its result.
|
|
24 |
||
25 |
Check if the script successfully runs if 'help' is requested via
|
|
26 |
command line argument ('-h').
|
|
27 |
"""
|
|
28 |
sys.stdout.write('Checking: %s ' % script_path) |
|
29 |
sys.stdout.flush() |
|
8847.1.1
by Celso Providelo
Integrating the tree script checker into the test suite. |
30 |
cmd_line = script_path + " -h" |
31 |
out, err, returncode = run_script(cmd_line) |
|
32 |
if returncode != os.EX_OK: |
|
8486.12.1
by Celso Providelo
Fixing the 'fixable' scripts and adding a checker with the really-broken ones blacklisted. |
33 |
sys.stdout.write('... FAILED\n') |
8847.1.1
by Celso Providelo
Integrating the tree script checker into the test suite. |
34 |
sys.stdout.write('%s\n' % err) |
8486.12.1
by Celso Providelo
Fixing the 'fixable' scripts and adding a checker with the really-broken ones blacklisted. |
35 |
else: |
36 |
sys.stdout.write('... OK\n') |
|
37 |
sys.stdout.flush() |
|
38 |
||
39 |
||
40 |
def main(): |
|
41 |
"""Walk over the specified script locations and check them."""
|
|
8847.1.1
by Celso Providelo
Integrating the tree script checker into the test suite. |
42 |
for script_path in find_lp_scripts(): |
43 |
check_script(script_path) |
|
8486.12.1
by Celso Providelo
Fixing the 'fixable' scripts and adding a checker with the really-broken ones blacklisted. |
44 |
|
45 |
||
46 |
if __name__ == '__main__': |
|
47 |
sys.exit(main()) |