mozreview: fix pep8 indentation errors (
bug 1232700); r?smacleod
This fixes the following errors:
E121 continuation line under-indented for hanging indent
E122 continuation line missing indentation or outdented
E124 closing bracket does not match visual indentation
E125 continuation line with same indent as next logical line
E126 continuation line over-indented for hanging indent
E128 continuation line under-indented for visual indent
E129 visually indented line with same indent as next logical line
E131 continuation line unaligned for hanging indent
MozReview-Commit-ID: 8mLIcb74vMF
--- a/pylib/mozreview/mozreview/autoland/resources.py
+++ b/pylib/mozreview/mozreview/autoland/resources.py
@@ -233,17 +233,17 @@ class AutolandTriggerResource(BaseAutola
user_id=request.user.id,
)
AutolandEventLogEntry.objects.create(
status=AutolandEventLogEntry.REQUESTED,
autoland_request_id=autoland_request_id)
self.save_autolandrequest_id('p2rb.autoland', rr,
- autoland_request_id)
+ autoland_request_id)
return 200, {}
autoland_trigger_resource = AutolandTriggerResource()
class TryAutolandTriggerResource(BaseAutolandTriggerResource):
@@ -328,27 +328,27 @@ class TryAutolandTriggerResource(BaseAut
return AUTOLAND_REQUEST_IN_PROGRESS
try:
# We use a hard-coded destination here. If we ever open this up
# to make the destination a parameter to this resource, we need to
# verify that the destination is in fact an "scm_level_1"
# repository to ensure that people don't try to land to inbound
# using this resource.
- response = requests.post(autoland_url + '/autoland',
+ response = requests.post(
+ autoland_url + '/autoland',
data=json.dumps({
- 'ldap_username': request.mozreview_profile.ldap_username,
- 'tree': rr.repository.name,
- 'pingback_url': pingback_url,
- 'rev': last_revision,
- 'destination': TRY_AUTOLAND_DESTINATION,
- 'trysyntax': try_syntax,
- }), headers={
- 'content-type': 'application/json',
- },
+ 'ldap_username': request.mozreview_profile.ldap_username,
+ 'tree': rr.repository.name,
+ 'pingback_url': pingback_url,
+ 'rev': last_revision,
+ 'destination': TRY_AUTOLAND_DESTINATION,
+ 'trysyntax': try_syntax,
+ }),
+ headers={'content-type': 'application/json'},
timeout=AUTOLAND_REQUEST_TIMEOUT,
auth=(autoland_user, autoland_password))
except requests.exceptions.RequestException:
logging.error('We hit a RequestException when submitting a '
'request to Autoland')
release_lock(lock_id)
return AUTOLAND_ERROR
except requests.exceptions.Timeout:
@@ -386,17 +386,17 @@ class TryAutolandTriggerResource(BaseAut
})
)
AutolandEventLogEntry.objects.create(
status=AutolandEventLogEntry.REQUESTED,
autoland_request_id=autoland_request_id)
self.save_autolandrequest_id('p2rb.autoland_try', rr,
- autoland_request_id)
+ autoland_request_id)
return 200, {}
try_autoland_trigger_resource = TryAutolandTriggerResource()
class AutolandRequestUpdateResource(WebAPIResource):
--- a/pylib/mozreview/mozreview/extension.py
+++ b/pylib/mozreview/mozreview/extension.py
@@ -216,32 +216,32 @@ class MozReviewExtension(Extension):
'label': 'File a Bug',
'url': 'https://bugzilla.mozilla.org/enter_bug.cgi'
'?product=Developer%20Services&component=MozReview',
},
],
}])
ReviewRequestDropdownActionHook(self, actions=[
- {
- 'label': 'Automation',
- 'id': 'automation-menu',
- 'items': [
- {
- 'id': 'autoland-try-trigger',
- 'label': 'Trigger a Try Build',
- 'url': '#',
+ {
+ 'label': 'Automation',
+ 'id': 'automation-menu',
+ 'items': [
+ {
+ 'id': 'autoland-try-trigger',
+ 'label': 'Trigger a Try Build',
+ 'url': '#',
+ },
+ {
+ 'id': 'autoland-trigger',
+ 'label': 'Land Commits',
+ 'url': '#',
+ },
+ ],
},
- {
- 'id': 'autoland-trigger',
- 'label': 'Land Commits',
- 'url': '#',
- },
- ],
- },
])
# Hide fields from all review requests that are not used by Mozilla
# developers.
main_fieldset = get_review_request_fieldset('main')
testing_done_field = get_review_request_field('testing_done')
if testing_done_field:
main_fieldset.remove_field(testing_done_field)
--- a/pylib/mozreview/mozreview/fields.py
+++ b/pylib/mozreview/mozreview/fields.py
@@ -153,18 +153,18 @@ class ImportCommitField(BaseReviewReques
repo_path = review_request.repository.path
if not commit_id:
logging.error('No commit_id for review request: %d' % (
review_request.id))
return ''
return get_template('mozreview/hg-import.html').render(Context({
- 'commit_id': commit_id,
- 'repo_path': repo_path,
+ 'commit_id': commit_id,
+ 'repo_path': repo_path,
}))
class PullCommitField(BaseReviewRequestField):
"""This field provides some information on how to pull down the commit"""
# RB validation requires this to be unique, so we fake a field id
field_id = "p2rb.PullCommitField"
label = _("Pull")
@@ -195,18 +195,18 @@ class PullCommitField(BaseReviewRequestF
repo_path = review_request.repository.path
if not commit_id:
logging.error('No commit_id for review request: %d' % (
review_request.id))
return ''
return get_template('mozreview/hg-pull.html').render(Context({
- 'commit_id': commit_id,
- 'repo_path': repo_path,
+ 'commit_id': commit_id,
+ 'repo_path': repo_path,
}))
class BaseCommitField(CommitDataBackedField):
"""Field for the commit a review request is based on.
This field stores the base commit that a parent review request is
based on (the parent commit of the first commit in the series).
@@ -312,17 +312,17 @@ class TryField(BaseReviewRequestField):
logging.error('A malformed autoland_id was detected: %s' %
info['new'][0])
return self._retrieve_error_txt
try:
ar = AutolandRequest.objects.get(pk=autoland_id)
except:
logging.error('An unknown autoland_id was detected: %s' %
- info['new'][0])
+ info['new'][0])
return self._retrieve_error_txt
if ar.last_known_status == AutolandEventLogEntry.REQUESTED:
return self._waiting_txt
elif ar.last_known_status == AutolandEventLogEntry.PROBLEM:
return linebreaksbr(self._autoland_problem % ar.last_error_msg)
elif ar.last_known_status == AutolandEventLogEntry.SERVED:
url = self._job_url % ar.repository_revision
--- a/pylib/mozreview/mozreview/forms.py
+++ b/pylib/mozreview/mozreview/forms.py
@@ -13,17 +13,17 @@ class MozReviewSettingsForm(SettingsForm
widget=forms.TextInput(attrs={
'size': 100,
}))
pulse_port = forms.IntegerField(required=False)
pulse_ssl = forms.BooleanField(required=False)
pulse_user = forms.CharField(required=False)
pulse_password = forms.CharField(required=False,
widget=forms.PasswordInput(
- render_value=True))
+ render_value=True))
autoland_import_pullrequest_ui_enabled = forms.BooleanField(
label=_('Enable Autoland Import Pullrequest UI'),
help_text=_('This allows access to the web endpoint for importing '
'Github pull requests'),
initial=False,
required=False)
autoland_try_ui_enabled = forms.BooleanField(
label=_('Enable Autoland Try UI'),
--- a/pylib/mozreview/mozreview/middleware.py
+++ b/pylib/mozreview/mozreview/middleware.py
@@ -22,21 +22,21 @@ class MozReviewCacheDisableMiddleware(ob
# URL names which should not use etag caching.
URLNAME_BLACKLIST = [
'review-request-detail',
'view-diff',
]
def process_view(self, request, view_func, view_args, view_kwargs):
if (request.resolver_match and
- request.resolver_match.url_name in self.URLNAME_BLACKLIST and
- 'HTTP_IF_NONE_MATCH' in request.META):
+ request.resolver_match.url_name in self.URLNAME_BLACKLIST and
+ 'HTTP_IF_NONE_MATCH' in request.META):
# Clear the etag provided by the client
del request.META['HTTP_IF_NONE_MATCH']
def process_response(self, request, response):
if (request.resolver_match and
- request.resolver_match.url_name in self.URLNAME_BLACKLIST and
- 'ETag' in response):
+ request.resolver_match.url_name in self.URLNAME_BLACKLIST and
+ 'ETag' in response):
# Clear the etag Review Board generated
del response['ETag']
return response
--- a/pylib/mozreview/mozreview/resources/bugzilla_login.py
+++ b/pylib/mozreview/mozreview/resources/bugzilla_login.py
@@ -97,16 +97,48 @@ class BugzillaAPIKeyLoginResource(WebAPI
'api_key': {
'type': str,
'description': 'Bugzilla API key',
}
}
)
def create(self, request, username, api_key, *args, **kwargs):
"""Authenticate a user from a username and API key."""
+ backend_cls = get_registered_auth_backend('bugzilla')
+ if not backend_cls:
+ return SERVICE_NOT_CONFIGURED
+
+ backend = backend_cls()
+
+ try:
+ user = backend.authenticate_api_key(username, api_key)
+ if user is None:
+ return LOGIN_FAILED
+
+ # The user will need to visit Bugzilla to obtain an API key.
+ except BugzillaAPIKeyNeededError as e:
+ return WebAPIResponseError(request, LOGIN_FAILED, extra_params={
+ 'bugzilla_api_key_needed': True,
+ 'bugzilla_api_key_url': e.url,
+ })
+
+ # The user hasn't logged in via the HTML interface yet. This
+ # error response should be interpretted by clients to direct
+ # them to log in to the web site.
+ except WebLoginNeededError:
+ protocol = SiteConfiguration.objects.get_current().get(
+ 'site_domain_method')
+ domain = Site.objects.get_current().domain
+ login_url = '%s://%s%saccount/login' % (
+ protocol, domain, settings.SITE_ROOT)
+
+ extra = {
+ 'web_login_needed': True,
+ 'login_url': login_url,
+ }
result = auth_api_key(request, username, api_key)
if not isinstance(result, User):
return result
# Authentication succeeded. Persist the returned user for the
# session.
login(request, result)
--- a/pylib/mozreview/mozreview/tests/test-autoland-concurrent.py
+++ b/pylib/mozreview/mozreview/tests/test-autoland-concurrent.py
@@ -134,17 +134,17 @@ class AutolandConcurrentTest(MozReviewWe
self.reviewboard_login('mjane@example.com', 'password2')
self.load_rburl('r/1')
try_btn = self.browser.find_element_by_id('autoland-try-trigger')
self.assertEqual(
try_btn.value_of_css_property('opacity'), '0.5')
self.assign_reviewer(0, 'jsmith')
publish_btn = WebDriverWait(self.browser, 3).until(
EC.visibility_of_element_located((By.ID,
- 'btn-draft-publish')))
+ 'btn-draft-publish')))
publish_btn.click()
WebDriverWait(self.browser, 10).until(
EC.invisibility_of_element_located((By.ID, 'draft-banner')))
# Attempt to make intermittent failure with opacity of 'try' button
# less common. See Bug 1220733.
self.load_rburl('r/2')
@@ -175,11 +175,11 @@ class AutolandConcurrentTest(MozReviewWe
self.send_autoland_try_request()
error_msg = WebDriverWait(self.browser, 10).until(
EC.visibility_of_element_located(
(By.CSS_SELECTOR, '#activity-indicator .error_msg')
)
)
self.assertEqual(error_msg.text,
- ('An autoland request for this review '
- 'request is already in progress. '
- 'Please wait for that request to finish.'))
+ ('An autoland request for this review '
+ 'request is already in progress. '
+ 'Please wait for that request to finish.'))
--- a/pylib/mozreview/mozreview/tests/test-autoland-try.py
+++ b/pylib/mozreview/mozreview/tests/test-autoland-try.py
@@ -77,17 +77,17 @@ class AutolandTryTest(MozReviewWebDriver
self.reviewboard_login('mjane@example.com', 'password2')
self.load_rburl('r/1')
try_btn = self.browser.find_element_by_id('autoland-try-trigger')
self.assertEqual(
try_btn.value_of_css_property('opacity'), '0.5')
self.assign_reviewer(0, 'jsmith')
publish_btn = WebDriverWait(self.browser, 3).until(
EC.visibility_of_element_located((By.ID,
- 'btn-draft-publish')))
+ 'btn-draft-publish')))
publish_btn.click()
WebDriverWait(self.browser, 10).until(
EC.invisibility_of_element_located((By.ID, 'draft-banner')))
automation_menu = self.browser.find_element_by_id('automation-menu')
automation_menu.click()
try_btn = self.browser.find_element_by_id('autoland-try-trigger')
@@ -159,13 +159,13 @@ class AutolandTryTest(MozReviewWebDriver
WebDriverWait(self.browser, 10).until(
EC.visibility_of_element_located((By.CLASS_NAME, 'changedesc'))
)
time.sleep(10)
self.browser.refresh()
changedesc = self.browser.find_elements_by_class_name('changedesc')[1]
self.assertTrue('https://treeherder.mozilla.org/'
- in changedesc.get_attribute('innerHTML'))
+ in changedesc.get_attribute('innerHTML'))
# We should not have closed the review automatically
with self.assertRaises(NoSuchElementException):
self.browser.find_element_by_id('submitted-banner')