Lines 24-29
Link Here
|
24 |
|
24 |
|
25 |
import os.path, re, pwd, grp |
25 |
import os.path, re, pwd, grp |
26 |
|
26 |
|
|
|
27 |
from os import strerror |
28 |
from subprocess import PIPE, Popen |
29 |
from multiprocessing import Pipe |
27 |
from WebappConfig.debug import OUT |
30 |
from WebappConfig.debug import OUT |
28 |
import WebappConfig.wrapper as wrapper |
31 |
import WebappConfig.wrapper as wrapper |
29 |
from WebappConfig.sandbox import Sandbox |
32 |
from WebappConfig.sandbox import Sandbox |
Lines 93-98
Link Here
|
93 |
|
96 |
|
94 |
''' |
97 |
''' |
95 |
|
98 |
|
|
|
99 |
class HookedScriptError(Exception): |
100 |
''' Exception thrown when a hook script fails ''' |
101 |
|
102 |
def __init__(self, script, errno): |
103 |
self.errno = errno |
104 |
self.script= script |
105 |
|
106 |
def __str__(self): |
107 |
cmd = "'" + self.script + "'" |
108 |
if self.errno < 0: |
109 |
return cmd + " was terminated by signal " + repr(-self.errno) |
110 |
else: |
111 |
return cmd + " terminated with error status " + repr(self.errno) |
112 |
|
113 |
|
96 |
def __init__(self, config): |
114 |
def __init__(self, config): |
97 |
|
115 |
|
98 |
self.__root = wrapper.get_root() |
116 |
self.__root = wrapper.get_root() |
Lines 130-152
Link Here
|
130 |
os.access(self.__hooksd + '/' + x, os.X_OK)): |
148 |
os.access(self.__hooksd + '/' + x, os.X_OK)): |
131 |
|
149 |
|
132 |
OUT.debug('Running hook script', 7) |
150 |
OUT.debug('Running hook script', 7) |
133 |
|
151 |
cmd = self.__hooksd + '/' + x + ' '+ type |
134 |
fi, fo, fe = os.popen3(self.__hooksd + '/' + x + ' ' |
152 |
try: |
135 |
+ type) |
153 |
p = Popen(cmd,shell=True,bufsize=1,stdin=None, |
136 |
fi.close() |
154 |
stdout=PIPE,stderr=PIPE,close_fds=True, |
137 |
result_lines = fo.readlines() |
155 |
universal_newlines=True) |
138 |
error_lines = fe.readlines() |
156 |
|
139 |
fo.close() |
157 |
(fo,fe) = p.communicate() |
140 |
fe.close() |
158 |
|
141 |
|
159 |
if fo: |
142 |
if result_lines: |
160 |
OUT.notice(fo) |
143 |
for i in result_lines: |
161 |
|
144 |
OUT.notice(i) |
162 |
if fe and p.returncode != 0: |
145 |
|
163 |
OUT.error(fe) |
146 |
if error_lines: |
164 |
else: |
147 |
for i in error_lines: |
165 |
OUT.warn(fe) |
148 |
OUT.warn(i) |
166 |
|
149 |
|
167 |
if p.returncode: |
|
|
168 |
raise Ebuild.HookedScriptError(cmd, p.returncode) |
169 |
|
170 |
except Exception, e: |
171 |
sandbox.stop() |
172 |
# remove OUT.die when WebAppConfig finally |
173 |
# provides at least a catch-all exception handler |
174 |
# OUT.error(e) |
175 |
OUT.die(e) |
176 |
raise |
150 |
sandbox.stop() |
177 |
sandbox.stop() |
151 |
|
178 |
|
152 |
def show_post(self, filename, ptype, server = None): |
179 |
def show_post(self, filename, ptype, server = None): |