From 2df97d8ca5116f9978141d1c4df85b9f4b4ed597 Mon Sep 17 00:00:00 2001 From: davidlatwe Date: Mon, 17 Aug 2020 18:29:33 +0800 Subject: [PATCH 01/11] Add raising TypeError on invalid `root` and doc string updated --- allzpark/control.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/allzpark/control.py b/allzpark/control.py index c152f5c..11da9ed 100644 --- a/allzpark/control.py +++ b/allzpark/control.py @@ -47,7 +47,7 @@ def __init__(self, ctrl, storage): "profileName": storage.value("startupProfile"), "appRequest": storage.value("startupApplication"), - # String or callable, returning list of profile names + # list or callable, returning list of profile names "root": None, # Current error, if any @@ -444,7 +444,7 @@ def find(self, family, range_=None): Arguments: family (str): Name of package - range (str): Range, e.g. "1" or "==0.3.13" + range_ (str): Range, e.g. "1" or "==0.3.13" """ @@ -552,8 +552,9 @@ def reset(self, root=None, on_success=lambda: None): with its corresponding Rez package. Arguments: - root (str): Absolute path to profiles on disk, or callable - returning names of profiles + root (list, callable): A list of profile names, or a callable + returning names of profiles. + on_success (callable): Callback on reset completed. """ @@ -811,6 +812,10 @@ def list_profiles(self, root=None): self.error("Could not find profiles in %s" % root) profiles = [] + else: + raise TypeError("Argument 'root' should be either list type or " + "callable.") + # Facilitate accidental empty family names, e.g. None or '' profiles = list(filter(None, profiles)) From 080fe7042c823a3c6f470a5018991313f022969f Mon Sep 17 00:00:00 2001 From: davidlatwe Date: Mon, 17 Aug 2020 18:36:18 +0800 Subject: [PATCH 02/11] Add `profile_paths` for specific profile packages search --- allzpark/allzparkconfig.py | 6 ++++++ allzpark/cli.py | 3 ++- allzpark/control.py | 18 ++++++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/allzpark/allzparkconfig.py b/allzpark/allzparkconfig.py index fc15a05..601f326 100644 --- a/allzpark/allzparkconfig.py +++ b/allzpark/allzparkconfig.py @@ -24,6 +24,12 @@ # Where to go when clicking the logo help_url = "https://allzpark.com" +# A list of paths for finding profile packages +# This is useful if you have specific paths only for profile packages. +# Caveat: If this given, other paths (e.g. rez.config.packages_path) +# will be ignored. +profile_paths = None + def profiles(): """Return list of profiles diff --git a/allzpark/cli.py b/allzpark/cli.py index 75927b9..4e6a4f2 100644 --- a/allzpark/cli.py +++ b/allzpark/cli.py @@ -365,7 +365,8 @@ def init(): profiles = profiles_from_dir(opts.root) root = profiles or allzparkconfig.profiles - ctrl.reset(root, on_success=measure) + paths = allzparkconfig.profile_paths + ctrl.reset(root, paths=paths, on_success=measure) def measure(): duration = time.time() - timing["beforeReset"] diff --git a/allzpark/control.py b/allzpark/control.py index 11da9ed..56ced46 100644 --- a/allzpark/control.py +++ b/allzpark/control.py @@ -50,6 +50,9 @@ def __init__(self, ctrl, storage): # list or callable, returning list of profile names "root": None, + # Specific paths for finding profile packages + "profilePaths": None, + # Current error, if any "error": None, @@ -439,17 +442,18 @@ def on_unhandled_exception(self, type, value, tb): def stdio(self, stream, level=logging.INFO): return _Stream(self, stream, level) - def find(self, family, range_=None): + def find(self, family, range_=None, paths=None): """Find packages, relative Allzpark state Arguments: family (str): Name of package range_ (str): Range, e.g. "1" or "==0.3.13" + paths (list): Designated package paths to search """ package_filter = self._package_filter() - paths = self._package_paths() + paths = paths or self._package_paths() it = rez.find(family, range_, paths=paths) it = sorted( it, @@ -545,7 +549,7 @@ def _package_filter(self): return package_filter @util.async_ - def reset(self, root=None, on_success=lambda: None): + def reset(self, root=None, paths=None, on_success=lambda: None): """Initialise controller with `root` Profiles are listed at `root` and matched @@ -554,12 +558,17 @@ def reset(self, root=None, on_success=lambda: None): Arguments: root (list, callable): A list of profile names, or a callable returning names of profiles. + paths (list): List of package path where profiles being installed, + useful if you have specific paths only for profile packages. + If this given, other paths (e.g. rez.config.packages_path) + will be ignored. on_success (callable): Callback on reset completed. """ self.info("Resetting..") root = root or self._state["root"] + paths = paths or self._state["profilePaths"] assert root, "Tried resetting without a root, this is a bug" def do(): @@ -570,7 +579,7 @@ def do(): # Find profile package package = None - for package in self.find(name): + for package in self.find(name, paths=paths): if name not in profiles: profiles[name] = dict() @@ -609,6 +618,7 @@ def do(): self._state["profileName"] = current_profile self._state["root"] = root + self._state["profilePaths"] = paths self._state.to_ready() self.resetted.emit() From cdbfd4b27f5da8b146ec0deb922947e7fd3f4f92 Mon Sep 17 00:00:00 2001 From: davidlatwe Date: Mon, 17 Aug 2020 19:14:30 +0800 Subject: [PATCH 03/11] Rename to align Rez's `packages_path` --- allzpark/allzparkconfig.py | 2 +- allzpark/cli.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/allzpark/allzparkconfig.py b/allzpark/allzparkconfig.py index 601f326..73effff 100644 --- a/allzpark/allzparkconfig.py +++ b/allzpark/allzparkconfig.py @@ -28,7 +28,7 @@ # This is useful if you have specific paths only for profile packages. # Caveat: If this given, other paths (e.g. rez.config.packages_path) # will be ignored. -profile_paths = None +profiles_path = None def profiles(): diff --git a/allzpark/cli.py b/allzpark/cli.py index 4e6a4f2..0c669d6 100644 --- a/allzpark/cli.py +++ b/allzpark/cli.py @@ -365,7 +365,7 @@ def init(): profiles = profiles_from_dir(opts.root) root = profiles or allzparkconfig.profiles - paths = allzparkconfig.profile_paths + paths = allzparkconfig.profiles_path ctrl.reset(root, paths=paths, on_success=measure) def measure(): From 744f03445882fe8e791b3a6a1b99122114780a6e Mon Sep 17 00:00:00 2001 From: davidlatwe Date: Mon, 17 Aug 2020 19:28:49 +0800 Subject: [PATCH 04/11] Rename state entry profilePaths -> profilesPath --- allzpark/control.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/allzpark/control.py b/allzpark/control.py index 56ced46..0a95c3d 100644 --- a/allzpark/control.py +++ b/allzpark/control.py @@ -51,7 +51,7 @@ def __init__(self, ctrl, storage): "root": None, # Specific paths for finding profile packages - "profilePaths": None, + "profilesPath": None, # Current error, if any "error": None, @@ -568,7 +568,7 @@ def reset(self, root=None, paths=None, on_success=lambda: None): self.info("Resetting..") root = root or self._state["root"] - paths = paths or self._state["profilePaths"] + paths = paths or self._state["profilesPath"] assert root, "Tried resetting without a root, this is a bug" def do(): @@ -618,7 +618,7 @@ def do(): self._state["profileName"] = current_profile self._state["root"] = root - self._state["profilePaths"] = paths + self._state["profilesPath"] = paths self._state.to_ready() self.resetted.emit() From 343aa96f07eaca97066f0f1ad777f6c6fdaa7a8b Mon Sep 17 00:00:00 2001 From: davidlatwe Date: Mon, 17 Aug 2020 19:29:39 +0800 Subject: [PATCH 05/11] Show profiles path in Preferences widget --- allzpark/cli.py | 3 +++ allzpark/dock.py | 1 + 2 files changed, 4 insertions(+) diff --git a/allzpark/cli.py b/allzpark/cli.py index 0c669d6..3bb5cdc 100644 --- a/allzpark/cli.py +++ b/allzpark/cli.py @@ -293,6 +293,9 @@ def main(): if allzparkconfig.startup_application: storage.setValue("startupApp", allzparkconfig.startup_application) + if allzparkconfig.profiles_path: + storage.setValue("profilesPath", allzparkconfig.profiles_path) + if opts.demo: # Normally unsafe, but for the purposes of a demo # a convenient location for installed packages diff --git a/allzpark/dock.py b/allzpark/dock.py index 5676964..4814973 100644 --- a/allzpark/dock.py +++ b/allzpark/dock.py @@ -1025,6 +1025,7 @@ class Preferences(AbstractDockWidget): qargparse.InfoList("rezPackagesPath"), qargparse.InfoList("rezLocalPath"), qargparse.InfoList("rezReleasePath"), + qargparse.InfoList("profilesPath"), qargparse.Info("settingsPath"), ] From 7899241d7cde3fbebf52d21efdccd10a3ab4e9aa Mon Sep 17 00:00:00 2001 From: davidlatwe Date: Mon, 17 Aug 2020 21:14:39 +0800 Subject: [PATCH 06/11] Include profile_paths when resolving context --- allzpark/control.py | 1 + 1 file changed, 1 insertion(+) diff --git a/allzpark/control.py b/allzpark/control.py index 0a95c3d..297be2e 100644 --- a/allzpark/control.py +++ b/allzpark/control.py @@ -482,6 +482,7 @@ def env(self, request, use_filter=True): package_filter = self._package_filter() paths = self._package_paths() + paths += self._state["profilesPath"] or [] return rez.env( request, From 2b94ae65c3130272fe25b40e2ac823265b158d3a Mon Sep 17 00:00:00 2001 From: davidlatwe Date: Mon, 17 Aug 2020 21:17:49 +0800 Subject: [PATCH 07/11] Improve log message appearances Line breaks and spaces are now preserved. --- allzpark/control.py | 2 +- allzpark/dock.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/allzpark/control.py b/allzpark/control.py index 297be2e..114b43f 100644 --- a/allzpark/control.py +++ b/allzpark/control.py @@ -388,7 +388,7 @@ def on_unhandled_exception(self, type, value, tb): # package family not found: occoc (searched: C:\) _, package, paths = value.value.split(": ", 2) package = package.split(" (", 1)[0] - paths = paths.rstrip(")").split(os.pathsep) + paths = paths.rstrip(")").split("; ") # Hard-coded pathsep in Rez message = """

