Mercurial > bitten > bitten-test
comparison bitten/master.py @ 758:d11ef8024d7c
Make all times be generated by the server. This eliminates a number of inconsistencies you'll see when the clocks on the slaves are skewed from the master.
author | wbell |
---|---|
date | Sat, 24 Apr 2010 14:28:41 +0000 |
parents | 545be0c8f405 |
children | b2272caf5ac4 |
comparison
equal
deleted
inserted
replaced
756:3fbc7672640e | 758:d11ef8024d7c |
---|---|
279 elem.attr['status']) | 279 elem.attr['status']) |
280 | 280 |
281 db = self.env.get_db_cnx() | 281 db = self.env.get_db_cnx() |
282 | 282 |
283 step = BuildStep(self.env, build=build.id, name=stepname) | 283 step = BuildStep(self.env, build=build.id, name=stepname) |
284 try: | 284 |
285 step.started = int(_parse_iso_datetime(elem.attr['time'])) | 285 # not a great way to determine the start/stop time of the |
286 step.stopped = step.started + float(elem.attr['duration']) | 286 # step, but it's a server time, which eliminates a bunch |
287 except ValueError, e: | 287 # of skew issues. |
288 self.log.error('Error parsing build step timestamp: %s', e, | 288 now = int(time.time()) |
289 exc_info=True) | 289 step.started = now - float(elem.attr['duration']) |
290 self._send_error(req, HTTP_BAD_REQUEST, e.args[0]) | 290 step.stopped = now |
291 | |
291 if elem.attr['status'] == 'failure': | 292 if elem.attr['status'] == 'failure': |
292 self.log.warning('Build %s step %s failed', build.id, stepname) | 293 self.log.warning('Build %s step %s failed', build.id, stepname) |
293 step.status = BuildStep.FAILURE | 294 step.status = BuildStep.FAILURE |
294 if current_step.onerror == 'fail': | 295 if current_step.onerror == 'fail': |
295 last_step = True | 296 last_step = True |
373 'Content-Type': 'text/plain', | 374 'Content-Type': 'text/plain', |
374 'Content-Length': str(len(body)), | 375 'Content-Length': str(len(body)), |
375 'Location': req.abs_href.builds( | 376 'Location': req.abs_href.builds( |
376 build.id, 'steps', stepname)}) | 377 build.id, 'steps', stepname)}) |
377 | 378 |
378 | |
379 def _parse_iso_datetime(string): | |
380 """Minimal parser for ISO date-time strings. | |
381 | |
382 Return the time as floating point number. Only handles UTC timestamps | |
383 without time zone information.""" | |
384 try: | |
385 string = string.split('.', 1)[0] # strip out microseconds | |
386 return calendar.timegm(time.strptime(string, '%Y-%m-%dT%H:%M:%S')) | |
387 except ValueError, e: | |
388 raise ValueError('Invalid ISO date/time %r' % string) |