From 476c03bfbfeea7922d0a7c7983defc787a9e822f Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Fri, 22 Feb 2019 17:26:26 +0100 Subject: [PATCH] initial commit added action --- pype/plugins/global/load/open_djv.py | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 pype/plugins/global/load/open_djv.py diff --git a/pype/plugins/global/load/open_djv.py b/pype/plugins/global/load/open_djv.py new file mode 100644 index 0000000000..eadc973d2f --- /dev/null +++ b/pype/plugins/global/load/open_djv.py @@ -0,0 +1,49 @@ +import sys +import os +import subprocess + +from avalon import api + + +def open(filepath): + """Open file with system default executable""" + if sys.platform.startswith('darwin'): + subprocess.call(('open', filepath)) + elif os.name == 'nt': + os.startfile(filepath) + elif os.name == 'posix': + subprocess.call(('xdg-open', filepath)) + + +class OpenInDJV(api.Loader): + """Open Image Sequence with system default""" + + # families = ["write"] + representations = ["*"] + + label = "Open in DJV" + order = -10 + icon = "play-circle" + color = "orange" + + def load(self, context, name, namespace, data): + + directory = self.fname + from avalon.vendor import clique + + pattern = clique.PATTERNS["frames"] + files = os.listdir(directory) + collections, remainder = clique.assemble(files, + patterns=[pattern], + minimum_items=1) + + assert not remainder, ("There shouldn't have been a remainder for " + "'%s': %s" % (directory, remainder)) + + seqeunce = collections[0] + first_image = list(seqeunce)[0] + filepath = os.path.normpath(os.path.join(directory, first_image)) + + self.log.info("Opening : {}".format(filepath)) + + open(filepath)