:(

diff --git a/allzpark/dock.py b/allzpark/dock.py index 4814973..a9c1a14 100644 --- a/allzpark/dock.py +++ b/allzpark/dock.py @@ -245,6 +245,8 @@ def append(self, line, level=logging.INFO): logging.CRITICAL: "", }.get(level, "") + line = line.replace(" ", " ") + line = line.replace("\n", "
") line = "%s%s

" % (color, line) cursor = self._widgets["text"].textCursor() From 718e6de376c9749823e595f0a31fe1da7ebdbc23 Mon Sep 17 00:00:00 2001 From: davidlatwe Date: Mon, 17 Aug 2020 22:45:31 +0800 Subject: [PATCH 08/11] Revert un-needed changes --- allzpark/cli.py | 3 +-- allzpark/control.py | 23 ++++++++--------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/allzpark/cli.py b/allzpark/cli.py index 3bb5cdc..d9a1198 100644 --- a/allzpark/cli.py +++ b/allzpark/cli.py @@ -368,8 +368,7 @@ def init(): profiles = profiles_from_dir(opts.root) root = profiles or allzparkconfig.profiles - paths = allzparkconfig.profiles_path - ctrl.reset(root, paths=paths, on_success=measure) + ctrl.reset(root, on_success=measure) def measure(): duration = time.time() - timing["beforeReset"] diff --git a/allzpark/control.py b/allzpark/control.py index 114b43f..ae18c44 100644 --- a/allzpark/control.py +++ b/allzpark/control.py @@ -50,9 +50,6 @@ def __init__(self, ctrl, storage): # list or callable, returning list of profile names "root": None, - # Specific paths for finding profile packages - "profilesPath": None, - # Current error, if any "error": None, @@ -442,18 +439,17 @@ def on_unhandled_exception(self, type, value, tb): def stdio(self, stream, level=logging.INFO): return _Stream(self, stream, level) - def find(self, family, range_=None, paths=None): + def find(self, family, range_=None): """Find packages, relative Allzpark state Arguments: family (str): Name of package range_ (str): Range, e.g. "1" or "==0.3.13" - paths (list): Designated package paths to search """ package_filter = self._package_filter() - paths = paths or self._package_paths() + paths = self._package_paths() it = rez.find(family, range_, paths=paths) it = sorted( it, @@ -482,7 +478,6 @@ def env(self, request, use_filter=True): package_filter = self._package_filter() paths = self._package_paths() - paths += self._state["profilesPath"] or [] return rez.env( request, @@ -550,7 +545,7 @@ def _package_filter(self): return package_filter @util.async_ - def reset(self, root=None, paths=None, on_success=lambda: None): + def reset(self, root=None, on_success=lambda: None): """Initialise controller with `root` Profiles are listed at `root` and matched @@ -559,17 +554,12 @@ def reset(self, root=None, paths=None, on_success=lambda: None): Arguments: root (list, callable): A list of profile names, or a callable returning names of profiles. - paths (list): List of package path where profiles being installed, - useful if you have specific paths only for profile packages. - If this given, other paths (e.g. rez.config.packages_path) - will be ignored. on_success (callable): Callback on reset completed. """ self.info("Resetting..") root = root or self._state["root"] - paths = paths or self._state["profilesPath"] assert root, "Tried resetting without a root, this is a bug" def do(): @@ -580,7 +570,7 @@ def do(): # Find profile package package = None - for package in self.find(name, paths=paths): + for package in self.find(name): if name not in profiles: profiles[name] = dict() @@ -619,7 +609,6 @@ def do(): self._state["profileName"] = current_profile self._state["root"] = root - self._state["profilesPath"] = paths self._state.to_ready() self.resetted.emit() @@ -973,6 +962,10 @@ def _package_paths(self): # It may not be part of the path pass + # Optional setup for profile packages specific paths + if allzparkconfig.profiles_path: + paths += allzparkconfig.profiles_path + return paths def _list_apps(self, profile): From 7338b91d91e4b8a44af5e06598fe4de0f47448ef Mon Sep 17 00:00:00 2001 From: davidlatwe Date: Mon, 17 Aug 2020 23:03:02 +0800 Subject: [PATCH 09/11] Update comment --- allzpark/allzparkconfig.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/allzpark/allzparkconfig.py b/allzpark/allzparkconfig.py index 73effff..5e0c5c1 100644 --- a/allzpark/allzparkconfig.py +++ b/allzpark/allzparkconfig.py @@ -26,8 +26,6 @@ # A list of paths for finding profile packages # This is useful if you have specific paths only for profile packages. -# Caveat: If this given, other paths (e.g. rez.config.packages_path) -# will be ignored. profiles_path = None From eeb0321599e290b10074afc8237d895d89720c7a Mon Sep 17 00:00:00 2001 From: davidlatwe Date: Tue, 18 Aug 2020 00:29:48 +0800 Subject: [PATCH 10/11] Drop `profiles_path` See mottosso/allzpark#102 --- allzpark/allzparkconfig.py | 4 ---- allzpark/cli.py | 3 --- allzpark/control.py | 4 ---- allzpark/dock.py | 1 - 4 files changed, 12 deletions(-) diff --git a/allzpark/allzparkconfig.py b/allzpark/allzparkconfig.py index 5e0c5c1..fc15a05 100644 --- a/allzpark/allzparkconfig.py +++ b/allzpark/allzparkconfig.py @@ -24,10 +24,6 @@ # Where to go when clicking the logo help_url = "https://allzpark.com" -# A list of paths for finding profile packages -# This is useful if you have specific paths only for profile packages. -profiles_path = None - def profiles(): """Return list of profiles diff --git a/allzpark/cli.py b/allzpark/cli.py index d9a1198..75927b9 100644 --- a/allzpark/cli.py +++ b/allzpark/cli.py @@ -293,9 +293,6 @@ def main(): if allzparkconfig.startup_application: storage.setValue("startupApp", allzparkconfig.startup_application) - if allzparkconfig.profiles_path: - storage.setValue("profilesPath", allzparkconfig.profiles_path) - if opts.demo: # Normally unsafe, but for the purposes of a demo # a convenient location for installed packages diff --git a/allzpark/control.py b/allzpark/control.py index ae18c44..0d5c359 100644 --- a/allzpark/control.py +++ b/allzpark/control.py @@ -962,10 +962,6 @@ def _package_paths(self): # It may not be part of the path pass - # Optional setup for profile packages specific paths - if allzparkconfig.profiles_path: - paths += allzparkconfig.profiles_path - return paths def _list_apps(self, profile): diff --git a/allzpark/dock.py b/allzpark/dock.py index a9c1a14..a60b1f3 100644 --- a/allzpark/dock.py +++ b/allzpark/dock.py @@ -1027,7 +1027,6 @@ class Preferences(AbstractDockWidget): qargparse.InfoList("rezPackagesPath"), qargparse.InfoList("rezLocalPath"), qargparse.InfoList("rezReleasePath"), - qargparse.InfoList("profilesPath"), qargparse.Info("settingsPath"), ] From 9ff1ea7ddb34556c8a1eaa5714688d1fa8df3cb4 Mon Sep 17 00:00:00 2001 From: davidlatwe Date: Tue, 18 Aug 2020 02:21:14 +0800 Subject: [PATCH 11/11] Leave rez.config.packages_path untouched --- allzpark/control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/allzpark/control.py b/allzpark/control.py index 0d5c359..6444ef5 100644 --- a/allzpark/control.py +++ b/allzpark/control.py @@ -946,7 +946,7 @@ def select_tool(self, tool_name): def _package_paths(self): """Return all package paths, relative the current state of the world""" - paths = util.normpaths(*rez.config.packages_path) + paths = rez.config.packages_path[:] # Optional development packages if not self._state.retrieve("useDevelopmentPackages"):