| Total Complexity | 4 | 
| Total Lines | 19 | 
| Duplicated Lines | 0 % | 
| 1 | import httplib  | 
            ||
| 6 | class GetBuildNumberAction(CircleCI):  | 
            ||
| 7 | |||
| 8 | def run(self, vcs_revision, project, search_limit=10):  | 
            ||
| 9 | """  | 
            ||
| 10 | Get build number for a SHA in project.  | 
            ||
| 11 | """  | 
            ||
| 12 | path = 'project/' + project  | 
            ||
| 13 | |||
| 14 | response = self._perform_request(  | 
            ||
| 15 | path, method='GET',  | 
            ||
| 16 |             extra_headers={'limit': int(search_limit)} | 
            ||
| 17 | )  | 
            ||
| 18 | |||
| 19 | if response.status_code != httplib.OK:  | 
            ||
| 20 |             raise Exception('Project %s not found.' % project) | 
            ||
| 21 | |||
| 22 | for build in response.json:  | 
            ||
| 23 | if build['vcs_revision'] == vcs_revision:  | 
            ||
| 24 | return build['build_number']  | 
            ||
| 25 |