1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
Launchpad Scripts
=================
Launchpad scripts are built using the LaunchpadScript class in
lp.services.scripts.base. This, along with the LaunchpadCronScript
specialization, implement common behavior for all Launchpad command
line scripts.
>>> from lp.services.scripts.base import (
... LaunchpadScript, LaunchpadCronScript)
Scripts report their executution using the standard Python logging
module, with command line arguments and logging setup provided by
LaunchpadScript. Unhandled exceptions from scripts are automatically
sent to the Python logging system. Cronscripts (scripts using
LaunchpadCronScript) also log warnings and and errors as OOPS reports.
>>> import os.path, subprocess, sys
>>> from lp.services.config import config
>>> cronscript_crash_path = os.path.join(
... config.root, 'lib', 'lp', 'services', 'scripts', 'tests',
... 'cronscript-crash.py')
>>> p = subprocess.Popen(
... [sys.executable, cronscript_crash_path, '-vq'],
... stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
... stdin=subprocess.PIPE)
>>> print p.communicate()[0]
INFO Creating lockfile: ...
WARNING This is a warning
INFO New OOPS detected
CRITICAL This is critical
INFO New OOPS detected
ERROR Unhandled exception
...
NotImplementedError: Whoops
>>> p.returncode
1
|