139
140
kws['stdin'] = subprocess.PIPE
140
141
kws['stdout'] = subprocess.PIPE
141
142
kws['stderr'] = subprocess.PIPE
142
if hint in ('cvs', 'svn'):
143
if hint in ('cvs', 'svn', 'hg-update.py'):
143
144
def format_line(line, error_output, fp=self.phasefp):
144
145
if line[-1] == '\n': line = line[:-1]
175
176
p = subprocess.Popen(command, **kws)
176
177
except OSError, e:
177
self.phasefp.write('<span class="error">Error: %s</span>\n' % escape(str(e)))
178
self.phasefp.write('<span class="error">' + _('Error: %s') % escape(str(e)) + '</span>\n')
178
179
raise CommandError(str(e))
180
181
cmds.pprint_output(p, format_line)
181
182
if p.returncode != 0:
182
raise CommandError('Error running %s' % command, p.returncode)
183
raise CommandError(_('Error running %s') % command, p.returncode)
184
185
def start_build(self):
185
186
self.server = ServerProxy(self.xmlrpc_report_url, allow_none = True)
206
207
self.build_id = self.server.start_build(info)
207
208
except xmlrpclib.ProtocolError, e:
208
209
if e.errcode == 403:
209
print >> sys.stderr, 'ERROR: Wrong credentials, please check username/password'
210
print >> sys.stderr, _('ERROR: Wrong credentials, please check username/password')
215
s = 'Starting Build #%s' % self.build_id
216
s = _('Starting Build #%s') % self.build_id
217
218
print '=' * len(s)
237
238
self.modulefp = None
238
239
self.server.end_module(self.build_id, module, compress_data(log), failed)
240
def start_phase(self, module, state):
241
self.server.start_phase(self.build_id, module, state)
241
def start_phase(self, module, phase):
242
self.server.start_phase(self.build_id, module, phase)
243
TerminalBuildScript.start_phase(self, module, state)
244
TerminalBuildScript.start_phase(self, module, phase)
244
245
self.phasefp = StringIO()
247
def end_phase(self, module, state, error):
248
def end_phase(self, module, phase, error):
248
249
log = fix_encoding(self.phasefp.getvalue())
249
250
self.phasefp = None
250
self.server.end_phase(self.build_id, module, state, compress_data(log), error)
252
def handle_error(self, module, state, nextstate, error, altstates):
253
if self.modules == {}:
254
self.modules = jhbuild.moduleset.load_tests(self.config)
256
if module in self.modules.modules.keys() \
257
and self.modules.modules[module].test_type == 'ldtp':
258
self._upload_logfile(module)
259
self.server.end_phase(self.build_id, module, phase, compress_data(log), error)
261
def handle_error(self, module, phase, nextphase, error, altphases):
253
262
'''handle error during build'''
254
print 'handle error!'
263
print 'FIXME: handle error! (failed build: %s: %s)' % (module, error)
266
def _upload_ldtp_logfile (self, module):
267
test_module = self.modules.modules[module]
268
src_dir = test_module.get_srcdir()
269
if not os.path.exists (os.path.join(src_dir,'run.xml')):
271
logfile = test_module.get_ldtp_log_file (os.path.join(src_dir,'run.xml'))
272
if not os.path.exists (logfile):
274
self._upload_logfile (module, logfile, 'application/x-ldtp+xml')
276
def _upload_logfile (self, module, logfile, mimetype):
277
log = open (logfile, 'r')
278
basename = os.path.basename (logfile)
279
self.server.attach_file (self.build_id, module, 'test', basename,
280
compress_data(log.read()), mimetype)
258
283
BUILD_SCRIPT = AutobuildBuildScript