mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 13:31:27 +00:00
add debug prints
This commit is contained in:
parent
64c4fbf68a
commit
7dc8aa724d
|
@ -172,6 +172,8 @@ class ServicesMutations:
|
|||
self, input: SetServiceConfigurationInput
|
||||
) -> ServiceMutationReturn:
|
||||
"""Set the new configuration values"""
|
||||
print('set_service_configuration')
|
||||
print(f"{input=}")
|
||||
service = get_service_by_id(input.service_id)
|
||||
if service is None:
|
||||
return ServiceMutationReturn(
|
||||
|
@ -180,7 +182,9 @@ class ServicesMutations:
|
|||
code=404,
|
||||
)
|
||||
try:
|
||||
print('Got service by id.')
|
||||
service.set_configuration(input.configuration)
|
||||
print('Configuration set.')
|
||||
return ServiceMutationReturn(
|
||||
success=True,
|
||||
message="Service configuration updated.",
|
||||
|
|
|
@ -57,10 +57,12 @@ class StringServiceConfigItem(ServiceConfigItem):
|
|||
return service_options.get(self.id, self.default_value)
|
||||
|
||||
def set_value(self, value, service_options):
|
||||
print('set_value called')
|
||||
if not self.validate_value(value):
|
||||
raise ValueError(f"Value {value} is not valid")
|
||||
if self.regex and not self.regex.match(value):
|
||||
raise ValueError(f"Value {value} does not match regex {self.regex}")
|
||||
print('seting actual value')
|
||||
service_options[self.id] = value
|
||||
|
||||
def as_dict(self, service_options):
|
||||
|
|
|
@ -202,17 +202,30 @@ class Service(ABC):
|
|||
|
||||
@classmethod
|
||||
def set_configuration(cls, config_items):
|
||||
print('set_configuration')
|
||||
print(f'{config_items=}')
|
||||
print('Starting pre-check for config items')
|
||||
for key, value in config_items.items():
|
||||
print(f'{key=}')
|
||||
print(f'{value=}')
|
||||
if key not in cls.config_items:
|
||||
raise ValueError(f"Key {key} is not valid for {cls.get_id()}")
|
||||
print('key in cls.config_items')
|
||||
if cls.config_items[key].validate_value(value) is False:
|
||||
raise ValueError(f"Value {value} is not valid for {key}")
|
||||
print('value is valid')
|
||||
with WriteUserData() as user_data:
|
||||
print('Writing to user_data')
|
||||
if "modules" not in user_data:
|
||||
print('modules not in user_data')
|
||||
user_data["modules"] = {}
|
||||
if cls.get_id() not in user_data["modules"]:
|
||||
print('cls.get_id() not in user_data["modules"]')
|
||||
user_data["modules"][cls.get_id()] = {}
|
||||
for key, value in config_items.items():
|
||||
print('Starting writing')
|
||||
print(f'{key=}')
|
||||
print(f'{value=}')
|
||||
cls.config_items[key].set_value(
|
||||
value,
|
||||
user_data["modules"][cls.get_id()],
|
||||
|
|
Loading…
Reference in a new issue