fix staff

This commit is contained in:
Administrator 2024-02-17 01:09:30 +03:00
parent 12ce9b1906
commit ea6f5e2ca4

View File

@ -22,6 +22,7 @@ class PlatformClient:
self.fetch_url = urllib.parse.urljoin(self.endpoint, 'fetch')
self.config_storage = {}
self.experiment_storage = {}
self.staff_storage = {}
self.poll_data()
if need_poll:
self.poll_data_in_thread()
@ -63,6 +64,10 @@ class PlatformClient:
local_platform = json.loads(open('local_platform.json', 'r').read())
self.config_storage = local_platform['configs']
self.experiment_storage = local_platform['experiments']
self.staff_storage = {
key: set(value)
for key, value in local_platform['platform_staff'].items()
}
return
response_data = self.request_with_retries(self.fetch_url, {
'project': self.app_name,
@ -70,6 +75,10 @@ class PlatformClient:
}, with_exception)
self.config_storage = response_data['configs']
self.experiment_storage = response_data['experiments']
self.staff_storage = {
key: set(value)
for key, value in response_data['platform_staff'].items()
}
def fetch_configs(self, with_exception=False):
if self.stage == 'local':
@ -98,18 +107,10 @@ class PlatformClient:
self.experiment_storage[experiment] = response_data
def is_staff(self, **kwargs):
if self.stage == 'local':
local_platform = json.loads(open('local_platform.json', 'r').read())
local_staff = local_platform['staff']
for element in local_staff:
for key, value in kwargs.items():
if element[key] == value:
if value in self.staff_storage[key]:
return True
return False
response_data = self.request_with_retries(self.staff_url, kwargs)
if response_data is None:
return False
return response_data['is_staff']
def get_config(self, name):
return self.config_storage[name]