Access mds_var variables from script that run during workflow.

Issue #418 resolved
Christopher Bradsher created an issue

It would be nice to be able to access the mds_var variables from with a script that runs "when running workflow." The main use case I have is to be able to validate inputs eg.

if [[ -z $mds_var1 ]]; then
  echo "No username filled in. Stopping."
  exit 1
fi

if [[ $mds_var1 != $mds_var2 ]]; then
  echo "Username filled in as ${mds_var1} and ${mds_var2} which don't match. Stopping."
  exit 1
fi

Since the environment variables aren’t set until after reboot this is not currently possible to my knowledge.

Comments (6)

  1. Christopher Bradsher reporter

    Went ahead and implemented it. The Imagr fork doesn’t appear to be up to date so I had to manually edit MainController.py inside the release copy of Imagr.app

    diff --git a/Imagr/MainController.py b/Imagr/MainController.py
    index 241ee90..4d5bd17 100644
    --- a/Imagr/MainController.py
    +++ b/Imagr/MainController.py
    @@ -1898,6 +1898,9 @@ class MainController(NSObject):
             my_env = os.environ.copy()
             url_parse = urlparse.urlparse(Utils.getServerURL())
             my_env["server_path"]=url_parse.path
    +        if self.environmentVariableArray:
    +            for var in self.environmentVariableArray:
    +                my_env[var.keys()[0].replace("com.twocanoes.mds.", "mds_")] = var.values()[0]
             proc = subprocess.Popen(script_file.name, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True,env=my_env)
             while proc.poll() is None:
                 output = proc.stdout.readline().strip().decode('UTF-8')
    

  2. Log in to comment