Skip to content

Commit

Permalink
[webkitbugspy] Handle Radar rate limits
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=261469
rdar://115370971

Reviewed by Dewei Zhu.

* Tools/Scripts/libraries/webkitbugspy/setup.py: Bump version.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py: Ditto
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/data.py: protectedAccessGroups is a list.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/radar.py:
(RadarModel.Milestone): Update function call with AccessGroups.
(RadarModel.RadarGroup): Added.
(Radar.RetryPolicy): Added.
* Tools/Scripts/libraries/webkitbugspy/webkitbugspy/radar.py:
(Tracker.__init__): Add retry policy.
* Tools/Scripts/libraries/webkitscmpy/setup.py: Bump version.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/clone.py:
(Clone.main): Use new AccessGroups.

Canonical link: https://commits.webkit.org/267913@main
  • Loading branch information
JonWBedard committed Sep 12, 2023
1 parent 3a63df5 commit 6ba3165
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Tools/Scripts/libraries/webkitbugspy/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def readme():

setup(
name='webkitbugspy',
version='0.13.1',
version='0.13.2',
description='Library containing a shared API for various bug trackers.',
long_description=readme(),
classifiers=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _maybe_add_library_path(path):
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)

version = Version(0, 13, 1)
version = Version(0, 13, 2)

from .user import User
from .issue import Issue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
dict(
name='October',
isProtected=True,
protectedAccessGroup='Managers,Integrators',
protectedAccessGroups=['Managers', 'Integrators'],
categories=['Test Development', 'Tentpole Feature Work', 'Escape / Regression in the Build'],
events=['Week 1', 'Week 2', 'Week 3', 'Week 4', 'Convergence'],
tentpoles=['Scrolling', 'SVG'],
Expand Down
18 changes: 13 additions & 5 deletions Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/radar.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,18 @@ class Milestone(object):
def __init__(
self, name,
isClosed=False,
isRestricted=False, restrictedAccessGroup='',
isProtected=False, protectedAccessGroup='',
isRestricted=False, restrictedAccessGroups=None,
isProtected=False, protectedAccessGroups=None,
isCategoryRequired=False, categories=None,
isEventRequired=False, events=None,
isTentpoleRequired=False, tentpoles=None,
):
self.name = name
self.isClosed = isClosed
self.isRestricted = isRestricted
self.restrictedAccessGroup = restrictedAccessGroup
self.restrictedAccessGroups = [RadarModel.RadarGroup(name) for name in restrictedAccessGroups or []]
self.isProtected = isProtected
self.protectedAccessGroup = protectedAccessGroup
self.protectedAccessGroups = [RadarModel.RadarGroup(name) for name in protectedAccessGroups or []]

self._isCategoryRequired = isCategoryRequired
self._categories = [RadarModel.Category(category) for category in (categories or [])]
Expand All @@ -142,6 +142,7 @@ def __init__(
self._isTentpoleRequired = isTentpoleRequired
self._tentpoles = [RadarModel.Tentpole(tentpole) for tentpole in (tentpoles or [])]


class Category(object):
def __init__(self, name):
self.name = name
Expand All @@ -167,6 +168,10 @@ class Keyword(object):
def __init__(self, name):
self.name = name

class RadarGroup(object):
def __init__(self, id):
self.id = id

def __init__(self, client, issue):
from datetime import datetime, timedelta

Expand Down Expand Up @@ -434,6 +439,9 @@ class exceptions(object):
class UnsuccessfulResponseException(Exception):
pass

class RetryPolicy(object):
pass

@classmethod
def transform_user(cls, user):
return User(
Expand All @@ -459,7 +467,7 @@ def __init__(self, users=None, issues=None, projects=None, milestones=None):
self.milestones[ms.name] = ms

self.AppleDirectoryQuery = AppleDirectoryQuery(self)
self.RadarClient = lambda authentication_strategy, client_system_identifier: RadarClient(self, authentication_strategy)
self.RadarClient = lambda authentication_strategy, client_system_identifier, retry_policy=None: RadarClient(self, authentication_strategy)

from mock import patch
self.patches.append(patch('webkitbugspy.radar.Tracker.radarclient', new=lambda s=None: self))
Expand Down
1 change: 1 addition & 0 deletions Tools/Scripts/libraries/webkitbugspy/webkitbugspy/radar.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def __init__(self, users=None, authentication=None, project=None, projects=None,
if authentication:
self.client = self.library.RadarClient(
authentication, self.library.ClientSystemIdentifier(library_name, str(library_version)),
retry_policy=self.radarclient().RetryPolicy(),
)
else:
self.client = None
Expand Down
2 changes: 1 addition & 1 deletion Tools/Scripts/libraries/webkitscmpy/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def readme():

setup(
name='webkitscmpy',
version='6.6.11',
version='6.6.12',
description='Library designed to interact with git and svn repositories.',
long_description=readme(),
classifiers=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _maybe_add_webkitcorepy_path():
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)

version = Version(6, 6, 11)
version = Version(6, 6, 12)

AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
AutoInstall.register(Package('jinja2', Version(2, 11, 3)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,16 @@ def main(cls, args, repository, merge_back=False, **kwargs):
milestone = None
continue
if milestone.isRestricted:
for group in milestone.restrictedAccessGroup.split(','):
if rdar.me().username in rdar.library.AppleDirectoryQuery.member_dsid_list_for_group_name(group):
for group in milestone.restrictedAccessGroups:
if rdar.me().username in rdar.library.AppleDirectoryQuery.member_dsid_list_for_group_name(group.id):
break
else:
sys.stderr.write("You do not have read access to '{}', pick another\n".format(milestone.name))
milestone = None
continue
if milestone.isProtected:
for group in milestone.protectedAccessGroup.split(','):
if rdar.me().username in rdar.library.AppleDirectoryQuery.member_dsid_list_for_group_name(group):
for group in milestone.protectedAccessGroups:
if rdar.me().username in rdar.library.AppleDirectoryQuery.member_dsid_list_for_group_name(group.id):
break
else:
sys.stderr.write("You do not have write access to '{}', pick another\n".format(milestone.name))
Expand Down

0 comments on commit 6ba3165

Please sign in to comment.