| Conditions | 4 | 
| Total Lines | 28 | 
| Lines | 0 | 
| Ratio | 0 % | 
| 1 | import httplib  | 
            ||
| 9 | def run(self, build_number, project, wait_timeout=600):  | 
            ||
| 10 | """  | 
            ||
| 11 | Get build number for a SHA in project.  | 
            ||
| 12 | """  | 
            ||
| 13 | path = 'project/%s/%s' % (project, build_number)  | 
            ||
| 14 | |||
| 15 | start_time = time.time()  | 
            ||
| 16 | done = False  | 
            ||
| 17 | while not done:  | 
            ||
| 18 | response = self._perform_request(  | 
            ||
| 19 | path, method='GET',  | 
            ||
| 20 | )  | 
            ||
| 21 | |||
| 22 | if response.status_code != httplib.OK:  | 
            ||
| 23 |                 msg = ('Build number %s for project ' % build_number + | 
            ||
| 24 | '%s not found.' % project)  | 
            ||
| 25 | raise Exception(msg)  | 
            ||
| 26 | |||
| 27 | response = response.json()  | 
            ||
| 28 | |||
| 29 | if response['lifecycle'] == 'finished':  | 
            ||
| 30 | return True  | 
            ||
| 31 | |||
| 32 | time.sleep(10)  | 
            ||
| 33 | done = (time.time() - start_time) > wait_timeout  | 
            ||
| 34 | |||
| 35 |         raise Exception('Build did not complete within %s seconds.' % | 
            ||
| 36 | wait_timeout)  | 
            ||
| 37 |