ayon-core/openpype/plugins/load/open_file.py
Roy Nieterau f58994d59c Loader: Remove context argument from Loader.__init__() (#4602)
* Remove Loader `context` argument to __init__

* Add backwards compatibility for Loader.load by still setting `.fname` attr

* Refactor/remove usage of `self.fname` in loaders

* Fix some refactoring

* Fix some refactoring

* Hound

* Revert invalid refactor

* Fix refactor

* Fix playblast panel collection

* Refactor missing method

* Fix typo

* Use the correct `context`

---------

Co-authored-by: Toke Stuart Jepsen <tokejepsen@gmail.com>
Co-authored-by: Kayla Man <64118225+moonyuet@users.noreply.github.com>
Co-authored-by: Jakub Trllo <jakub.trllo@gmail.com>
2023-07-11 17:48:33 +02:00

36 lines
882 B
Python

import sys
import os
import subprocess
from openpype.pipeline import load
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 OpenFile(load.LoaderPlugin):
"""Open Image Sequence or Video with system default"""
families = ["render2d"]
representations = ["*"]
label = "Open"
order = -10
icon = "play-circle"
color = "orange"
def load(self, context, name, namespace, data):
path = self.filepath_from_context(context)
if not os.path.exists(path):
raise RuntimeError("File not found: {}".format(path))
self.log.info("Opening : {}".format(path))
open(path)