From 71df17d701efeb74f128fc320350172ab4c1b20a Mon Sep 17 00:00:00 2001 From: David Lai Date: Tue, 4 Feb 2020 00:09:41 +0800 Subject: [PATCH 1/3] Update targets only when provided --- pyblish_qml/host.py | 7 ++++--- pyblish_qml/ipc/server.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pyblish_qml/host.py b/pyblish_qml/host.py index 6330035..ded25e8 100644 --- a/pyblish_qml/host.py +++ b/pyblish_qml/host.py @@ -77,7 +77,7 @@ def uninstall(): def show(parent=None, - targets=[], + targets=None, modal=None, auto_publish=False, auto_validate=False): @@ -110,8 +110,9 @@ def show(parent=None, proxy = ipc.server.Proxy(server) try: - # Update target - proxy.target(targets) + if targets: + # Update targets + proxy.target(targets) proxy.show(show_settings) return server diff --git a/pyblish_qml/ipc/server.py b/pyblish_qml/ipc/server.py index bcb5f80..14ce3cf 100644 --- a/pyblish_qml/ipc/server.py +++ b/pyblish_qml/ipc/server.py @@ -116,7 +116,7 @@ def __init__(self, service, python=None, pyqt5=None, - targets=[], + targets=None, modal=False, environ=None): From 3fdccb551ab00079acc80803d824fc77ab62deb7 Mon Sep 17 00:00:00 2001 From: davidlatwe Date: Tue, 4 Feb 2020 11:34:54 +0800 Subject: [PATCH 2/3] Set to default targets if no targets provided --- pyblish_qml/host.py | 11 ++++++++--- pyblish_qml/ipc/server.py | 7 ------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/pyblish_qml/host.py b/pyblish_qml/host.py index ded25e8..8c05e22 100644 --- a/pyblish_qml/host.py +++ b/pyblish_qml/host.py @@ -97,6 +97,12 @@ def show(parent=None, if modal is None: modal = bool(os.environ.get("PYBLISH_QML_MODAL", False)) + if not targets: + # If no targets are passed to pyblish-qml, we assume that we want the + # default target and the registered targets. This is to facilitate + # getting all plugins on pyblish_qml.show(). + targets = ["default"] + pyblish.api.registered_targets() + # Automatically install if not already installed. install(modal) @@ -110,9 +116,8 @@ def show(parent=None, proxy = ipc.server.Proxy(server) try: - if targets: - # Update targets - proxy.target(targets) + # Update targets + proxy.target(targets) proxy.show(show_settings) return server diff --git a/pyblish_qml/ipc/server.py b/pyblish_qml/ipc/server.py index 14ce3cf..0feb08d 100644 --- a/pyblish_qml/ipc/server.py +++ b/pyblish_qml/ipc/server.py @@ -201,14 +201,7 @@ def __init__(self, # from opening an external terminal window. kwargs["creationflags"] = CREATE_NO_WINDOW - # If no targets are passed to pyblish-qml, we assume that we want the - # default target and the registered targets. This is to facilitate - # getting all plugins on pyblish_qml.show(). - import pyblish.api - if not targets: - targets = ["default"] + pyblish.api.registered_targets() print("Targets: {0}".format(", ".join(targets))) - kwargs["args"].append("--targets") kwargs["args"].extend(targets) From 839b1d993e32844fa71cfb78f1367894fe97a24b Mon Sep 17 00:00:00 2001 From: davidlatwe Date: Thu, 6 Feb 2020 13:08:17 +0800 Subject: [PATCH 3/3] Remove mutable default arg value --- pyblish_qml/app.py | 4 ++-- pyblish_qml/control.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pyblish_qml/app.py b/pyblish_qml/app.py index 3de9cb8..b4c546f 100644 --- a/pyblish_qml/app.py +++ b/pyblish_qml/app.py @@ -76,7 +76,7 @@ class Application(QtGui.QGuiApplication): inFocused = QtCore.pyqtSignal() outFocused = QtCore.pyqtSignal() - def __init__(self, source, targets=[]): + def __init__(self, source, targets=None): super(Application, self).__init__(sys.argv) self.setWindowIcon(QtGui.QIcon(ICON_PATH)) @@ -281,7 +281,7 @@ def _listen(): thread.start() -def main(demo=False, aschild=False, targets=[]): +def main(demo=False, aschild=False, targets=None): """Start the Qt-runtime and show the window Arguments: diff --git a/pyblish_qml/control.py b/pyblish_qml/control.py index 478e5a6..188c91f 100644 --- a/pyblish_qml/control.py +++ b/pyblish_qml/control.py @@ -61,13 +61,13 @@ class Controller(QtCore.QObject): resultModel = qtproperty(lambda self: self.data["models"]["result"]) resultProxy = qtproperty(lambda self: self.data["proxies"]["result"]) - def __init__(self, host, parent=None, targets=[]): + def __init__(self, host, parent=None, targets=None): super(Controller, self).__init__(parent) # Connection to host self.host = host - self.targets = targets + self.targets = targets or [] self.data = { "models": { @@ -984,7 +984,7 @@ def on_finished(): util.defer(get_data, callback=on_data_received) - def run(self, plugins, context, callback=None, callback_args=[]): + def run(self, plugins, context, callback=None, callback_args=None): """Commence asynchronous tasks This method runs through the provided `plugins` in @@ -1001,6 +1001,7 @@ def run(self, plugins, context, callback=None, callback_args=[]): callback_args (list, optional): Arguments passed to callback """ + callback_args = callback_args or [] # if "ready" not in self.states: # return self.error.emit("Not ready")