From 15d9eea96bf908933968393faa3963b00c179074 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Tue, 10 May 2022 15:11:11 -0400 Subject: [PATCH] New script that returns the SERVER_NAME of the current instance --- crc/scripts/get_instance.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 crc/scripts/get_instance.py diff --git a/crc/scripts/get_instance.py b/crc/scripts/get_instance.py new file mode 100644 index 00000000..5bf36a06 --- /dev/null +++ b/crc/scripts/get_instance.py @@ -0,0 +1,18 @@ +from crc import app +from crc.scripts.script import Script + + +class GetInstance(Script): + + def get_description(self): + return """Get the name of the current instance, using the SERVER_NAME environment variable.""" + + def do_task_validate_only(self, task, study_id, workflow_id, *args, **kwargs): + return self.do_task(task, study_id, workflow_id, *args, **kwargs) + + def do_task(self, task, study_id, workflow_id, *args, **kwargs): + if 'SERVER_NAME' in app.config: + return app.config['SERVER_NAME'] + # TODO: Not sure what we should do here + app.logger.info('no_server_name: SERVER_NAME not configured for this server.') + return ''