maya-umbrella 0.3.0__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of maya-umbrella might be problematic. Click here for more details.
- maya_umbrella-0.4.1/PKG-INFO +138 -0
- maya_umbrella-0.4.1/README.md +112 -0
- maya_umbrella-0.4.1/maya_umbrella/__init__.py +5 -0
- maya_umbrella-0.4.1/maya_umbrella/__version__.py +1 -0
- maya_umbrella-0.4.1/maya_umbrella/constants.py +5 -0
- maya_umbrella-0.4.1/maya_umbrella/core.py +117 -0
- {maya_umbrella-0.3.0 → maya_umbrella-0.4.1}/maya_umbrella/filesystem.py +35 -2
- {maya_umbrella-0.3.0 → maya_umbrella-0.4.1}/maya_umbrella/hooks/delete_turtle.py +7 -2
- {maya_umbrella-0.3.0 → maya_umbrella-0.4.1}/maya_umbrella/hooks/delete_unknown_plugin_node.py +8 -7
- {maya_umbrella-0.3.0 → maya_umbrella-0.4.1}/maya_umbrella/hooks/fix_model_panel.py +2 -3
- maya_umbrella-0.4.1/maya_umbrella/hooks/fix_on_model_change_3dc.py +19 -0
- maya_umbrella-0.4.1/maya_umbrella/log.py +37 -0
- maya_umbrella-0.4.1/maya_umbrella/vaccine.py +222 -0
- maya_umbrella-0.4.1/maya_umbrella/vaccines/vaccine1.py +17 -0
- maya_umbrella-0.4.1/maya_umbrella/vaccines/vaccine2.py +60 -0
- maya_umbrella-0.4.1/maya_umbrella/vaccines/vaccine3.py +78 -0
- {maya_umbrella-0.3.0 → maya_umbrella-0.4.1}/pyproject.toml +74 -4
- maya_umbrella-0.3.0/PKG-INFO +0 -85
- maya_umbrella-0.3.0/README.md +0 -59
- maya_umbrella-0.3.0/maya_umbrella/__init__.py +0 -5
- maya_umbrella-0.3.0/maya_umbrella/__version__.py +0 -1
- maya_umbrella-0.3.0/maya_umbrella/core.py +0 -76
- maya_umbrella-0.3.0/maya_umbrella/hooks/fix_on_model_change_3dc.py +0 -14
- maya_umbrella-0.3.0/maya_umbrella/vaccine.py +0 -80
- maya_umbrella-0.3.0/maya_umbrella/vaccines/vaccine1.py +0 -19
- maya_umbrella-0.3.0/maya_umbrella/vaccines/vaccine2.py +0 -65
- maya_umbrella-0.3.0/maya_umbrella/vaccines/vaccine3.py +0 -110
- {maya_umbrella-0.3.0 → maya_umbrella-0.4.1}/LICENSE +0 -0
- {maya_umbrella-0.3.0 → maya_umbrella-0.4.1}/maya_umbrella/hooks/__init__.py +0 -0
- {maya_umbrella-0.3.0 → maya_umbrella-0.4.1}/maya_umbrella/vaccines/__init__.py +0 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: maya_umbrella
|
|
3
|
+
Version: 0.4.1
|
|
4
|
+
Summary: Check and fix maya virus.
|
|
5
|
+
Home-page: https://github.com/loonghao/maya_umbrella
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: notifiers,python,Maya,dcc
|
|
8
|
+
Author: longhao
|
|
9
|
+
Author-email: hal.long@outlook.com
|
|
10
|
+
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 2
|
|
13
|
+
Classifier: Programming Language :: Python :: 2.7
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Project-URL: Documentation, https://github.com/loonghao/maya_umbrella
|
|
23
|
+
Project-URL: Repository, https://github.com/loonghao/maya_umbrella
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# maya-umbrella
|
|
27
|
+
|
|
28
|
+
[](https://img.shields.io/pypi/pyversions/maya-umbrella)
|
|
29
|
+
[](https://github.com/wntrblm/nox)
|
|
30
|
+
[](https://pypi.org/project/maya-umbrella/)
|
|
31
|
+
[](https://pypi.org/project/maya-umbrella/)
|
|
32
|
+
[](https://pepy.tech/project/maya-umbrella)
|
|
33
|
+
[](https://pypi.org/project/maya-umbrella/)
|
|
34
|
+
[](https://pypi.org/project/maya-umbrella/)
|
|
35
|
+
[](https://github.com/loonghao/maya-umbrella/graphs/commit-activity)
|
|
36
|
+
[](https://img.shields.io/badge/maya-2024-green)
|
|
37
|
+
[](https://img.shields.io/badge/maya-2023-green)
|
|
38
|
+
[](https://img.shields.io/badge/maya-2022-green)
|
|
39
|
+
[](https://img.shields.io/badge/maya-2021-green)
|
|
40
|
+
[](https://img.shields.io/badge/maya-2020-green)
|
|
41
|
+
[](https://img.shields.io/badge/maya-2019-green)
|
|
42
|
+
[](https://img.shields.io/badge/maya-2018-green)
|
|
43
|
+
|
|
44
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
45
|
+
[](#contributors-)
|
|
46
|
+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
47
|
+
|
|
48
|
+
Check and fix maya virus.
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# 发开环境设置
|
|
52
|
+
|
|
53
|
+
通过虚拟环境去设置开发环境, 推荐python-3.8以上的版本
|
|
54
|
+
|
|
55
|
+
```shell
|
|
56
|
+
pip install nox poetry
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
# 开发调试
|
|
60
|
+
|
|
61
|
+
```shell
|
|
62
|
+
nox -s maya-2020
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 在maya中测试
|
|
66
|
+
|
|
67
|
+
通过`nox -s maya-xxx`, 启动maya.
|
|
68
|
+
nox会动态根据你本地安装得maya去注册nox session, 比如你本地安装了`maya-2020`,那么通过`nox -s maya-2018`
|
|
69
|
+
|
|
70
|
+
启动maya后在脚本编辑器中执行下面得代码,就会动态的从`<repo>/tests/virus/`里面去open ma文件去进行测试.
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import manual_test_in_maya
|
|
74
|
+
|
|
75
|
+
manual_test_in_maya.start()
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 增加新的疫苗
|
|
79
|
+
|
|
80
|
+
在`<repo>/maya_umbrella/vaccines/` 新建一个py, 因为有很多病毒没有具体的名字代号,我们统一以`vaccine<id>.py`
|
|
81
|
+
继承`from maya_umbrella.vaccine import AbstractVaccine`并且class名字叫`Vaccine`即可, 然后去写具体的收集病毒逻辑
|
|
82
|
+
|
|
83
|
+
## 代码检查
|
|
84
|
+
|
|
85
|
+
我们可以利用封装好的`nox`命令去执行进行代码检查
|
|
86
|
+
|
|
87
|
+
```shell
|
|
88
|
+
nox -s ruff_check
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
# 环境变量
|
|
92
|
+
|
|
93
|
+
我们可以通过下列环境变量去修改maya_umbrella的一些设置,方便有pipeline的公司可以更好的集成
|
|
94
|
+
|
|
95
|
+
修改maya umbrella的日志保存目录,默认是windows temp目录
|
|
96
|
+
|
|
97
|
+
```shell
|
|
98
|
+
MAYA_UMBRELLA_LOG_ROOT
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
修改maya umbrella的日志文件名称, 默认是`maya_umbrella`
|
|
102
|
+
|
|
103
|
+
```shell
|
|
104
|
+
MAYA_UMBRELLA_LOG_NAME
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
设置日志级别,默认是info, 可以是debug可以看到更多的日志信息
|
|
108
|
+
|
|
109
|
+
```shell
|
|
110
|
+
MAYA_UMBRELLA_LOG_LEVEL
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Contributors ✨
|
|
114
|
+
|
|
115
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
116
|
+
|
|
117
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
118
|
+
<!-- prettier-ignore-start -->
|
|
119
|
+
<!-- markdownlint-disable -->
|
|
120
|
+
<table>
|
|
121
|
+
<tbody>
|
|
122
|
+
<tr>
|
|
123
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/loonghao"><img src="https://avatars1.githubusercontent.com/u/13111745?v=4?s=100" width="100px;" alt="Hal"/><br /><sub><b>Hal</b></sub></a><br /><a href="https://github.com/loonghao/maya_umbrella/commits?author=loonghao" title="Code">💻</a> <a href="#infra-loonghao" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/loonghao/maya_umbrella/commits?author=loonghao" title="Tests">⚠️</a></td>
|
|
124
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/hotwinter0"><img src="https://avatars.githubusercontent.com/u/106237305?v=4?s=100" width="100px;" alt="hotwinter0"/><br /><sub><b>hotwinter0</b></sub></a><br /><a href="https://github.com/loonghao/maya_umbrella/commits?author=hotwinter0" title="Tests">⚠️</a> <a href="https://github.com/loonghao/maya_umbrella/commits?author=hotwinter0" title="Code">💻</a></td>
|
|
125
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/lingyunfx"><img src="https://avatars.githubusercontent.com/u/73666629?v=4?s=100" width="100px;" alt="lingyunfx"/><br /><sub><b>lingyunfx</b></sub></a><br /><a href="https://github.com/loonghao/maya_umbrella/commits?author=lingyunfx" title="Tests">⚠️</a></td>
|
|
126
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/yjjjj"><img src="https://avatars.githubusercontent.com/u/12741735?v=4?s=100" width="100px;" alt="yjjjj"/><br /><sub><b>yjjjj</b></sub></a><br /><a href="https://github.com/loonghao/maya_umbrella/commits?author=yjjjj" title="Tests">⚠️</a> <a href="https://github.com/loonghao/maya_umbrella/commits?author=yjjjj" title="Code">💻</a></td>
|
|
127
|
+
</tr>
|
|
128
|
+
</tbody>
|
|
129
|
+
</table>
|
|
130
|
+
|
|
131
|
+
<!-- markdownlint-restore -->
|
|
132
|
+
<!-- prettier-ignore-end -->
|
|
133
|
+
|
|
134
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
135
|
+
|
|
136
|
+
This project follows the [all-contributors](https://allcontributors.org) specification.
|
|
137
|
+
Contributions of any kind are welcome!
|
|
138
|
+
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# maya-umbrella
|
|
2
|
+
|
|
3
|
+
[](https://img.shields.io/pypi/pyversions/maya-umbrella)
|
|
4
|
+
[](https://github.com/wntrblm/nox)
|
|
5
|
+
[](https://pypi.org/project/maya-umbrella/)
|
|
6
|
+
[](https://pypi.org/project/maya-umbrella/)
|
|
7
|
+
[](https://pepy.tech/project/maya-umbrella)
|
|
8
|
+
[](https://pypi.org/project/maya-umbrella/)
|
|
9
|
+
[](https://pypi.org/project/maya-umbrella/)
|
|
10
|
+
[](https://github.com/loonghao/maya-umbrella/graphs/commit-activity)
|
|
11
|
+
[](https://img.shields.io/badge/maya-2024-green)
|
|
12
|
+
[](https://img.shields.io/badge/maya-2023-green)
|
|
13
|
+
[](https://img.shields.io/badge/maya-2022-green)
|
|
14
|
+
[](https://img.shields.io/badge/maya-2021-green)
|
|
15
|
+
[](https://img.shields.io/badge/maya-2020-green)
|
|
16
|
+
[](https://img.shields.io/badge/maya-2019-green)
|
|
17
|
+
[](https://img.shields.io/badge/maya-2018-green)
|
|
18
|
+
|
|
19
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
20
|
+
[](#contributors-)
|
|
21
|
+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
22
|
+
|
|
23
|
+
Check and fix maya virus.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# 发开环境设置
|
|
27
|
+
|
|
28
|
+
通过虚拟环境去设置开发环境, 推荐python-3.8以上的版本
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
pip install nox poetry
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
# 开发调试
|
|
35
|
+
|
|
36
|
+
```shell
|
|
37
|
+
nox -s maya-2020
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 在maya中测试
|
|
41
|
+
|
|
42
|
+
通过`nox -s maya-xxx`, 启动maya.
|
|
43
|
+
nox会动态根据你本地安装得maya去注册nox session, 比如你本地安装了`maya-2020`,那么通过`nox -s maya-2018`
|
|
44
|
+
|
|
45
|
+
启动maya后在脚本编辑器中执行下面得代码,就会动态的从`<repo>/tests/virus/`里面去open ma文件去进行测试.
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
import manual_test_in_maya
|
|
49
|
+
|
|
50
|
+
manual_test_in_maya.start()
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## 增加新的疫苗
|
|
54
|
+
|
|
55
|
+
在`<repo>/maya_umbrella/vaccines/` 新建一个py, 因为有很多病毒没有具体的名字代号,我们统一以`vaccine<id>.py`
|
|
56
|
+
继承`from maya_umbrella.vaccine import AbstractVaccine`并且class名字叫`Vaccine`即可, 然后去写具体的收集病毒逻辑
|
|
57
|
+
|
|
58
|
+
## 代码检查
|
|
59
|
+
|
|
60
|
+
我们可以利用封装好的`nox`命令去执行进行代码检查
|
|
61
|
+
|
|
62
|
+
```shell
|
|
63
|
+
nox -s ruff_check
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
# 环境变量
|
|
67
|
+
|
|
68
|
+
我们可以通过下列环境变量去修改maya_umbrella的一些设置,方便有pipeline的公司可以更好的集成
|
|
69
|
+
|
|
70
|
+
修改maya umbrella的日志保存目录,默认是windows temp目录
|
|
71
|
+
|
|
72
|
+
```shell
|
|
73
|
+
MAYA_UMBRELLA_LOG_ROOT
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
修改maya umbrella的日志文件名称, 默认是`maya_umbrella`
|
|
77
|
+
|
|
78
|
+
```shell
|
|
79
|
+
MAYA_UMBRELLA_LOG_NAME
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
设置日志级别,默认是info, 可以是debug可以看到更多的日志信息
|
|
83
|
+
|
|
84
|
+
```shell
|
|
85
|
+
MAYA_UMBRELLA_LOG_LEVEL
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Contributors ✨
|
|
89
|
+
|
|
90
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
91
|
+
|
|
92
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
93
|
+
<!-- prettier-ignore-start -->
|
|
94
|
+
<!-- markdownlint-disable -->
|
|
95
|
+
<table>
|
|
96
|
+
<tbody>
|
|
97
|
+
<tr>
|
|
98
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/loonghao"><img src="https://avatars1.githubusercontent.com/u/13111745?v=4?s=100" width="100px;" alt="Hal"/><br /><sub><b>Hal</b></sub></a><br /><a href="https://github.com/loonghao/maya_umbrella/commits?author=loonghao" title="Code">💻</a> <a href="#infra-loonghao" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/loonghao/maya_umbrella/commits?author=loonghao" title="Tests">⚠️</a></td>
|
|
99
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/hotwinter0"><img src="https://avatars.githubusercontent.com/u/106237305?v=4?s=100" width="100px;" alt="hotwinter0"/><br /><sub><b>hotwinter0</b></sub></a><br /><a href="https://github.com/loonghao/maya_umbrella/commits?author=hotwinter0" title="Tests">⚠️</a> <a href="https://github.com/loonghao/maya_umbrella/commits?author=hotwinter0" title="Code">💻</a></td>
|
|
100
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/lingyunfx"><img src="https://avatars.githubusercontent.com/u/73666629?v=4?s=100" width="100px;" alt="lingyunfx"/><br /><sub><b>lingyunfx</b></sub></a><br /><a href="https://github.com/loonghao/maya_umbrella/commits?author=lingyunfx" title="Tests">⚠️</a></td>
|
|
101
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/yjjjj"><img src="https://avatars.githubusercontent.com/u/12741735?v=4?s=100" width="100px;" alt="yjjjj"/><br /><sub><b>yjjjj</b></sub></a><br /><a href="https://github.com/loonghao/maya_umbrella/commits?author=yjjjj" title="Tests">⚠️</a> <a href="https://github.com/loonghao/maya_umbrella/commits?author=yjjjj" title="Code">💻</a></td>
|
|
102
|
+
</tr>
|
|
103
|
+
</tbody>
|
|
104
|
+
</table>
|
|
105
|
+
|
|
106
|
+
<!-- markdownlint-restore -->
|
|
107
|
+
<!-- prettier-ignore-end -->
|
|
108
|
+
|
|
109
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
110
|
+
|
|
111
|
+
This project follows the [all-contributors](https://allcontributors.org) specification.
|
|
112
|
+
Contributions of any kind are welcome!
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.4.1"
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Import built-in modules
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
# Import third-party modules
|
|
5
|
+
import maya.api.OpenMaya as om
|
|
6
|
+
import maya.cmds as cmds
|
|
7
|
+
|
|
8
|
+
# Import local modules
|
|
9
|
+
from maya_umbrella.filesystem import get_hooks
|
|
10
|
+
from maya_umbrella.filesystem import get_vaccines
|
|
11
|
+
from maya_umbrella.filesystem import load_hook
|
|
12
|
+
from maya_umbrella.log import setup_logger
|
|
13
|
+
from maya_umbrella.vaccine import MayaVirusCleaner
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class MayaVirusDefender(object):
|
|
17
|
+
callback_ids = []
|
|
18
|
+
remove_callbacks = []
|
|
19
|
+
_bad_files = []
|
|
20
|
+
_vaccines = []
|
|
21
|
+
callback_maps = {
|
|
22
|
+
"after_open": om.MSceneMessage.kAfterOpen,
|
|
23
|
+
"maya_initialized": om.MSceneMessage.kMayaInitialized,
|
|
24
|
+
"after_import": om.MSceneMessage.kAfterImport,
|
|
25
|
+
"after_import_reference": om.MSceneMessage.kAfterImportReference,
|
|
26
|
+
"after_load_reference": om.MSceneMessage.kAfterLoadReference,
|
|
27
|
+
"before_save": om.MSceneMessage.kBeforeSave,
|
|
28
|
+
"before_import": om.MSceneMessage.kBeforeImport,
|
|
29
|
+
"before_load_reference": om.MSceneMessage.kBeforeLoadReference,
|
|
30
|
+
"before_import_reference": om.MSceneMessage.kBeforeImportReference,
|
|
31
|
+
"maya_exiting": om.MSceneMessage.kMayaExiting,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
def __init__(self, auto_fix=True):
|
|
35
|
+
"""Initialize the MayaVirusDefender.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
auto_fix (bool): Whether to automatically fix issues.
|
|
39
|
+
"""
|
|
40
|
+
logger = logging.getLogger(__name__)
|
|
41
|
+
self.auto_fix = auto_fix
|
|
42
|
+
self.logger = setup_logger(logger)
|
|
43
|
+
self.virus_cleaner = MayaVirusCleaner(self.logger)
|
|
44
|
+
self.load_vaccines()
|
|
45
|
+
|
|
46
|
+
def load_vaccines(self):
|
|
47
|
+
"""Load all vaccines."""
|
|
48
|
+
for vaccine in get_vaccines():
|
|
49
|
+
vaccine_class = load_hook(vaccine).Vaccine
|
|
50
|
+
try:
|
|
51
|
+
self._vaccines.append(vaccine_class(api=self.virus_cleaner, logger=self.logger))
|
|
52
|
+
except Exception as e:
|
|
53
|
+
self.logger.error("Error loading vaccine: %s", e)
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def vaccines(self):
|
|
57
|
+
"""Get all loaded vaccines.
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
list: A list of loaded vaccines.
|
|
61
|
+
"""
|
|
62
|
+
return self._vaccines
|
|
63
|
+
|
|
64
|
+
def run_hooks(self):
|
|
65
|
+
"""Run all hooks, only works in non-batch mode."""
|
|
66
|
+
if not cmds.about(batch=True):
|
|
67
|
+
for hook_file in get_hooks():
|
|
68
|
+
self.logger.debug("run_hook: %s", hook_file)
|
|
69
|
+
try:
|
|
70
|
+
load_hook(hook_file).hook(virus_cleaner=self.virus_cleaner)
|
|
71
|
+
except Exception as e:
|
|
72
|
+
self.logger.error("Error running hook: %s", e)
|
|
73
|
+
|
|
74
|
+
def collect(self):
|
|
75
|
+
"""Collect all issues related to the Maya virus."""
|
|
76
|
+
for vaccine in self.vaccines:
|
|
77
|
+
vaccine.collect_issues()
|
|
78
|
+
|
|
79
|
+
def fix(self):
|
|
80
|
+
"""Fix all issues related to the Maya virus."""
|
|
81
|
+
self.virus_cleaner.fix_all_issues()
|
|
82
|
+
|
|
83
|
+
def report(self):
|
|
84
|
+
"""Report all issues related to the Maya virus."""
|
|
85
|
+
self.virus_cleaner.reset_all_issues()
|
|
86
|
+
self.collect()
|
|
87
|
+
self.virus_cleaner.report_all_issues()
|
|
88
|
+
|
|
89
|
+
def setup(self):
|
|
90
|
+
"""Set up the MayaVirusDefender."""
|
|
91
|
+
self.virus_cleaner.setup_default_callbacks()
|
|
92
|
+
for name, callbacks in self.virus_cleaner.registered_callbacks.items():
|
|
93
|
+
maya_callback = self.callback_maps[name]
|
|
94
|
+
self.logger.debug("%s setup.", name)
|
|
95
|
+
for func in callbacks:
|
|
96
|
+
self.callback_ids.append(om.MSceneMessage.addCallback(maya_callback, func))
|
|
97
|
+
for name, callbacks in self.callback_maps.items():
|
|
98
|
+
self.logger.debug("setup callback %s.", name)
|
|
99
|
+
self.callback_ids.append(om.MSceneMessage.addCallback(callbacks, self._callback))
|
|
100
|
+
|
|
101
|
+
def _callback(self, *args, **kwargs):
|
|
102
|
+
"""Callback function for MayaVirusDefender.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
*args: Variable length argument list.
|
|
106
|
+
**kwargs: Arbitrary keyword arguments.
|
|
107
|
+
"""
|
|
108
|
+
if self.auto_fix:
|
|
109
|
+
self.collect()
|
|
110
|
+
self.fix()
|
|
111
|
+
self.run_hooks()
|
|
112
|
+
else:
|
|
113
|
+
self.report()
|
|
114
|
+
|
|
115
|
+
def start(self):
|
|
116
|
+
"""Start the MayaVirusDefender."""
|
|
117
|
+
self._callback()
|
|
@@ -6,6 +6,10 @@ import os
|
|
|
6
6
|
import random
|
|
7
7
|
import shutil
|
|
8
8
|
import string
|
|
9
|
+
import tempfile
|
|
10
|
+
|
|
11
|
+
# Import local modules
|
|
12
|
+
from maya_umbrella.constants import PACKAGE_NAME
|
|
9
13
|
|
|
10
14
|
|
|
11
15
|
def this_root():
|
|
@@ -17,7 +21,7 @@ def safe_remove_file(file_path):
|
|
|
17
21
|
"""Remove the file at the given path without raising an error if the file does not exist."""
|
|
18
22
|
try:
|
|
19
23
|
os.remove(file_path)
|
|
20
|
-
except
|
|
24
|
+
except OSError:
|
|
21
25
|
pass
|
|
22
26
|
|
|
23
27
|
|
|
@@ -25,7 +29,7 @@ def safe_rmtree(path):
|
|
|
25
29
|
"""Remove the directory at the given path without raising an error if the directory does not exist."""
|
|
26
30
|
try:
|
|
27
31
|
shutil.rmtree(path)
|
|
28
|
-
except
|
|
32
|
+
except OSError:
|
|
29
33
|
pass
|
|
30
34
|
|
|
31
35
|
|
|
@@ -106,5 +110,34 @@ def get_hooks():
|
|
|
106
110
|
|
|
107
111
|
|
|
108
112
|
def get_vaccines():
|
|
113
|
+
"""Get a list of all vaccine files.
|
|
114
|
+
|
|
115
|
+
Returns:
|
|
116
|
+
list: A list of vaccine files.
|
|
117
|
+
"""
|
|
109
118
|
pattern = os.path.join(this_root(), "vaccines", "*.py")
|
|
110
119
|
return [vaccine for vaccine in glob.glob(pattern) if "__init__" not in vaccine]
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def get_log_root():
|
|
123
|
+
"""Get the log root directory.
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
str: The log root directory.
|
|
127
|
+
"""
|
|
128
|
+
return os.getenv("MAYA_UMBRELLA_LOG_ROOT", tempfile.gettempdir())
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def get_log_file():
|
|
132
|
+
"""Get the path of the log file.
|
|
133
|
+
|
|
134
|
+
Returns:
|
|
135
|
+
str: The path of the log file.
|
|
136
|
+
"""
|
|
137
|
+
root = get_log_root()
|
|
138
|
+
try:
|
|
139
|
+
os.makedirs(root)
|
|
140
|
+
except OSError:
|
|
141
|
+
pass
|
|
142
|
+
name = os.getenv("MAYA_UMBRELLA_LOG_NAME", PACKAGE_NAME)
|
|
143
|
+
return os.path.join(root, "{name}.log".format(name=name))
|
|
@@ -3,11 +3,16 @@ import maya.cmds as cmds
|
|
|
3
3
|
import maya.mel as mel
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
def hook(
|
|
6
|
+
def hook(virus_cleaner):
|
|
7
7
|
for plugin in ["Turtle.mll", "mayatomr.mll"]:
|
|
8
8
|
if cmds.pluginInfo(plugin, q=1, loaded=1):
|
|
9
9
|
cmds.unloadPlugin(plugin, f=1)
|
|
10
|
-
turtle_nodes = [
|
|
10
|
+
turtle_nodes = [
|
|
11
|
+
"TurtleRenderOptions",
|
|
12
|
+
"TurtleUIOptions",
|
|
13
|
+
"TurtleBakeLayerManager",
|
|
14
|
+
"TurtleDefaultBakeLayer",
|
|
15
|
+
]
|
|
11
16
|
for node in turtle_nodes:
|
|
12
17
|
if cmds.objExists(node):
|
|
13
18
|
cmds.lockNode(node, lock=1)
|
{maya_umbrella-0.3.0 → maya_umbrella-0.4.1}/maya_umbrella/hooks/delete_unknown_plugin_node.py
RENAMED
|
@@ -2,28 +2,29 @@
|
|
|
2
2
|
import maya.cmds as cmds
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
def hook(
|
|
5
|
+
def hook(virus_cleaner):
|
|
6
6
|
unknown_node = cmds.ls(type="unknown")
|
|
7
7
|
unknown_plugin = cmds.unknownPlugin(query=True, l=True)
|
|
8
8
|
if unknown_node:
|
|
9
9
|
for nodeObj in unknown_node:
|
|
10
10
|
if cmds.objExists(nodeObj):
|
|
11
11
|
if cmds.referenceQuery(nodeObj, isNodeReferenced=True):
|
|
12
|
-
logger.warning("Node from reference, skip.
|
|
12
|
+
virus_cleaner.logger.warning("Node from reference, skip. {}".format(nodeObj))
|
|
13
13
|
continue
|
|
14
14
|
if cmds.lockNode(nodeObj, query=True)[0]:
|
|
15
15
|
try:
|
|
16
16
|
cmds.lockNode(nodeObj, lock=False)
|
|
17
|
-
except Exception
|
|
18
|
-
logger.warning(
|
|
17
|
+
except Exception:
|
|
18
|
+
virus_cleaner.logger.warning(
|
|
19
|
+
"The node is locked and cannot be unlocked. skip {}".format(nodeObj))
|
|
19
20
|
continue
|
|
20
21
|
try:
|
|
21
22
|
cmds.delete(nodeObj)
|
|
22
|
-
logger.warning("Delete node
|
|
23
|
-
except Exception
|
|
23
|
+
virus_cleaner.logger.warning("Delete node: {}".format(nodeObj))
|
|
24
|
+
except Exception:
|
|
24
25
|
pass
|
|
25
26
|
|
|
26
27
|
if unknown_plugin:
|
|
27
28
|
for plugObj in unknown_plugin:
|
|
28
29
|
cmds.unknownPlugin(plugObj, remove=True)
|
|
29
|
-
logger.warning("Delete plug-in
|
|
30
|
+
virus_cleaner.logger.warning("Delete plug-in: {}".format(plugObj))
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
import maya.cmds as cmds
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
def hook(
|
|
5
|
+
def hook(virus_cleaner):
|
|
6
6
|
for model_panel in cmds.getPanel(typ="modelPanel"):
|
|
7
|
-
|
|
8
7
|
# Get callback of the model editor
|
|
9
8
|
callback = cmds.modelEditor(model_panel, query=True, editorChanged=True)
|
|
10
9
|
|
|
11
10
|
# If the callback is the erroneous `CgAbBlastPanelOptChangeCallback`
|
|
12
11
|
if callback == "CgAbBlastPanelOptChangeCallback":
|
|
13
|
-
|
|
12
|
+
virus_cleaner.logger.info("Remove the callbacks from the editor")
|
|
14
13
|
cmds.modelEditor(model_panel, edit=True, editorChanged="")
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Import third-party modules
|
|
2
|
+
import maya.cmds as cmds
|
|
3
|
+
import maya.mel as mel
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def hook(virus_cleaner):
|
|
7
|
+
try:
|
|
8
|
+
mel.eval("global proc onModelChange3dc(string $a){}")
|
|
9
|
+
except Exception:
|
|
10
|
+
pass
|
|
11
|
+
try:
|
|
12
|
+
cmds.delete("fixCgAbBlastPanelOptChangeCallback")
|
|
13
|
+
except Exception:
|
|
14
|
+
pass
|
|
15
|
+
try:
|
|
16
|
+
script = "global proc CgAbBlastPanelOptChangeCallback(string $i){}"
|
|
17
|
+
mel.eval(script)
|
|
18
|
+
except Exception:
|
|
19
|
+
pass
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Import built-in modules
|
|
2
|
+
import logging.handlers
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
# Import local modules
|
|
6
|
+
from maya_umbrella.constants import LOG_FORMAT
|
|
7
|
+
from maya_umbrella.constants import LOG_MAX_BYTES
|
|
8
|
+
from maya_umbrella.constants import PACKAGE_NAME
|
|
9
|
+
from maya_umbrella.filesystem import get_log_file
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def setup_logger(logger=None, logfile=None, log_level=None):
|
|
13
|
+
"""Set up the logger with the specified log file and log level.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
logger (logging.Logger, optional): The logger to set up. Defaults to the logger for the package.
|
|
17
|
+
logfile (str, optional): The path to the log file. Defaults to the log file returned by `get_log_file()`.
|
|
18
|
+
log_level (int, optional): The log level. Defaults to `logging.INFO`.
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
logging.Logger: The set up logger.
|
|
22
|
+
"""
|
|
23
|
+
logger = logger or logging.getLogger(PACKAGE_NAME)
|
|
24
|
+
log_level = log_level or os.getenv("MAYA_UMBRELLA_LOG_LEVEL", "INFO")
|
|
25
|
+
logger.setLevel(log_level)
|
|
26
|
+
logfile = logfile or get_log_file()
|
|
27
|
+
if not len(logger.handlers):
|
|
28
|
+
filehandler = logging.handlers.RotatingFileHandler(
|
|
29
|
+
logfile,
|
|
30
|
+
mode="a",
|
|
31
|
+
backupCount=7,
|
|
32
|
+
delay=True,
|
|
33
|
+
maxBytes=LOG_MAX_BYTES,
|
|
34
|
+
)
|
|
35
|
+
filehandler.setFormatter(logging.Formatter(LOG_FORMAT))
|
|
36
|
+
logger.addHandler(filehandler)
|
|
37
|
+
return logger
|