Skip to content

Commit

Permalink
Merge pull request #36 from tokejepsen/publish_silent
Browse files Browse the repository at this point in the history
Silent publishing
  • Loading branch information
tokejepsen authored Jul 24, 2018
2 parents 5073788 + 92d02a8 commit b2b749f
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 6 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ import pyblish_nuke
pyblish_nuke.setup()
```

#### Publishing

There are two options in the file menu to publishing with:

- ```Publish```: Publishing with a silent non-GUI publish, which is fast but does not show the registered GUI.
![oct 31 2017 3-49 pm](https://user-images.githubusercontent.com/1860085/32230460-810fb154-be53-11e7-8bea-0c9a81cf8476.gif)
- ```Publish...```: Publishing with the registered GUI.



<br>
<br>
<br>
Expand Down
3 changes: 2 additions & 1 deletion pyblish_nuke/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
register_plugins,
register_host,
add_to_filemenu,
dock
dock,
publish
)
Binary file added pyblish_nuke/failed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 81 additions & 3 deletions pyblish_nuke/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# Local libraries
from . import plugins
from .vendor.Qt import QtWidgets, QtGui
from .vendor.Qt import QtWidgets, QtGui, QtCore


cached_process = None
Expand Down Expand Up @@ -144,10 +144,88 @@ def add_to_filemenu():

shortcut = os.environ.get("PYBLISH_HOTKEY", "")

cmd = "import pyblish_nuke;pyblish_nuke.show()"
cmd = "import pyblish_nuke;pyblish_nuke.publish()"
menu.addCommand("Publish", cmd, shortcut, index=9)
cmd = "import pyblish_nuke;pyblish_nuke.show()"
menu.addCommand("Publish...", cmd, shortcut, index=10)

menu.addSeparator(index=11)


class Splash(QtWidgets.QWidget):
"""Splash screen for publishing."""

def __init__(self, parent=None):
super(Splash, self).__init__(parent)
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setWindowFlags(
QtCore.Qt.WindowStaysOnTopHint |
QtCore.Qt.FramelessWindowHint
)

pixmap = QtGui.QPixmap(
os.path.join(os.path.dirname(__file__), "splash.png")
)
image = QtWidgets.QLabel()
image.setPixmap(pixmap)

layout = QtWidgets.QVBoxLayout(self)
layout.addWidget(image)

self.bar = QtGui.QProgressBar()
layout.addWidget(self.bar)

# Center widget on screen
self.resize(100, 100)


def publish():

splash = Splash()
splash.show()

def on_published(context):
pyblish.api.deregister_callback(*callback)

try:
splash.close()
except RuntimeError:
# Splash already closed
pass

errors = False
for r in context.data["results"]:
if r["error"]:
errors = True

messagebox = QtWidgets.QMessageBox()

pixmap_path = os.path.join(os.path.dirname(__file__), "success.png")
messagebox_text = "Publish successfull."
if errors:
pixmap_path = os.path.join(os.path.dirname(__file__), "failed.png")
messagebox_text = (
"Publish failed.\n\nSee script editor for details."
)

messagebox.setIconPixmap(QtGui.QPixmap(pixmap_path))

messagebox.setWindowTitle("Publish")
messagebox.setText(messagebox_text)
messagebox.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)

messagebox.exec_()

callback = "published", on_published
pyblish.api.register_callback(*callback)

def publish_iter():

for result in pyblish.util.publish_iter():
splash.bar.setValue(result["progress"] * 100)

menu.addSeparator(index=10)
QtCore.QTimer.singleShot(10, publish_iter)


def _show_no_gui():
Expand Down
Binary file added pyblish_nuke/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pyblish_nuke/success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions pyblish_nuke/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

VERSION_MAJOR = 2
VERSION_MINOR = 0
VERSION_PATCH = 4
VERSION_MINOR = 1
VERSION_PATCH = 0

version_info = (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
version = '%i.%i.%i' % version_info
Expand Down

0 comments on commit b2b749f

Please sign in to comment.