-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nuke): add python2 project warning
- Loading branch information
1 parent
52979cf
commit fc7ac0e
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# -*- coding=UTF-8 -*- | ||
# pyright: strict, reportTypeCommentUsage=none | ||
|
||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
TYPE_CHECKING = False | ||
if TYPE_CHECKING: | ||
from typing import Any | ||
|
||
|
||
import sys | ||
import wulifang | ||
import nuke | ||
from wulifang._util import cast_str | ||
|
||
|
||
def init_gui(): | ||
if sys.version_info.major == 2: | ||
return | ||
|
||
raw_hook = sys.excepthook | ||
|
||
def hook(type, value, traceback): | ||
# type: (type[BaseException], BaseException, Any) -> None | ||
if raw_hook: # type: ignore | ||
raw_hook(type, value, traceback) | ||
if ( | ||
isinstance(value, NameError) | ||
and value.args == ("name 'unicode' is not defined",) | ||
and nuke.value(cast_str("root.name"), cast_str("")) | ||
): | ||
wulifang.message.info( | ||
"脚本出错,python 版本不兼容。当前工程需使用 Nuke12 以下版本。" | ||
) | ||
|
||
def cleanup(): | ||
if sys.excepthook == hook: | ||
sys.excepthook = raw_hook | ||
|
||
sys.excepthook = hook | ||
wulifang.cleanup.add(cleanup) |