From d48a45aa2dd908107aba6577106e576ee9206f24 Mon Sep 17 00:00:00 2001 From: Diego Tavares Date: Thu, 22 Aug 2024 09:19:51 -0700 Subject: [PATCH] [cuegui] Enable some separator characters on service name (#1492) The following separators can now be used to name services: | / - _ --------- Signed-off-by: Diego Tavares --- cuegui/cuegui/ServiceDialog.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cuegui/cuegui/ServiceDialog.py b/cuegui/cuegui/ServiceDialog.py index cb3994036..5ca292262 100644 --- a/cuegui/cuegui/ServiceDialog.py +++ b/cuegui/cuegui/ServiceDialog.py @@ -159,12 +159,18 @@ def save(self): Create and emit a ServiceData object based on the contents of the form. """ - if len(str(self.name.text())) < 3: + service_name = str(self.name.text()) + if len(service_name) < 3: QtWidgets.QMessageBox.critical(self, "Error", "The service name must be at least 3 characters.") return - if not str(self.name.text()).isalnum(): + # Allow alphanumeric chars and | / - _ + # chars like , and . can be used as separators in other parts of the API and behave + # inconsistently + if (not service_name.isalnum()) and \ + [char for char in service_name + if not char.isalnum() and char not in "|/-_"]: QtWidgets.QMessageBox.critical(self, "Error", "The service name must alphanumeric.") return @@ -176,7 +182,7 @@ def save(self): service = opencue.wrappers.service.Service() if self.__service: service.data.id = self.__service.data.id - service.setName(str(self.name.text())) + service.setName(service_name) service.setThreadable(self.threadable.isChecked()) service.setMinCores(self.min_cores.value()) service.setMaxCores(self.max_cores.value())