From f4fcdfb148eb5aba47f9c00e4dc2e7bd9b20aea4 Mon Sep 17 00:00:00 2001 From: aardschok Date: Fri, 18 Aug 2017 16:04:59 +0200 Subject: [PATCH] open image sequence with plugin --- .../plugins/maya/load/load_imagesequence.py | 49 +++++++++++++++++++ colorbleed/plugins/publish/cleanup.py | 0 2 files changed, 49 insertions(+) create mode 100644 colorbleed/plugins/maya/load/load_imagesequence.py create mode 100644 colorbleed/plugins/publish/cleanup.py diff --git a/colorbleed/plugins/maya/load/load_imagesequence.py b/colorbleed/plugins/maya/load/load_imagesequence.py new file mode 100644 index 0000000000..27e24f4782 --- /dev/null +++ b/colorbleed/plugins/maya/load/load_imagesequence.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 OpenImageSequence(api.Loader): + """Open Image Sequence with system default""" + + families = ["colorbleed.imagesequence"] + representations = ["*"] + + label = "Open sequence" + order = -10 + icon = "play-circle" + color = "orange" + + def process(self, name, namespace, context, 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) diff --git a/colorbleed/plugins/publish/cleanup.py b/colorbleed/plugins/publish/cleanup.py new file mode 100644 index 0000000000..e69de29bb2