From 8159b029d573ffdc22e556caafae6bc96843986e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Tue, 10 Dec 2019 12:25:24 +0000 Subject: [PATCH 1/4] (genera) fixing subprocess function to allow pass through Popen.subprocess arguments. Also adding better output for running subprocess --- pype/lib.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/pype/lib.py b/pype/lib.py index c8fade7f4a..8772608b38 100644 --- a/pype/lib.py +++ b/pype/lib.py @@ -14,24 +14,35 @@ log = logging.getLogger(__name__) # Special naming case for subprocess since its a built-in method. -def _subprocess(args): +def _subprocess(*args, **kwargs): """Convenience method for getting output errors for subprocess.""" # make sure environment contains only strings - env = {k: str(v) for k, v in os.environ.items()} + filtered_env = {k: str(v) for k, v in os.environ.items()} - proc = subprocess.Popen( - args, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - stdin=subprocess.PIPE, - env=env - ) + # set overrides + kwargs['stdout'] = kwargs.get('stdout', subprocess.PIPE) + kwargs['stderr'] = kwargs.get('stderr', subprocess.STDOUT) + kwargs['stdin'] = kwargs.get('stdin', subprocess.PIPE) + kwargs['env'] = kwargs.get('env',filtered_env) - output = proc.communicate()[0] + proc = subprocess.Popen(*args, **kwargs) + + output, error = proc.communicate() + + if output: + output = output.decode("utf-8") + output += "\n" + for line in output.strip().split("\n"): + log.info(line) + + if error: + error = error.decode("utf-8") + error += "\n" + for line in error.strip().split("\n"): + log.error(line) if proc.returncode != 0: - log.error(output) raise ValueError("\"{}\" was not successful: {}".format(args, output)) return output From 73e50fa03fcc6efccbcf49cfac120e3dbb4bf01a Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Sun, 5 Jan 2020 14:24:56 +0100 Subject: [PATCH 2/4] change label to see whole label value --- pype/ftrack/actions/action_seed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pype/ftrack/actions/action_seed.py b/pype/ftrack/actions/action_seed.py index cf0a4b0445..5cbc5d1cec 100644 --- a/pype/ftrack/actions/action_seed.py +++ b/pype/ftrack/actions/action_seed.py @@ -9,7 +9,7 @@ class SeedDebugProject(BaseAction): #: Action identifier. identifier = "seed.debug.project" #: Action label. - label = "SeedDebugProject" + label = "Seed Debug Project" #: Action description. description = "Description" #: priority From 0024688a449a81919ab4b3331126a4f451a112ff Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Sun, 5 Jan 2020 14:25:50 +0100 Subject: [PATCH 3/4] convert input values to integer and set to 0 if not successful --- pype/ftrack/actions/action_seed.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pype/ftrack/actions/action_seed.py b/pype/ftrack/actions/action_seed.py index 5cbc5d1cec..260e854d14 100644 --- a/pype/ftrack/actions/action_seed.py +++ b/pype/ftrack/actions/action_seed.py @@ -265,6 +265,11 @@ class SeedDebugProject(BaseAction): def create_assets(self, project, asset_count): self.log.debug("*** Creating assets:") + try: + asset_count = int(asset_count) + except ValueError: + asset_count = 0 + main_entity = self.session.create("Folder", { "name": "Assets", "parent": project @@ -305,6 +310,19 @@ class SeedDebugProject(BaseAction): def create_shots(self, project, seq_count, shots_count): self.log.debug("*** Creating shots:") + + # Convert counts to integers + try: + seq_count = int(seq_count) + except ValueError: + seq_count = 0 + + try: + shots_count = int(shots_count) + except ValueError: + shots_count = 0 + + # Create Folder "Shots" main_entity = self.session.create("Folder", { "name": "Shots", "parent": project From 080f1f6819d09b5c7d9ca8c3f3bc061998e9933b Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Sun, 5 Jan 2020 14:26:13 +0100 Subject: [PATCH 4/4] check if input values of seeder are greater than 0 --- pype/ftrack/actions/action_seed.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pype/ftrack/actions/action_seed.py b/pype/ftrack/actions/action_seed.py index 260e854d14..1238e73e72 100644 --- a/pype/ftrack/actions/action_seed.py +++ b/pype/ftrack/actions/action_seed.py @@ -270,6 +270,10 @@ class SeedDebugProject(BaseAction): except ValueError: asset_count = 0 + if asset_count <= 0: + self.log.debug("No assets to create") + return + main_entity = self.session.create("Folder", { "name": "Assets", "parent": project @@ -322,6 +326,18 @@ class SeedDebugProject(BaseAction): except ValueError: shots_count = 0 + # Check if both are higher than 0 + missing = [] + if seq_count <= 0: + missing.append("sequences") + + if shots_count <= 0: + missing.append("shots") + + if missing: + self.log.debug("No {} to create".format(" and ".join(missing))) + return + # Create Folder "Shots" main_entity = self.session.create("Folder", { "name": "Shots",