diff options
Diffstat (limited to 'lib/python2.7/site-packages/buildbot-0.8.8-py2.7.egg/buildbot/status/web/hooks/googlecode.py')
-rw-r--r-- | lib/python2.7/site-packages/buildbot-0.8.8-py2.7.egg/buildbot/status/web/hooks/googlecode.py | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/lib/python2.7/site-packages/buildbot-0.8.8-py2.7.egg/buildbot/status/web/hooks/googlecode.py b/lib/python2.7/site-packages/buildbot-0.8.8-py2.7.egg/buildbot/status/web/hooks/googlecode.py deleted file mode 100644 index f40cf174..00000000 --- a/lib/python2.7/site-packages/buildbot-0.8.8-py2.7.egg/buildbot/status/web/hooks/googlecode.py +++ /dev/null @@ -1,87 +0,0 @@ -# This file is part of Buildbot. Buildbot is free software: you can -# redistribute it and/or modify it under the terms of the GNU General Public -# License as published by the Free Software Foundation, version 2. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Copyright 2011, Louis Opter <kalessin@kalessin.fr> - -# Quite inspired from the github hook. - -import hmac -from twisted.python import log -from buildbot.util import json - -class GoogleCodeAuthFailed(Exception): - pass - -class Payload(object): - def __init__(self, headers, body, branch): - self._auth_code = headers['Google-Code-Project-Hosting-Hook-Hmac'] - self._body = body # we need to save it if we want to authenticate it - self._branch = branch - - payload = json.loads(body) - self.project = payload['project_name'] - self.repository = payload['repository_path'] - self.revisions = payload['revisions'] - self.revision_count = payload['revision_count'] - - def authenticate(self, secret_key): - m = hmac.new(secret_key) - m.update(self._body) - digest = m.hexdigest() - return digest == self._auth_code - - def changes(self): - changes = [] - - for r in self.revisions: - files = set() - files.update(r['added']) - files.update(r['modified']) - files.update(r['removed']) - changes.append(dict( - author=r['author'], - files=list(files), - comments=r['message'], - revision=r['revision'], - when=r['timestamp'], - # Let's hope Google add the branch one day: - branch=r.get('branch', self._branch), - revlink=r['url'], - repository=self.repository, - project=self.project - )) - - return changes - -def getChanges(request, options=None): - headers = request.received_headers - body = request.content.getvalue() - - # Instantiate a Payload object: this will parse the body, get the - # authentication code from the headers and remember the branch picked - # up by the user (Google Code doesn't send on which branch the changes - # were made) - payload = Payload(headers, body, options.get('branch', 'default')) - - if 'secret_key' in options: - if not payload.authenticate(options['secret_key']): - raise GoogleCodeAuthFailed() - else: - log.msg("Missing secret_key in the Google Code WebHook options: " - "cannot authenticate the request!") - - log.msg('Received %d changes from Google Code' % - (payload.revision_count,)) - changes = payload.changes() - - return changes, 'Google Code' |