mirror of
https://github.com/buildbot/buildbot.git
synced 2021-05-20 10:47:20 +03:00
www: Reduce excessive line length
This commit is contained in:
@@ -117,11 +117,13 @@ class RemoteUserAuth(AuthBase):
|
||||
def maybeAutoLogin(self, request):
|
||||
header = request.getHeader(self.header)
|
||||
if header is None:
|
||||
raise Error(403, b"missing http header " + self.header + b". Check your reverse proxy config!")
|
||||
msg = b"missing http header " + self.header + b". Check your reverse proxy config!"
|
||||
raise Error(403, msg)
|
||||
res = self.headerRegex.match(header)
|
||||
if res is None:
|
||||
raise Error(
|
||||
403, b'http header does not match regex! "' + header + b'" not matching ' + self.headerRegex.pattern)
|
||||
msg = b'http header does not match regex! "' + header + b'" not matching ' + \
|
||||
self.headerRegex.pattern
|
||||
raise Error(403, msg)
|
||||
session = request.getSession()
|
||||
user_info = {k: bytes2unicode(v) for k, v in res.groupdict().items()}
|
||||
if session.user_info != user_info:
|
||||
|
||||
@@ -83,7 +83,8 @@ class Match:
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def getOwnerFromBuildsetOrBuildRequest(self, buildsetorbuildrequest):
|
||||
props = yield self.master.data.get(("buildsets", buildsetorbuildrequest['buildsetid'], "properties"))
|
||||
props = yield self.master.data.get(("buildsets", buildsetorbuildrequest['buildsetid'],
|
||||
"properties"))
|
||||
if 'owner' in props:
|
||||
return props['owner'][0]
|
||||
return None
|
||||
|
||||
@@ -115,13 +115,14 @@ class ChangeHookResource(resource.Resource):
|
||||
if dialect not in self.dialects:
|
||||
m = "The dialect specified, '{}', wasn't whitelisted in change_hook".format(dialect)
|
||||
log.msg(m)
|
||||
log.msg(
|
||||
"Note: if dialect is 'base' then it's possible your URL is malformed and we didn't regex it properly")
|
||||
log.msg("Note: if dialect is 'base' then it's possible your URL is "
|
||||
"malformed and we didn't regex it properly")
|
||||
raise ValueError(m)
|
||||
|
||||
if dialect not in self._dialect_handlers:
|
||||
if dialect not in self._plugins:
|
||||
m = "The dialect specified, '{}', is not registered as a buildbot.webhook plugin".format(dialect)
|
||||
m = ("The dialect specified, '{}', is not registered as "
|
||||
"a buildbot.webhook plugin").format(dialect)
|
||||
log.msg(m)
|
||||
raise ValueError(m)
|
||||
options = self.dialects[dialect]
|
||||
|
||||
@@ -344,7 +344,8 @@ class GitHubHandler(BaseHookHandler):
|
||||
'codebase': options.get('codebase', None),
|
||||
'github_property_whitelist': options.get('github_property_whitelist', None),
|
||||
'skips': options.get('skips', None),
|
||||
'github_api_endpoint': options.get('github_api_endpoint', None) or 'https://api.github.com',
|
||||
'github_api_endpoint':
|
||||
options.get('github_api_endpoint', None) or 'https://api.github.com',
|
||||
'pullrequest_ref': options.get('pullrequest_ref', None) or 'merge',
|
||||
'token': options.get('token', None),
|
||||
'debug': options.get('debug', None) or False,
|
||||
|
||||
@@ -108,7 +108,8 @@ class GitLabHandler(BaseHookHandler):
|
||||
when_timestamp = dateparse(commit['timestamp'])
|
||||
# @todo provide and document a way to choose between http and ssh url
|
||||
repo_url = attrs['target']['git_http_url']
|
||||
# project name from http headers is empty for me, so get it from object_attributes/target/name
|
||||
# project name from http headers is empty for me, so get it from
|
||||
# object_attributes/target/name
|
||||
project = attrs['target']['name']
|
||||
|
||||
# Filter out uninteresting events
|
||||
@@ -117,7 +118,8 @@ class GitLabHandler(BaseHookHandler):
|
||||
log.msg("GitLab MR#{}: Ignoring because state is {}".format(attrs['iid'], state))
|
||||
return []
|
||||
action = attrs['action']
|
||||
if not re.match('^(open|reopen)$', action) and not (action == "update" and "oldrev" in attrs):
|
||||
if not re.match('^(open|reopen)$', action) and \
|
||||
not (action == "update" and "oldrev" in attrs):
|
||||
log.msg("GitLab MR#{}: Ignoring because action {} was not open or "
|
||||
"reopen or an update that added code".format(attrs['iid'],
|
||||
action))
|
||||
@@ -126,7 +128,8 @@ class GitLabHandler(BaseHookHandler):
|
||||
changes = [{
|
||||
'author': '{} <{}>'.format(commit['author']['name'], commit['author']['email']),
|
||||
'files': [], # @todo use rest API
|
||||
'comments': "MR#{}: {}\n\n{}".format(attrs['iid'], attrs['title'], attrs['description']),
|
||||
'comments': "MR#{}: {}\n\n{}".format(attrs['iid'], attrs['title'],
|
||||
attrs['description']),
|
||||
'revision': commit['id'],
|
||||
'when_timestamp': when_timestamp,
|
||||
'branch': attrs['target_branch'],
|
||||
|
||||
@@ -44,7 +44,8 @@ from buildbot.www import rest
|
||||
from buildbot.www import sse
|
||||
from buildbot.www import ws
|
||||
|
||||
# as per: http://security.stackexchange.com/questions/95972/what-are-requirements-for-hmac-secret-key
|
||||
# as per:
|
||||
# http://security.stackexchange.com/questions/95972/what-are-requirements-for-hmac-secret-key
|
||||
# we need 128 bit key for HS256
|
||||
SESSION_SECRET_LENGTH = 128
|
||||
SESSION_SECRET_ALGORITHM = "HS256"
|
||||
@@ -363,7 +364,8 @@ class WWWService(service.ReconfigurableServiceMixin, service.AsyncMultiService):
|
||||
# we encode that in hex for db storage convenience
|
||||
return bytes2unicode(hexlify(os.urandom(int(SESSION_SECRET_LENGTH / 8))))
|
||||
|
||||
session_secret = yield state.atomicCreateState(objectid, "session_secret", create_session_secret)
|
||||
session_secret = yield state.atomicCreateState(objectid, "session_secret",
|
||||
create_session_secret)
|
||||
self.site.setSessionSecret(session_secret)
|
||||
|
||||
def setupProtectedResource(self, resource_obj, checkers):
|
||||
|
||||
@@ -35,7 +35,8 @@ class WsProtocol(WebSocketServerProtocol):
|
||||
self.debug = self.master.config.www.get('debug', False)
|
||||
|
||||
def sendJsonMessage(self, **msg):
|
||||
return self.sendMessage(unicode2bytes(json.dumps(msg, default=toJson, separators=(',', ':'))))
|
||||
return self.sendMessage(unicode2bytes(json.dumps(msg, default=toJson,
|
||||
separators=(',', ':'))))
|
||||
|
||||
def onMessage(self, frame, isBinary):
|
||||
if self.debug:
|
||||
|
||||
@@ -103,7 +103,8 @@ class Api:
|
||||
elif results >= 0 and results < len(Results):
|
||||
results_txt = Results[results]
|
||||
|
||||
svgdata = self.makesvg(results_txt, results_txt, left_text=config['left_text'], config=config)
|
||||
svgdata = self.makesvg(results_txt, results_txt, left_text=config['left_text'],
|
||||
config=config)
|
||||
defer.returnValue(svgdata)
|
||||
|
||||
def textwidth(self, text, config):
|
||||
|
||||
Reference in New Issue
Block a user