diff --git a/pype/hosts/maya/plugins/publish/validate_unicode_strings.py b/pype/hosts/maya/plugins/publish/validate_unicode_strings.py deleted file mode 100644 index cfcba4f514..0000000000 --- a/pype/hosts/maya/plugins/publish/validate_unicode_strings.py +++ /dev/null @@ -1,40 +0,0 @@ -import os -from maya import cmds - -import pyblish.api -import pype.api -import pype.hosts.maya.api.action - - -class ValidateUnicodeStrings(pyblish.api.Validator): - """Validate all environment variables are string type. - - """ - - order = pype.api.ValidateContentsOrder - hosts = ['maya'] - families = ['review'] - label = 'Unicode Strings' - actions = [pype.api.RepairAction] - - def process(self, instance): - invalid = self.get_invalid(instance) - if invalid: - raise RuntimeError("Found unicode strings in environment variables.") - - @classmethod - def get_invalid(cls, instance): - invalid = [] - for key, value in os.environ.items(): - if type(value) is type(u't'): - invalid.append((key, value)) - - return invalid - - @classmethod - def repair(cls, instance): - """Retype all unicodes to strings.""" - - for key, value in os.environ.items(): - if type(value) is type(u't'): - os.environ[key] = str(value) diff --git a/pype/lib/execute.py b/pype/lib/execute.py index 7e37e5d6da..f815d05f1b 100644 --- a/pype/lib/execute.py +++ b/pype/lib/execute.py @@ -94,7 +94,7 @@ def run_subprocess(*args, **kwargs): # not passed. env = kwargs.get("env") or os.environ # Make sure environment contains only strings - filtered_env = {k: str(v) for k, v in env.items()} + filtered_env = {str(k): str(v) for k, v in env.items()} # Use lib's logger if was not passed with kwargs. logger = kwargs.pop("logger", log) diff --git a/pype/plugins/publish/repair_unicode_strings.py b/pype/plugins/publish/repair_unicode_strings.py new file mode 100644 index 0000000000..fdd4bb7d03 --- /dev/null +++ b/pype/plugins/publish/repair_unicode_strings.py @@ -0,0 +1,15 @@ +import os +import pyblish.api + + +class RepairUnicodeStrings(pyblish.api.Collector): + """Validate all environment variables are string type. + + """ + + order = pyblish.api.CollectorOrder + label = 'Unicode Strings' + + def process(self, context): + for key, value in os.environ.items(): + os.environ[str(key)] = str(value)