Updated method names
This commit is contained in:
parent
89305ec602
commit
dbf00e0ed5
|
@ -1,23 +1,24 @@
|
|||
"""Transifex webhook handler """
|
||||
import os
|
||||
import base64
|
||||
|
||||
import time
|
||||
import json
|
||||
import hmac
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import os
|
||||
import requests
|
||||
import time
|
||||
|
||||
from subprocess import call
|
||||
from base64 import b64encode
|
||||
import requests
|
||||
|
||||
from buildbot.process.properties import Properties
|
||||
from buildbot.util import bytes2unicode, unicode2bytes
|
||||
from buildbot.www.hooks.base import BaseHookHandler
|
||||
|
||||
from dateutil.parser import parse as dateparse
|
||||
|
||||
from twisted.internet import defer
|
||||
from twisted.python import log
|
||||
|
||||
from dateutil.parser import parse as dateparse
|
||||
|
||||
_HEADER_USER_AGENT = 'User-Agent'
|
||||
_HEADER_SIGNATURE = 'X-TX-Signature'
|
||||
|
@ -42,7 +43,7 @@ class TransifexHandler(BaseHookHandler):
|
|||
output = json.dumps({"status": "OK" if status else "FAIL", "message": message})
|
||||
return [output, [('Content-type', 'application/json')]]
|
||||
|
||||
def verifyTransifexSignature(
|
||||
def _verifyTransifexSignature(
|
||||
self, request, content, signature, header_signature
|
||||
):
|
||||
http_verb = 'POST'
|
||||
|
@ -64,28 +65,23 @@ class TransifexHandler(BaseHookHandler):
|
|||
|
||||
if signature != request.getHeader(_HEADER_SIGNATURE):
|
||||
return False
|
||||
return True
|
||||
|
||||
def process_translation_completed(self, payload, transifex_dict, event_type, codebase):
|
||||
changes = []
|
||||
transifex_response = self._transform_variables(payload, transifex_dict)
|
||||
if 'pybitmessage-test' in transifex_response['project'] and 'messagespot' in transifex_response['resource']:
|
||||
if 'translation_completed' in transifex_response['event']:
|
||||
ts = int(time.time())
|
||||
# if 'pybitmessage-test' in transifex_response['project'] and 'messagespot' in transifex_response['resource']:
|
||||
# if 'translation_completed' in transifex_response['event']:
|
||||
try:
|
||||
lang = transifex_response['language']
|
||||
return
|
||||
except Exception as exception:
|
||||
raise KeyError('No such key found: ' + str(exception))
|
||||
|
||||
# if isinstance(self.options, dict):
|
||||
# commits = commits[:1]
|
||||
|
||||
# # for commit in commits:
|
||||
# # files = []
|
||||
# # for kind in ('added', 'modified', 'removed'):
|
||||
# # files.extend(commit.get(kind, []) or [])
|
||||
change = {
|
||||
'author': 'buildbot-transifex,
|
||||
'resource': transifex_response['resource'],
|
||||
'author': 'buildbot-transifex',
|
||||
'resource': transifex_dict['resource'],
|
||||
'branch': transifex_dict['branch'],
|
||||
'project': transifex_response['project'],
|
||||
'project': transifex_dict['project'],
|
||||
'event': event_type,
|
||||
'properties': {
|
||||
'branch': branch,
|
||||
|
@ -133,7 +129,7 @@ class TransifexHandler(BaseHookHandler):
|
|||
digestmod=hashlib.sha256)
|
||||
header_signature = bytes2unicode(
|
||||
request.getHeader(_HEADER_SIGNATURE))
|
||||
self.verifyTransifexSignature(
|
||||
self._verifyTransifexSignature(
|
||||
request, content, self.rendered_secret,
|
||||
signature, header_signature
|
||||
)
|
||||
|
@ -143,11 +139,13 @@ class TransifexHandler(BaseHookHandler):
|
|||
project = payload.get("project", 'None')
|
||||
resource = payload.get("resource", 'None')
|
||||
|
||||
transifex_request_data['branch'] = "v0.6"
|
||||
transifex_request_data['branch'] = transifex_dict['branch']
|
||||
transifex_request_data['revision'] = ""
|
||||
transifex_request_data["properties"] = "langugage"
|
||||
transifex_request_data["properties"] = "resource"
|
||||
transifex_request_data["properties"] = "project"
|
||||
transifex_request_data["properties"] = {
|
||||
"transifex_language": language,
|
||||
"transifex_resource": resource,
|
||||
"transifex_project": project
|
||||
}
|
||||
|
||||
transifex_request_data["properties"] = {
|
||||
"branch": branch,
|
||||
|
|
Loading…
Reference in New Issue
Block a user