本文整理汇总了Python中mozreview.extra_data.is_parent函数的典型用法代码示例。如果您正苦于以下问题:Python is_parent函数的具体用法?Python is_parent怎么用?Python is_parent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_parent函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: is_approved
def is_approved(self, review_request, prev_approved, prev_failure):
"""Check if a review request is approved to land
We will completely override the checks done by Review Board and
provide our own (to keep approval simpler and explicit).
If True is returned by this function it will indicate that
review request may be autolanded - care should be taken
when modifying the logic.
"""
# TODO: We should consider rejecting review requests which
# currently have a draft (to prevent autolanding incorrect
# things)
try:
if not is_pushed(review_request):
return False, 'Manually uploaded requests cannot be approved.'
if not review_request.public:
return False, 'The review request is not public.'
if is_parent(review_request):
return self.is_approved_parent(review_request)
return self.is_approved_child(review_request)
except Exception as e:
# We catch all exceptions because any error will make
# Review Board revert to it's default behaviour which
# is much more relaxed than ours.
logger.error('Failed to calculate approval for review '
'request %s: %s' % (review_request.id, e))
return False, "Error when calculating approval."
开发者ID:kilikkuo,项目名称:version-control-tools,代码行数:31,代码来源:hooks.py
示例2: pre_save_review
def pre_save_review(sender, *args, **kwargs):
"""Handle pre_save for a Review.
This is needed to give a default value to the REVIEW_FLAG_KEY
extra_data key. It tries to retrieve the last known review status,
falling back to r? if no status is found.
"""
review = kwargs["instance"]
if review.pk:
# The review create endpoint calls save twice: the first time it
# gets or creates the review and the second time it updates the
# object retrieved/created. This condition let us execute the code
# below only once.
if not is_parent(review.review_request):
if REVIEW_FLAG_KEY not in review.extra_data:
# TODO: we should use a different query than going through
# all the reviews, which is what get_reviewers_status does.
reviewers_status = get_reviewers_status(review.review_request,
reviewers=[review.user])
user = review.user.username
flag = reviewers_status.get(user, {}).get('review_flag', ' ')
review.extra_data[REVIEW_FLAG_KEY] = flag
review.ship_it = (review.extra_data[REVIEW_FLAG_KEY] == 'r+')
开发者ID:sethfowler,项目名称:dot-config,代码行数:26,代码来源:signal_handlers.py
示例3: _sort_families
def _sort_families(self, request, rrs, families=None):
"""Sort ReviewRequest objects into families.
'families' is a dict with parent ReviewRequest ids as keys. Each
value is another dict, with 'parent' mapped to the parent
ReviewRequest and 'children' mapped to a list of child ReviewRequests
of that parent. If 'families' is not None, it is updated in place;
if 'families' is not given, it is first initialized. In both cases
'families' is also returned.
For each ReviewRequest in rrs, 'families' is updated appropriately
to assemble a full set of families.
"""
if families is None:
families = defaultdict(lambda: dict(parent=None, children={}))
for rr in rrs:
if rr.status == ReviewRequest.DISCARDED:
continue
if not self.has_access_permissions(request, rr):
continue
if is_parent(rr):
families[rr.id]['parent'] = rr
else:
# Some early review requests were orphaned; ignore them.
try:
parent_rr = get_parent_rr(rr)
except ReviewRequest.DoesNotExist:
continue
families[parent_rr.id]['children'][rr.id] = rr
return families
开发者ID:kilikkuo,项目名称:version-control-tools,代码行数:35,代码来源:review_request_summary.py
示例4: get
def get(self, request, *args, **kwargs):
parent_rrid = kwargs[self.uri_object_key]
try:
parent_review_request = ReviewRequest.objects.get(id=parent_rrid)
except ReviewRequest.DoesNotExist:
return DOES_NOT_EXIST
if not self.has_access_permissions(request, parent_review_request,
*args, **kwargs):
return self.get_no_access_error(request, parent_review_request,
*args, **kwargs)
if not is_parent(parent_review_request):
return NOT_PARENT
if not parent_review_request.public:
# Review request has never been published.
return DOES_NOT_EXIST
families = self._sort_families(request, [parent_review_request])
self._sort_families(request, gen_child_rrs(parent_review_request),
families=families)
# FIXME: The returned data should actually be a dict, with keys
# 'stat' and self.item_result_key mapped to 'ok' and the
# family-summary dict, respectively, to match the standard Review
# Board web API format.
# However, the Bugzilla extension uses the existing, nonstandard
# return value, so we have to wait until it is fetching review
# requests by bug before fixing this.
return 200, self._summarize_families(request, families)[0]
开发者ID:kilikkuo,项目名称:version-control-tools,代码行数:32,代码来源:review_request_summary.py
示例5: as_html
def as_html(self):
commit_id = self.commit_data.extra_data.get(COMMIT_ID_KEY)
if is_parent(self.review_request_details, self.commit_data):
user = self.request.user
parent = get_parent_rr(
self.review_request_details.get_review_request(),
self.commit_data)
parent_details = parent.get_draft() or parent
children = [
child for child in gen_child_rrs(parent_details, user=user)
if child.is_accessible_by(user)]
commit_data = fetch_commit_data(children[-1])
commit_id = commit_data.extra_data.get(COMMIT_ID_KEY)
review_request = self.review_request_details.get_review_request()
repo_path = review_request.repository.path
if not commit_id:
logger.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,
}))
开发者ID:pkdevboxy,项目名称:version-control-tools,代码行数:28,代码来源:fields.py
示例6: get
def get(self, request, *args, **kwargs):
try:
parent_request = get_parent_rr(ReviewRequest.objects.get(
id=kwargs[self.uri_object_key]))
except ReviewRequest.DoesNotExist:
return DOES_NOT_EXIST
if parent_request is None:
return DOES_NOT_EXIST
if not is_parent(parent_request):
return NOT_PARENT
if not parent_request.is_accessible_by(request.user):
return PERMISSION_DENIED
if COMMITS_KEY not in parent_request.extra_data:
logging.error('Parent review request %s missing COMMIT_KEY'
% parent_request.id)
return NOT_PARENT
result = []
children = json.loads(parent_request.extra_data[COMMITS_KEY])
for child in children:
try:
child_request = ReviewRequest.objects.get(id=child[1])
except ReviewRequest.DoesNotExist:
return DOES_NOT_EXIST
if not child_request.approved:
return AUTOLAND_REVIEW_NOT_APPROVED
reviewers = [
r.user.username for r in gen_latest_reviews(child_request) if
r.ship_it and
r.user != child_request.submitter
]
if not reviewers and child_request.approved:
# This review request is approved (the repeated check is
# to ensure this is guaranteed if other parts of the code
# change) but we have an empty list of reviewers. We'll
# assume the author has just approved this themself and
# set r=me
reviewers.append('me')
result.append({
'commit': child[0],
'id': child[1],
'reviewers': reviewers,
'summary': replace_reviewers(child_request.description,
reviewers)
})
return 200, {
'commits': result,
'total_results': len(result),
'links': self.get_links(request=request),
}
开发者ID:MikeLing,项目名称:version-control-tools,代码行数:54,代码来源:commit_rewrite.py
示例7: on_review_request_closed_submitted
def on_review_request_closed_submitted(user, review_request, type, **kwargs):
if type != ReviewRequest.SUBMITTED:
return
commit_data = fetch_commit_data(review_request)
if not is_parent(review_request, commit_data):
return
_close_child_review_requests(user, review_request, ReviewRequest.SUBMITTED,
AUTO_SUBMITTED_DESCRIPTION,
commit_data=commit_data)
开发者ID:pkdevboxy,项目名称:version-control-tools,代码行数:12,代码来源:signal_handlers.py
示例8: on_draft_changed
def on_draft_changed(self, sender, **kwargs):
instance = kwargs["instance"]
rr = instance.get_review_request()
if is_pushed(instance) and not is_parent(rr):
parent_rr = get_parent_rr(rr)
parent_rr_draft = parent_rr.get_draft()
if parent_rr_draft is None:
parent_rr_draft = ReviewRequestDraft.create(parent_rr)
update_parent_rr_reviewers(parent_rr_draft)
开发者ID:frostytear,项目名称:version-control-tools,代码行数:12,代码来源:extension.py
示例9: on_review_publishing
def on_review_publishing(user, review, **kwargs):
"""Comment in the bug and potentially r+ or clear a review flag.
Note that a reviewer *must* have editbugs to set an attachment flag on
someone else's attachment (i.e. the standard BMO review process).
TODO: Report lack-of-editbugs properly; see bug 1119065.
"""
review_request = review.review_request
logger.info('Publishing review for user: %s review id: %s '
'review request id: %s' % (user, review.id,
review_request.id))
# skip review requests that were not pushed
if not is_pushed(review_request):
logger.info('Did not publish review: %s: for user: %d: review not '
'pushed.' % (user, review.id))
return
site = Site.objects.get_current()
siteconfig = SiteConfiguration.objects.get_current()
comment = build_plaintext_review(review,
get_obj_url(review, site,
siteconfig),
{"user": user})
b = Bugzilla(get_bugzilla_api_key(user))
# TODO: Update all attachments in one call. This is not possible right
# now because we have to potentially mix changing and creating flags.
if is_parent(review_request):
# Mirror the comment to the bug, unless it's a ship-it, in which
# case throw an error. Ship-its are allowed only on child commits.
if review.ship_it:
raise ParentShipItError
[b.post_comment(int(bug_id), comment) for bug_id in
review_request.get_bug_list()]
else:
diff_url = '%sdiff/#index_header' % get_obj_url(review_request)
bug_id = int(review_request.get_bug_list()[0])
if review.ship_it:
commented = b.r_plus_attachment(bug_id, review.user.email,
diff_url, comment)
else:
commented = b.cancel_review_request(bug_id, review.user.email,
diff_url, comment)
if comment and not commented:
b.post_comment(bug_id, comment)
开发者ID:linearregression,项目名称:version-control-tools,代码行数:51,代码来源:extension.py
示例10: on_review_request_reopened
def on_review_request_reopened(user, review_request, **kwargs):
if not is_parent(review_request):
return
commit_data = fetch_commit_data(review_request)
identifier = commit_data.extra_data[IDENTIFIER_KEY]
# If we're reviving a squashed review request that was discarded, it means
# we're going to want to restore the commit ID field back, since we remove
# it on discarding. This might be a problem if there's already a review
# request with the same commit ID somewhere on Review Board, since commit
# IDs are unique.
#
# When this signal fires, the state of the review request has already
# changed, so we query for a review request with the same commit ID that is
# not equal to the revived review request.
try:
preexisting_review_request = ReviewRequest.objects.get(
commit_id=identifier, repository=review_request.repository)
if preexisting_review_request != review_request:
logger.error(
'Could not revive review request with ID %s because its '
'commit id (%s) is already being used by a review request '
'with ID %s.' % (
review_request.id,
identifier,
preexisting_review_request.id))
# TODO: We need Review Board to recognize exceptions in these
# signal handlers so that the UI can print out a useful message.
raise Exception(
'Revive failed because a review request with commit ID %s '
'already exists.' % identifier)
except ReviewRequest.DoesNotExist:
# Great! This is a success case.
pass
for child in gen_child_rrs(review_request):
child.reopen(user=user)
# If the review request had been discarded, then the commit ID would
# have been cleared out. If the review request had been submitted,
# this is a no-op, since the commit ID would have been there already.
review_request.commit = identifier
review_request.save()
# If the review request has a draft, we have to set the commit ID there as
# well, otherwise it'll get overwritten on publish.
draft = review_request.get_draft(user)
if draft:
draft.commit = identifier
draft.save()
开发者ID:pkdevboxy,项目名称:version-control-tools,代码行数:51,代码来源:signal_handlers.py
示例11: get
def get(self, request, *args, **kwargs):
try:
parent_request = get_parent_rr(ReviewRequest.objects.get(
id=kwargs[self.uri_object_key]))
except ReviewRequest.DoesNotExist:
return DOES_NOT_EXIST
if parent_request is None:
return DOES_NOT_EXIST
if not is_parent(parent_request):
return NOT_PARENT
if not parent_request.is_accessible_by(request.user):
return PERMISSION_DENIED
if COMMITS_KEY not in parent_request.extra_data:
logging.error('Parent review request %s missing COMMIT_KEY'
% parent_request.id)
return NOT_PARENT
result = []
children = json.loads(parent_request.extra_data[COMMITS_KEY])
for child in children:
try:
child_request = ReviewRequest.objects.get(id=child[1])
except ReviewRequest.DoesNotExist:
return DOES_NOT_EXIST
if not child_request.approved:
return AUTOLAND_REVIEW_NOT_APPROVED
reviewers = map(lambda review: review.user.username,
gen_latest_reviews(child_request))
result.append({
'commit': child[0],
'id': child[1],
'reviewers': reviewers,
'summary': replace_reviewers(child_request.description,
reviewers)
})
return 200, {
'commits': result,
'total_results': len(result),
'links': self.get_links(request=request),
}
开发者ID:armenzg,项目名称:version-control-tools,代码行数:42,代码来源:commit_rewrite.py
示例12: create
def create(self, request, parent_request_id, *args, **kwargs):
try:
parent_rr = ReviewRequest.objects.get(pk=parent_request_id)
except ReviewRequest.DoesNotExist:
return DOES_NOT_EXIST
if not (parent_rr.is_accessible_by(request.user)
or parent_rr.is_mutable_by(request.user)):
return PERMISSION_DENIED
if not is_parent(parent_rr):
return NOT_PARENT
with transaction.atomic():
for child_rr in gen_child_rrs(parent_rr):
if child_rr.get_draft() is None:
ReviewRequestDraft.create(child_rr)
if parent_rr.get_draft() is None:
ReviewRequestDraft.create(parent_rr)
return 200, {}
开发者ID:kilikkuo,项目名称:version-control-tools,代码行数:21,代码来源:ensure_drafts.py
示例13: on_review_request_closed_discarded
def on_review_request_closed_discarded(user, review_request, type, **kwargs):
if type != ReviewRequest.DISCARDED:
return
commit_data = fetch_commit_data(review_request)
if is_parent(review_request, commit_data):
# close_child_review_requests will call save on this review request, so
# we don't have to worry about it.
review_request.commit = None
_close_child_review_requests(user, review_request,
ReviewRequest.DISCARDED,
AUTO_CLOSE_DESCRIPTION,
commit_data=commit_data)
else:
# TODO: Remove this once we properly prevent users from closing
# commit review requests.
b = Bugzilla(get_bugzilla_api_key(user))
bug = int(review_request.get_bug_list()[0])
diff_url = '%sdiff/#index_header' % get_obj_url(review_request)
b.obsolete_review_attachments(bug, diff_url)
开发者ID:pkdevboxy,项目名称:version-control-tools,代码行数:22,代码来源:signal_handlers.py
示例14: ensure_parent_draft
def ensure_parent_draft(draft):
"""Ensure parent draft exists when child has a draft.
This is intended to be called in the post_save signal for the
ReviewRequestDraft model and ensure the parent review request
has a draft if a child draft is saved. We need to do this so
that the parent may always be published when a child requires
publishing.
Particularly we update our own reviewer information in the
parent to make sure that a reviewer change on a child request
will create a parent draft - even if the reviewer change does
not alter the overall set of reviewers for the series.
"""
rr = draft.get_review_request()
if is_pushed(draft) and not is_parent(rr):
parent_rr = get_parent_rr(rr)
parent_rr_draft = parent_rr.get_draft()
if parent_rr_draft is None:
parent_rr_draft = ReviewRequestDraft.create(parent_rr)
update_parent_rr_reviewers(parent_rr_draft)
开发者ID:pkdevboxy,项目名称:version-control-tools,代码行数:24,代码来源:signal_handlers.py
示例15: create
def create(self, request, review_request_id, *args, **kwargs):
try:
rr = ReviewRequest.objects.get(pk=review_request_id)
except ReviewRequest.DoesNotExist:
return DOES_NOT_EXIST
if not is_pushed(rr) or not is_parent(rr):
logging.error(
"Failed triggering Autoland because the review "
"request is not pushed, or not the parent review "
"request."
)
return NOT_PUSHED_PARENT_REVIEW_REQUEST
if not rr.is_mutable_by(request.user):
return PERMISSION_DENIED
last_revision = json.loads(rr.extra_data.get("p2rb.commits"))[-1][0]
ext = get_extension_manager().get_enabled_extension("mozreview.extension.MozReviewExtension")
logging.info(
"Submitting a request to Autoland for review request "
"ID %s for revision %s " % (review_request_id, last_revision)
)
autoland_url = ext.settings.get("autoland_url")
if not autoland_url:
return AUTOLAND_CONFIGURATION_ERROR
autoland_user = ext.settings.get("autoland_user")
autoland_password = ext.settings.get("autoland_password")
if not autoland_user or not autoland_password:
return AUTOLAND_CONFIGURATION_ERROR
pingback_url = autoland_request_update_resource.get_uri(request)
logging.info("Telling Autoland to give status updates to %s" % pingback_url)
try:
# Rather than hard coding the destination it would make sense
# to extract it from metadata about the repository. That will have
# to wait until we fix Bug 1168486.
response = requests.post(
autoland_url + "/autoland",
data=json.dumps(
{
"tree": rr.repository.name,
"pingback_url": pingback_url,
"rev": last_revision,
"destination": INBOUND_AUTOLAND_DESTINATION,
}
),
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")
return AUTOLAND_ERROR
except requests.exceptions.Timeout:
logging.error("We timed out when submitting a request to " "Autoland")
return AUTOLAND_TIMEOUT
if response.status_code != 200:
return AUTOLAND_ERROR, {"status_code": response.status_code, "message": response.json().get("error")}
# We succeeded in scheduling the job.
try:
autoland_request_id = int(response.json().get("request_id", 0))
finally:
if autoland_request_id is None:
return AUTOLAND_ERROR, {"status_code": response.status_code, "request_id": None}
autoland_request = AutolandRequest.objects.create(
autoland_id=autoland_request_id,
push_revision=last_revision,
review_request_id=rr.id,
user_id=request.user.id,
)
AutolandEventLogEntry.objects.create(
status=AutolandEventLogEntry.REQUESTED, autoland_request_id=autoland_request_id
)
self.save_autolandrequest_id("p2rb.autoland_inbound", rr, autoland_request_id)
return 200, {}
开发者ID:Nephyrin,项目名称:bzexport,代码行数:89,代码来源:resources.py
示例16: should_render
def should_render(self, value):
return not is_parent(self.review_request_details, self.commit_data)
开发者ID:pkdevboxy,项目名称:version-control-tools,代码行数:2,代码来源:fields.py
示例17: create
def create(self, request, review_request_id, *args, **kwargs):
try:
rr = ReviewRequest.objects.get(pk=review_request_id)
except ReviewRequest.DoesNotExist:
return DOES_NOT_EXIST
if not is_pushed(rr) or not is_parent(rr):
logging.error('Failed triggering Autoland because the review '
'request is not pushed, or not the parent review '
'request.')
return NOT_PUSHED_PARENT_REVIEW_REQUEST
if not rr.is_mutable_by(request.user):
return PERMISSION_DENIED
target_repository = rr.repository.extra_data.get(
'landing_repository_url')
push_bookmark = rr.repository.extra_data.get('landing_bookmark')
if not target_repository:
return AUTOLAND_CONFIGURATION_ERROR.with_message(
'Autoland has not been configured with a proper landing URL.')
last_revision = json.loads(rr.extra_data.get('p2rb.commits'))[-1][0]
ext = get_extension_manager().get_enabled_extension(
'mozreview.extension.MozReviewExtension')
logging.info('Submitting a request to Autoland for review request '
'ID %s for revision %s '
% (review_request_id, last_revision))
autoland_url = ext.settings.get('autoland_url')
if not autoland_url:
return AUTOLAND_CONFIGURATION_ERROR
autoland_user = ext.settings.get('autoland_user')
autoland_password = ext.settings.get('autoland_password')
if not autoland_user or not autoland_password:
return AUTOLAND_CONFIGURATION_ERROR
pingback_url = autoland_request_update_resource.get_uri(request)
logging.info('Telling Autoland to give status updates to %s'
% pingback_url)
try:
# Rather than hard coding the destination it would make sense
# to extract it from metadata about the repository. That will have
# to wait until we fix Bug 1168486.
response = requests.post(autoland_url + '/autoland',
data=json.dumps({
'tree': rr.repository.name,
'pingback_url': pingback_url,
'rev': last_revision,
'destination': target_repository,
'push_bookmark': push_bookmark,
}), 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')
return AUTOLAND_ERROR
except requests.exceptions.Timeout:
logging.error('We timed out when submitting a request to '
'Autoland')
return AUTOLAND_TIMEOUT
if response.status_code != 200:
return AUTOLAND_ERROR, {
'status_code': response.status_code,
'message': response.json().get('error'),
}
# We succeeded in scheduling the job.
try:
autoland_request_id = int(response.json().get('request_id', 0))
finally:
if autoland_request_id is None:
return AUTOLAND_ERROR, {
'status_code': response.status_code,
'request_id': None,
}
autoland_request = AutolandRequest.objects.create(
autoland_id=autoland_request_id,
push_revision=last_revision,
repository_url=target_repository,
review_request_id=rr.id,
user_id=request.user.id,
)
AutolandEventLogEntry.objects.create(
status=AutolandEventLogEntry.REQUESTED,
autoland_request_id=autoland_request_id)
#.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:version-control-tools,代码行数:101,代码来源:resources.py
示例18: create
def create(self, request, review_request_id, try_syntax, *args, **kwargs):
try:
rr = ReviewRequest.objects.get(pk=review_request_id)
except ReviewRequest.DoesNotExist:
return DOES_NOT_EXIST
if not try_syntax.startswith('try: '):
return INVALID_FORM_DATA, {
'fields': {
'try_syntax': ['The provided try syntax was invalid']
}
}
if not is_pushed(rr) or not is_parent(rr):
logging.error('Failed triggering Autoland because the review '
'request is not pushed, or not the parent review '
'request.')
return NOT_PUSHED_PARENT_REVIEW_REQUEST
if not rr.is_mutable_by(request.user):
return PERMISSION_DENIED
target_repository = rr.repository.extra_data.get(
'try_repository_url')
if not target_repository:
return AUTOLAND_CONFIGURATION_ERROR.with_message(
'Autoland has not been configured with a proper try URL.')
last_revision = json.loads(rr.extra_data.get('p2rb.commits'))[-1][0]
ext = get_extension_manager().get_enabled_extension(
'mozreview.extension.MozReviewExtension')
logging.info('Submitting a request to Autoland for review request '
'ID %s for revision %s '
% (review_request_id, last_revision))
autoland_url = ext.settings.get('autoland_url')
if not autoland_url:
return AUTOLAND_CONFIGURATION_ERROR
autoland_user = ext.settings.get('autoland_user')
autoland_password = ext.settings.get('autoland_password')
if not autoland_user or not autoland_password:
return AUTOLAND_CONFIGURATION_ERROR
pingback_url = autoland_request_update_resource.get_uri(request)
logging.info('Telling Autoland to give status updates to %s'
% pingback_url)
lock_id = get_autoland_lock_id(rr.id, target_repository, last_revision)
if not acquire_lock(lock_id):
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',
data=json.dumps({
'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:
logging.error('We timed out when submitting a request to '
'Autoland')
release_lock(lock_id)
return AUTOLAND_TIMEOUT
if response.status_code != 200:
release_lock(lock_id)
return AUTOLAND_ERROR, {
'status_code': response.status_code,
'message': response.json().get('error'),
}
# We succeeded in scheduling the job.
try:
autoland_request_id = int(response.json().get('request_id', 0))
finally:
if autoland_request_id is None:
release_lock(lock_id)
return AUTOLAND_ERROR, {
#.........这里部分代码省略.........
开发者ID:frostytear,项目名称:version-control-tools,代码行数:101,代码来源:resources.py
示例19: initialize
def initialize(self):
initialize_pulse_handlers(self)
URLHook(self,
patterns('', url(r'^mozreview/', include('mozreview.urls'))))
HeaderDropdownActionHook(self, actions=[{
'label': 'MozReview',
'items': [
{
'label': 'User Guide',
'url': 'https://mozilla-version-control-tools.readthedocs.org/en/latest/mozreview-user.html',
},
{
'label': 'Mercurial for Mozillians',
'url': 'https://mozilla-version-control-tools.readthedocs.org/en/latest/hgmozilla/index.html',
},
{
'label': 'Hacking MozReview',
'url': 'https://mozilla-version-control-tools.readthedocs.org/en/latest/hacking-mozreview.html',
},
{
'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': '#',
},
{
'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)
info_fieldset = get_review_request_fieldset('info')
for field_name in ('branch', 'depends_on', 'blocks'):
field = get_review_request_field(field_name)
if field:
info_fieldset.remove_field(field)
# We "monkey patch" (yes, I feel dirty) the should_render method on
# the description field so that it is not rendered for parent review
# requests.
description_field = get_review_request_field('description')
if description_field:
description_field.should_render = (lambda self, value:
not is_parent(self.review_request_details))
# All of our review request styling is injected via
# review-stylings-css, which in turn loads the review.css static
# bundle.
TemplateHook(self, 'base-css', 'mozreview/review-stylings-css.html',
apply_to=review_request_url_names)
TemplateHook(self, 'base-css', 'mozreview/viewdiff-stylings-css.html',
apply_to=diffviewer_url_names)
TemplateHook(self, 'base-scripts-post',
'mozreview/review-scripts-js.html',
apply_to=review_request_url_names)
TemplateHook(self, 'base-extrahead',
'mozreview/base-extrahead-login-form.html',
apply_to=['login'])
TemplateHook(self, 'before-login-form',
'mozreview/before-login-form.html', apply_to=['login'])
TemplateHook(self, 'after-login-form',
'mozreview/after-login-form.html', apply_to=['login'])
TemplateHook(self, 'base-after-content',
'mozreview/scm_level.html')
TemplateHook(self, 'base-after-content',
'mozreview/repository.html')
ReviewRequestFieldsHook(self, 'main', [CommitsListField])
# This forces the Commits field to be the top item.
main_fieldset.field_classes.insert(0,
main_fieldset.field_classes.pop())
# The above hack forced Commits at the top, but the rest of these
# fields are fine below the Description.
ReviewRequestFieldsHook(self, 'main', [CombinedReviewersField])
ReviewRequestFieldsHook(self, 'main', [TryField])
ReviewRequestFieldsHook(self, 'main', [BaseCommitField])
#.........这里部分代码省略.........
开发者ID:frostytear,项目名称:version-control-tools,代码行数:101,代码来源:extension.py
示例20: create
def create(self, request, review_request_id, try_syntax, *args, **kwargs):
try:
rr = ReviewRequest.objects.get(pk=review_request_id)
except ReviewRequest.DoesNotExist:
return DOES_NOT_EXIST
if not try_syntax.startswith("try: "):
return INVALID_FORM_DATA, {"fields": {"try_syntax": ["The provided try syntax was invalid"]}}
commit_data = fetch_commit_data(rr)
if not is_pushed(rr, commit_data) or not is_parent(rr, commit_data):
logger.error(
"Failed triggering Autoland because the review "
"request is not pushed, or not the parent review "
"request."
)
return NOT_PUSHED_PARENT_REVIEW_REQUEST
target_repository = rr.repository.extra_data.get("try_repository_url")
if not target_repository:
return AUTOLAND_CONFIGURATION_ERROR.with_message("Autoland has not been configured with a proper try URL.")
last_revision = json.loads(commit_data.extra_data.get(COMMITS_KEY))[-1][0]
ext = get_extension_manager().get_enabled_extension("mozreview.extension.MozReviewExtension")
logger.info(
"Submitting a request to Autoland for
|
请发表评论