diff --git a/pype/muster/muster.py b/pype/muster/muster.py index 27cd6f73ec..66c7a94994 100644 --- a/pype/muster/muster.py +++ b/pype/muster/muster.py @@ -93,7 +93,7 @@ class MusterModule: 'password': password } api_entry = '/api/login' - response = requests.post( + response = self._requests_post( MUSTER_REST_URL + api_entry, params=params) if response.status_code != 200: self.log.error( @@ -125,3 +125,17 @@ class MusterModule: Show dialog to enter credentials """ self.widget_login.show() + + def _requests_post(self, *args, **kwargs): + """ Wrapper for requests, disabling SSL certificate validation if + DONT_VERIFY_SSL environment variable is found. This is useful when + Deadline or Muster server are running with self-signed certificates + and their certificate is not added to trusted certificates on + client machines. + + WARNING: disabling SSL certificate validation is defeating one line + of defense SSL is providing and it is not recommended. + """ + if 'verify' not in kwargs: + kwargs['verify'] = False if os.getenv("PYPE_DONT_VERIFY_SSL", True) else True # noqa + return requests.post(*args, **kwargs) diff --git a/pype/plugin.py b/pype/plugin.py index a3460e693e..cbe8ba47d7 100644 --- a/pype/plugin.py +++ b/pype/plugin.py @@ -46,7 +46,7 @@ class ContextPlugin(pyblish.api.ContextPlugin): class InstancePlugin(pyblish.api.InstancePlugin): def process(cls, *args, **kwargs): imprint_attributes(cls) - super(ContextPlugin, cls).process(cls, *args, **kwargs) + super(InstancePlugin, cls).process(cls, *args, **kwargs) class Extractor(InstancePlugin): diff --git a/pype/plugins/global/publish/extract_jpeg.py b/pype/plugins/global/publish/extract_jpeg.py index e4ff7a6407..10c339e0c6 100644 --- a/pype/plugins/global/publish/extract_jpeg.py +++ b/pype/plugins/global/publish/extract_jpeg.py @@ -48,7 +48,8 @@ class ExtractJpegEXR(pyblish.api.InstancePlugin): profile = config_data.get(proj_name, config_data['__default__']) jpeg_items = [] - jpeg_items.append("ffmpeg") + jpeg_items.append( + os.path.join(os.environ.get("FFMPEG_PATH"), "ffmpeg")) # override file if already exists jpeg_items.append("-y") # use same input args like with mov diff --git a/pype/plugins/global/publish/extract_review.py b/pype/plugins/global/publish/extract_review.py index 7e67ef7bab..1a7dcced78 100644 --- a/pype/plugins/global/publish/extract_review.py +++ b/pype/plugins/global/publish/extract_review.py @@ -163,7 +163,10 @@ class ExtractReview(pyblish.api.InstancePlugin): # output filename output_args.append(full_output_path) mov_args = [ - "ffmpeg", + os.path.join( + os.environ.get( + "FFMPEG_PATH", + ""), "ffmpeg"), " ".join(input_args), " ".join(output_args) ] diff --git a/pype/plugins/global/publish/validate_ffmpeg_installed.py b/pype/plugins/global/publish/validate_ffmpeg_installed.py index 250da0afd9..d8976a94b0 100644 --- a/pype/plugins/global/publish/validate_ffmpeg_installed.py +++ b/pype/plugins/global/publish/validate_ffmpeg_installed.py @@ -23,6 +23,8 @@ class ValidateFfmpegInstallef(pyblish.api.Validator): return True def process(self, instance): - if self.is_tool('ffmpeg') is False: + if self.is_tool( + os.path.join( + os.environ.get("FFMPEG_PATH", ""), "ffmpeg")) is False: self.log.error("ffmpeg not found in PATH") raise RuntimeError('ffmpeg not installed.') diff --git a/pype/plugins/maya/create/create_renderglobals.py b/pype/plugins/maya/create/create_renderglobals.py index 12b9766381..ac6048a3e7 100644 --- a/pype/plugins/maya/create/create_renderglobals.py +++ b/pype/plugins/maya/create/create_renderglobals.py @@ -160,7 +160,35 @@ class CreateRenderGlobals(avalon.maya.Creator): api_url = "{}/muster/show_login".format( os.environ["PYPE_REST_API_URL"]) self.log.debug(api_url) - login_response = requests.post(api_url, timeout=1) + login_response = self._requests_post(api_url, timeout=1) if login_response.status_code != 200: self.log.error('Cannot show login form to Muster') raise Exception('Cannot show login form to Muster') + + def _requests_post(self, *args, **kwargs): + """ Wrapper for requests, disabling SSL certificate validation if + DONT_VERIFY_SSL environment variable is found. This is useful when + Deadline or Muster server are running with self-signed certificates + and their certificate is not added to trusted certificates on + client machines. + + WARNING: disabling SSL certificate validation is defeating one line + of defense SSL is providing and it is not recommended. + """ + if 'verify' not in kwargs: + kwargs['verify'] = False if os.getenv("PYPE_DONT_VERIFY_SSL", True) else True # noqa + return requests.post(*args, **kwargs) + + def _requests_get(self, *args, **kwargs): + """ Wrapper for requests, disabling SSL certificate validation if + DONT_VERIFY_SSL environment variable is found. This is useful when + Deadline or Muster server are running with self-signed certificates + and their certificate is not added to trusted certificates on + client machines. + + WARNING: disabling SSL certificate validation is defeating one line + of defense SSL is providing and it is not recommended. + """ + if 'verify' not in kwargs: + kwargs['verify'] = False if os.getenv("PYPE_DONT_VERIFY_SSL", True) else True # noqa + return requests.get(*args, **kwargs) diff --git a/pype/plugins/maya/publish/submit_maya_deadline.py b/pype/plugins/maya/publish/submit_maya_deadline.py index a9017e5178..5bb50bd85e 100644 --- a/pype/plugins/maya/publish/submit_maya_deadline.py +++ b/pype/plugins/maya/publish/submit_maya_deadline.py @@ -111,7 +111,11 @@ class MayaSubmitDeadline(pyblish.api.InstancePlugin): order = pyblish.api.IntegratorOrder + 0.1 hosts = ["maya"] families = ["renderlayer"] - optional = True + if not os.environ.get("DEADLINE_REST_URL"): + optional = False + active = False + else: + optional = True def process(self, instance): @@ -319,7 +323,7 @@ class MayaSubmitDeadline(pyblish.api.InstancePlugin): # E.g. http://192.168.0.1:8082/api/jobs url = "{}/api/jobs".format(DEADLINE_REST_URL) - response = requests.post(url, json=payload) + response = self._requests_post(url, json=payload) if not response.ok: raise Exception(response.text) @@ -340,3 +344,31 @@ class MayaSubmitDeadline(pyblish.api.InstancePlugin): "%f=%d was rounded off to nearest integer" % (value, int(value)) ) + + def _requests_post(self, *args, **kwargs): + """ Wrapper for requests, disabling SSL certificate validation if + DONT_VERIFY_SSL environment variable is found. This is useful when + Deadline or Muster server are running with self-signed certificates + and their certificate is not added to trusted certificates on + client machines. + + WARNING: disabling SSL certificate validation is defeating one line + of defense SSL is providing and it is not recommended. + """ + if 'verify' not in kwargs: + kwargs['verify'] = False if os.getenv("PYPE_DONT_VERIFY_SSL", True) else True # noqa + return requests.post(*args, **kwargs) + + def _requests_get(self, *args, **kwargs): + """ Wrapper for requests, disabling SSL certificate validation if + DONT_VERIFY_SSL environment variable is found. This is useful when + Deadline or Muster server are running with self-signed certificates + and their certificate is not added to trusted certificates on + client machines. + + WARNING: disabling SSL certificate validation is defeating one line + of defense SSL is providing and it is not recommended. + """ + if 'verify' not in kwargs: + kwargs['verify'] = False if os.getenv("PYPE_DONT_VERIFY_SSL", True) else True # noqa + return requests.get(*args, **kwargs) diff --git a/pype/plugins/maya/publish/submit_maya_muster.py b/pype/plugins/maya/publish/submit_maya_muster.py index 2fb760eddf..ac60c40bf7 100644 --- a/pype/plugins/maya/publish/submit_maya_muster.py +++ b/pype/plugins/maya/publish/submit_maya_muster.py @@ -1,12 +1,16 @@ import os import json -from maya import cmds -from avalon import api -from avalon.vendor import requests -import pyblish.api -import pype.maya.lib as lib +import getpass import appdirs import platform + +from maya import cmds + +from avalon import api +from avalon.vendor import requests + +import pyblish.api +import pype.maya.lib as lib from pypeapp import config @@ -137,8 +141,12 @@ class MayaSubmitMuster(pyblish.api.InstancePlugin): order = pyblish.api.IntegratorOrder + 0.1 hosts = ["maya"] families = ["renderlayer"] - optional = True icon = "satellite-dish" + if not os.environ.get("MUSTER_REST_URL"): + optional = False + active = False + else: + optional = True _token = None @@ -175,7 +183,7 @@ class MayaSubmitMuster(pyblish.api.InstancePlugin): "select": "name" } api_entry = '/api/templates/list' - response = requests.post( + response = self._requests_post( self.MUSTER_REST_URL + api_entry, params=params) if response.status_code != 200: self.log.error( @@ -226,7 +234,7 @@ class MayaSubmitMuster(pyblish.api.InstancePlugin): "name": "submit" } api_entry = '/api/queue/actions' - response = requests.post( + response = self._requests_post( self.MUSTER_REST_URL + api_entry, params=params, json=payload) if response.status_code != 200: @@ -318,7 +326,10 @@ class MayaSubmitMuster(pyblish.api.InstancePlugin): muster_python = ("\"C:\\\\Program Files\\\\Virtual Vertex\\\\" "Muster 9\\\\MPython.exe\"") else: - muster_python = "/usr/local/muster9/mpython" + # we need to run pype as different user then Muster dispatcher + # service is running (usually root). + muster_python = ("/usr/sbin/runuser -u {}" + " -- /usr/bin/python3".format(getpass.getuser())) # build the path and argument. We are providing separate --pype # argument with network path to pype as post job actions are run @@ -550,3 +561,17 @@ class MayaSubmitMuster(pyblish.api.InstancePlugin): "%f=%d was rounded off to nearest integer" % (value, int(value)) ) + + def _requests_post(self, *args, **kwargs): + """ Wrapper for requests, disabling SSL certificate validation if + DONT_VERIFY_SSL environment variable is found. This is useful when + Deadline or Muster server are running with self-signed certificates + and their certificate is not added to trusted certificates on + client machines. + + WARNING: disabling SSL certificate validation is defeating one line + of defense SSL is providing and it is not recommended. + """ + if 'verify' not in kwargs: + kwargs['verify'] = False if os.getenv("PYPE_DONT_VERIFY_SSL", True) else True # noqa + return requests.post(*args, **kwargs) diff --git a/pype/plugins/maya/publish/submit_vray_deadline.py b/pype/plugins/maya/publish/submit_vray_deadline.py index 8854edec03..e9bdb7e377 100644 --- a/pype/plugins/maya/publish/submit_vray_deadline.py +++ b/pype/plugins/maya/publish/submit_vray_deadline.py @@ -25,6 +25,11 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): order = pyblish.api.IntegratorOrder hosts = ["maya"] families = ["vrayscene"] + if not os.environ.get("DEADLINE_REST_URL"): + optional = False + active = False + else: + optional = True def process(self, instance): @@ -109,7 +114,7 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): self.log.info("Job Data:\n{}".format(json.dumps(payload))) - response = requests.post(url=deadline_url, json=payload) + response = self._requests_post(url=deadline_url, json=payload) if not response.ok: raise RuntimeError(response.text) @@ -188,7 +193,7 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): self.log.info(json.dumps(payload_b)) # Post job to deadline - response_b = requests.post(url=deadline_url, json=payload_b) + response_b = self._requests_post(url=deadline_url, json=payload_b) if not response_b.ok: raise RuntimeError(response_b.text) @@ -272,3 +277,17 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): result = filename_zero.replace("\\", "/") return result + + def _requests_post(self, *args, **kwargs): + """ Wrapper for requests, disabling SSL certificate validation if + DONT_VERIFY_SSL environment variable is found. This is useful when + Deadline or Muster server are running with self-signed certificates + and their certificate is not added to trusted certificates on + client machines. + + WARNING: disabling SSL certificate validation is defeating one line + of defense SSL is providing and it is not recommended. + """ + if 'verify' not in kwargs: + kwargs['verify'] = False if os.getenv("PYPE_DONT_VERIFY_SSL", True) else True # noqa + return requests.post(*args, **kwargs) diff --git a/pype/plugins/maya/publish/validate_deadline_connection.py b/pype/plugins/maya/publish/validate_deadline_connection.py index 2daf7aebe0..f9c11620ba 100644 --- a/pype/plugins/maya/publish/validate_deadline_connection.py +++ b/pype/plugins/maya/publish/validate_deadline_connection.py @@ -28,8 +28,22 @@ class ValidateDeadlineConnection(pyblish.api.ContextPlugin): raise ValueError("Deadline REST API url not found.") # Check response - response = requests.get(DEADLINE_REST_URL) + response = self._requests_get(DEADLINE_REST_URL) assert response.ok, "Response must be ok" assert response.text.startswith("Deadline Web Service "), ( "Web service did not respond with 'Deadline Web Service'" ) + + def _requests_get(self, *args, **kwargs): + """ Wrapper for requests, disabling SSL certificate validation if + DONT_VERIFY_SSL environment variable is found. This is useful when + Deadline or Muster server are running with self-signed certificates + and their certificate is not added to trusted certificates on + client machines. + + WARNING: disabling SSL certificate validation is defeating one line + of defense SSL is providing and it is not recommended. + """ + if 'verify' not in kwargs: + kwargs['verify'] = False if os.getenv("PYPE_DONT_VERIFY_SSL", True) else True # noqa + return requests.get(*args, **kwargs) diff --git a/pype/plugins/maya/publish/validate_muster_connection.py b/pype/plugins/maya/publish/validate_muster_connection.py index 08bc83e0a0..1c49c95446 100644 --- a/pype/plugins/maya/publish/validate_muster_connection.py +++ b/pype/plugins/maya/publish/validate_muster_connection.py @@ -50,7 +50,7 @@ class ValidateMusterConnection(pyblish.api.ContextPlugin): 'authToken': self._token } api_entry = '/api/pools/list' - response = requests.get( + response = self._requests_get( MUSTER_REST_URL + api_entry, params=params) assert response.status_code == 200, "invalid response from server" assert response.json()['ResponseData'], "invalid data in response" @@ -87,7 +87,35 @@ class ValidateMusterConnection(pyblish.api.ContextPlugin): api_url = "{}/muster/show_login".format( os.environ["PYPE_REST_API_URL"]) cls.log.debug(api_url) - response = requests.post(api_url, timeout=1) + response = cls._requests_post(api_url, timeout=1) if response.status_code != 200: cls.log.error('Cannot show login form to Muster') raise Exception('Cannot show login form to Muster') + + def _requests_post(self, *args, **kwargs): + """ Wrapper for requests, disabling SSL certificate validation if + DONT_VERIFY_SSL environment variable is found. This is useful when + Deadline or Muster server are running with self-signed certificates + and their certificate is not added to trusted certificates on + client machines. + + WARNING: disabling SSL certificate validation is defeating one line + of defense SSL is providing and it is not recommended. + """ + if 'verify' not in kwargs: + kwargs['verify'] = False if os.getenv("PYPE_DONT_VERIFY_SSL", True) else True # noqa + return requests.post(*args, **kwargs) + + def _requests_get(self, *args, **kwargs): + """ Wrapper for requests, disabling SSL certificate validation if + DONT_VERIFY_SSL environment variable is found. This is useful when + Deadline or Muster server are running with self-signed certificates + and their certificate is not added to trusted certificates on + client machines. + + WARNING: disabling SSL certificate validation is defeating one line + of defense SSL is providing and it is not recommended. + """ + if 'verify' not in kwargs: + kwargs['verify'] = False if os.getenv("PYPE_DONT_VERIFY_SSL", True) else True # noqa + return requests.get(*args, **kwargs)