Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1080760 - generate bug suggestions for text_log_summary artifacts
Whenever a ``text_log_summary`` with ``error_lines`` is submitted, generate an additional ``Bug suggestions`` artifact for it.
- Loading branch information
Cameron Dawson
committed
Apr 28, 2015
1 parent
2d9629f
commit 3fa859e
Showing
5 changed files
with
302 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import logging | ||
|
||
from django.utils.encoding import python_2_unicode_compatible | ||
from django.conf import settings | ||
|
||
from thclient import TreeherderRequest | ||
|
||
from treeherder.etl.oauth_utils import OAuthCredentials | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def post_treeherder_collections(th_collections): | ||
errors = [] | ||
for project in th_collections: | ||
|
||
credentials = OAuthCredentials.get_credentials(project) | ||
|
||
th_request = TreeherderRequest( | ||
protocol=settings.TREEHERDER_REQUEST_PROTOCOL, | ||
host=settings.TREEHERDER_REQUEST_HOST, | ||
project=project, | ||
oauth_key=credentials.get('consumer_key', None), | ||
oauth_secret=credentials.get('consumer_secret', None) | ||
) | ||
|
||
logger.info( | ||
"collection loading request: {0}".format( | ||
th_request.get_uri(th_collections[project].endpoint_base))) | ||
response = th_request.post(th_collections[project]) | ||
|
||
if not response or response.status == 200: | ||
errors.append({ | ||
"project": project, | ||
"url": th_collections[project].endpoint_base, | ||
"message": response.read() | ||
}) | ||
if errors: | ||
raise CollectionNotLoadedException(errors) | ||
|
||
|
||
@python_2_unicode_compatible | ||
class CollectionNotLoadedException(Exception): | ||
|
||
def __init__(self, error_list, *args, **kwargs): | ||
""" | ||
error_list contains dictionaries, each containing | ||
project, url and message | ||
""" | ||
super(CollectionNotLoadedException, self).__init__(args, kwargs) | ||
self.error_list = error_list | ||
|
||
def __str__(self): | ||
return "\n".join( | ||
["[{project}] Error posting data to {url}: {message}".format( | ||
**error) for error in self.error_list] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.