Skip to content

Commit

Permalink
Add import_nuke function
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Einfalt committed Feb 28, 2017
1 parent 48a1828 commit e6e2b32
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 13 additions & 1 deletion nukecontexts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
import logging
import platform


def import_nuke():
try:
import nuke
return nuke
except ImportError as e:
try:
os.environ['NON_PRODUCTION_CONTEXT']
except KeyError:
raise e


TESTING = False
try:
TESTING = os.environ['NON_PRODUCTION_CONTEXT']
Expand All @@ -21,7 +33,7 @@
match = re.search(application, sys.executable)
if not match:
raise RuntimeError('Import nukecontexts from within Nuke')
import nuke
nuke = import_nuke()

__version__ = '0.1.4'
__all__ = ['ctx']
Expand Down
5 changes: 3 additions & 2 deletions nukecontexts/ctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

from tqdm import tqdm

from nukecontexts import logger
from nukecontexts import sentry
from nukecontexts import import_nuke, logger, sentry

nuke = import_nuke()


class NukeContextError(ValueError):
Expand Down

0 comments on commit e6e2b32

Please sign in to comment.