Merge lp:~jml/pkgme/pickleable-exceptions into lp:pkgme

Proposed by Jonathan Lange
Status: Merged
Merged at revision: 87
Proposed branch: lp:~jml/pkgme/pickleable-exceptions
Merge into: lp:pkgme
Diff against target: 46 lines (+8/-8)
1 file modified
pkgme/run_script.py (+8/-8)
To merge this branch: bzr merge lp:~jml/pkgme/pickleable-exceptions
Reviewer Review Type Date Requested Status
pkgme committers Pending
Review via email: mp+83171@code.launchpad.net

Description of the change

Turns out that celery pickles exceptions, and that you need to pass arguments to the parent classes in order to have exceptions pickle and unpickle successfully. Pickling is important for getting full error messages out of the tasks. In particular, the custom logic that we used to show the output from failed pkgme scripts wasn't getting used until I applied this patch.

http://celery.readthedocs.org/en/latest/userguide/tasks.html#creating-pickleable-exceptions

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'pkgme/run_script.py'
2--- pkgme/run_script.py 2011-10-31 16:18:41 +0000
3+++ pkgme/run_script.py 2011-11-23 14:31:37 +0000
4@@ -9,15 +9,15 @@
5
6 class ScriptProblem(PkgmeError):
7
8- def __init__(self, script_path):
9- super(ScriptProblem, self).__init__()
10+ def __init__(self, script_path, *args):
11+ super(ScriptProblem, self).__init__(script_path, *args)
12 self.script_path = script_path
13
14
15 class ScriptMissing(ScriptProblem):
16
17- def __init__(self, script_path):
18- super(ScriptMissing, self).__init__(script_path)
19+ def __init__(self, script_path, *args):
20+ super(ScriptMissing, self).__init__(script_path, *args)
21
22 def __str__(self):
23 return "%s not found" % (self.script_path, )
24@@ -26,18 +26,18 @@
25 class ScriptPermissionDenied(ScriptProblem):
26 """Attempting to run a script led to a permission denied error."""
27
28- def __init__(self, script_path):
29- super(ScriptPermissionDenied, self).__init__(script_path)
30+ def __init__(self, script_path, *args):
31+ super(ScriptPermissionDenied, self).__init__(script_path, *args)
32
33 def __str__(self):
34- return ("permission denied trying to execute %s, is it executable?"
35+ return ("permission denied trying to execute %s, is it executable?"
36 % (self.script_path, ))
37
38
39 class ScriptFailed(ScriptProblem):
40
41 def __init__(self, command, returncode, output_lines):
42- super(ScriptFailed, self).__init__(command[0])
43+ super(ScriptFailed, self).__init__(command, returncode, output_lines)
44 self.command = command
45 self.returncode = returncode
46 self.output_lines = output_lines

Subscribers

People subscribed via source and target branches