From 1ad1cea494b435b5b66fc9b28909b58dd0fa7ff7 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Tue, 10 Nov 2020 01:04:22 +0100 Subject: [PATCH] remove modified_environ function --- pype/api.py | 1 - pype/lib/__init__.py | 1 - pype/lib/lib_old.py | 32 ------- .../launcher/actions/unused/PremierePro.py | 83 ------------------- 4 files changed, 117 deletions(-) delete mode 100644 pype/plugins/launcher/actions/unused/PremierePro.py diff --git a/pype/api.py b/pype/api.py index 2c7dfa73f0..a6762beca3 100644 --- a/pype/api.py +++ b/pype/api.py @@ -43,7 +43,6 @@ from .lib import ( get_subsets, get_version_from_path, get_last_version_from_path, - modified_environ, add_tool_to_environment, source_hash, get_latest_version diff --git a/pype/lib/__init__.py b/pype/lib/__init__.py index 18531ca05c..c9ea8e7676 100644 --- a/pype/lib/__init__.py +++ b/pype/lib/__init__.py @@ -22,7 +22,6 @@ from .lib_old import ( get_ffmpeg_tool_path, get_hierarchy, add_tool_to_environment, - modified_environ, is_latest, any_outdated, _rreplace, diff --git a/pype/lib/lib_old.py b/pype/lib/lib_old.py index 7f5523b6b5..92ce206bf7 100644 --- a/pype/lib/lib_old.py +++ b/pype/lib/lib_old.py @@ -197,38 +197,6 @@ def add_tool_to_environment(tools): os.environ.update(env) -@contextlib.contextmanager -def modified_environ(*remove, **update): - """ - Temporarily updates the ``os.environ`` dictionary in-place. - - The ``os.environ`` dictionary is updated in-place so that the modification - is sure to work in all situations. - - :param remove: Environment variables to remove. - :param update: Dictionary of environment variables - and values to add/update. - """ - env = os.environ - update = update or {} - remove = remove or [] - - # List of environment variables being updated or removed. - stomped = (set(update.keys()) | set(remove)) & set(env.keys()) - # Environment variables and values to restore on exit. - update_after = {k: env[k] for k in stomped} - # Environment variables and values to remove on exit. - remove_after = frozenset(k for k in update if k not in env) - - try: - env.update(update) - [env.pop(k, None) for k in remove] - yield - finally: - env.update(update_after) - [env.pop(k) for k in remove_after] - - def is_latest(representation): """Return whether the representation is from latest version diff --git a/pype/plugins/launcher/actions/unused/PremierePro.py b/pype/plugins/launcher/actions/unused/PremierePro.py deleted file mode 100644 index e460af1451..0000000000 --- a/pype/plugins/launcher/actions/unused/PremierePro.py +++ /dev/null @@ -1,83 +0,0 @@ -import os -import acre - -from avalon import api, lib, io -import pype.api as pype - - -class PremierePro(api.Action): - - name = "premiere_2019" - label = "Premiere Pro" - icon = "premiere_icon" - order = 996 - - def is_compatible(self, session): - """Return whether the action is compatible with the session""" - if "AVALON_TASK" in session: - return True - return False - - def process(self, session, **kwargs): - """Implement the behavior for when the action is triggered - - Args: - session (dict): environment dictionary - - Returns: - Popen instance of newly spawned process - - """ - - with pype.modified_environ(**session): - # Get executable by name - app = lib.get_application(self.name) - executable = lib.which(app["executable"]) - - # Run as server - arguments = [] - - tools_env = acre.get_tools([self.name]) - env = acre.compute(tools_env) - env = acre.merge(env, current_env=dict(os.environ)) - - if not env.get('AVALON_WORKDIR', None): - project_name = env.get("AVALON_PROJECT") - anatomy = pype.Anatomy(project_name) - os.environ['AVALON_PROJECT'] = project_name - io.Session['AVALON_PROJECT'] = project_name - - task_name = os.environ.get( - "AVALON_TASK", io.Session["AVALON_TASK"] - ) - asset_name = os.environ.get( - "AVALON_ASSET", io.Session["AVALON_ASSET"] - ) - application = lib.get_application( - os.environ["AVALON_APP_NAME"] - ) - - project_doc = io.find_one({"type": "project"}) - data = { - "task": task_name, - "asset": asset_name, - "project": { - "name": project_doc["name"], - "code": project_doc["data"].get("code", '') - }, - "hierarchy": pype.get_hierarchy(), - "app": application["application_dir"] - } - anatomy_filled = anatomy.format(data) - workdir = anatomy_filled["work"]["folder"] - - os.environ["AVALON_WORKDIR"] = workdir - - env.update(dict(os.environ)) - - lib.launch( - executable=executable, - args=arguments, - environment=env - ) - return