maya-umbrella 0.5.0__tar.gz → 0.6.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.

Files changed (33) hide show
  1. {maya_umbrella-0.5.0 → maya_umbrella-0.6.1}/PKG-INFO +66 -4
  2. {maya_umbrella-0.5.0 → maya_umbrella-0.6.1}/README.md +65 -3
  3. maya_umbrella-0.6.1/maya_umbrella/__init__.py +9 -0
  4. maya_umbrella-0.6.1/maya_umbrella/__version__.py +1 -0
  5. maya_umbrella-0.6.1/maya_umbrella/cleaner.py +111 -0
  6. maya_umbrella-0.6.1/maya_umbrella/collector.py +411 -0
  7. {maya_umbrella-0.5.0 → maya_umbrella-0.6.1}/maya_umbrella/constants.py +4 -0
  8. maya_umbrella-0.6.1/maya_umbrella/defender.py +161 -0
  9. {maya_umbrella-0.5.0 → maya_umbrella-0.6.1}/maya_umbrella/filesystem.py +90 -3
  10. maya_umbrella-0.6.1/maya_umbrella/i18n.py +76 -0
  11. maya_umbrella-0.6.1/maya_umbrella/locales/en_US.json +19 -0
  12. maya_umbrella-0.6.1/maya_umbrella/locales/zh_CN.json +19 -0
  13. maya_umbrella-0.6.1/maya_umbrella/maya_funs.py +136 -0
  14. maya_umbrella-0.6.1/maya_umbrella/scanner.py +106 -0
  15. maya_umbrella-0.6.1/maya_umbrella/signatures.py +10 -0
  16. maya_umbrella-0.6.1/maya_umbrella/vaccine.py +37 -0
  17. {maya_umbrella-0.5.0 → maya_umbrella-0.6.1}/maya_umbrella/vaccines/vaccine1.py +2 -1
  18. {maya_umbrella-0.5.0 → maya_umbrella-0.6.1}/maya_umbrella/vaccines/vaccine2.py +14 -14
  19. {maya_umbrella-0.5.0 → maya_umbrella-0.6.1}/maya_umbrella/vaccines/vaccine3.py +24 -16
  20. {maya_umbrella-0.5.0 → maya_umbrella-0.6.1}/pyproject.toml +5 -3
  21. maya_umbrella-0.5.0/maya_umbrella/__init__.py +0 -5
  22. maya_umbrella-0.5.0/maya_umbrella/__version__.py +0 -1
  23. maya_umbrella-0.5.0/maya_umbrella/core.py +0 -120
  24. maya_umbrella-0.5.0/maya_umbrella/maya_funs.py +0 -36
  25. maya_umbrella-0.5.0/maya_umbrella/vaccine.py +0 -253
  26. {maya_umbrella-0.5.0 → maya_umbrella-0.6.1}/LICENSE +0 -0
  27. {maya_umbrella-0.5.0 → maya_umbrella-0.6.1}/maya_umbrella/hooks/__init__.py +0 -0
  28. {maya_umbrella-0.5.0 → maya_umbrella-0.6.1}/maya_umbrella/hooks/delete_turtle.py +0 -0
  29. {maya_umbrella-0.5.0 → maya_umbrella-0.6.1}/maya_umbrella/hooks/delete_unknown_plugin_node.py +0 -0
  30. {maya_umbrella-0.5.0 → maya_umbrella-0.6.1}/maya_umbrella/hooks/fix_model_panel.py +0 -0
  31. {maya_umbrella-0.5.0 → maya_umbrella-0.6.1}/maya_umbrella/hooks/fix_on_model_change_3dc.py +0 -0
  32. {maya_umbrella-0.5.0 → maya_umbrella-0.6.1}/maya_umbrella/log.py +0 -0
  33. {maya_umbrella-0.5.0 → maya_umbrella-0.6.1}/maya_umbrella/vaccines/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maya_umbrella
3
- Version: 0.5.0
3
+ Version: 0.6.1
4
4
  Summary: Check and fix maya virus.
5
5
  Home-page: https://github.com/loonghao/maya_umbrella
6
6
  License: MIT
@@ -43,18 +43,32 @@ Description-Content-Type: text/markdown
43
43
  [![maya-2018](https://img.shields.io/badge/maya-2018-green)](https://img.shields.io/badge/maya-2018-green)
44
44
 
45
45
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
46
- [![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-)
46
+ [![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-)
47
47
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
48
48
 
49
- This tool is designed to provide a robust solution for identifying and resolving any potential viruses within Autodesk Maya.
49
+ This tool is designed to provide a robust solution for identifying and resolving any potential viruses within Autodesk
50
+ Maya.
50
51
  It ensures a secure and seamless user experience by proactively scanning for threats and effectively neutralizing them.
51
52
 
52
53
  It can be provided as an API for seamless integration into your existing pipeline.
53
54
 
55
+ # 安装
56
+ maya_umbrella是以标准pipy包去发布的,所以我们可以通过pip install去安装
57
+ ```shell
58
+ your/maya-root/mayapy -m pip install maya-umbrella
59
+ ```
60
+ 更新版本
61
+ ```shell
62
+ your/maya-root/mayapy -m pip install maya-umbrella --upgrade
63
+ ```
64
+ 卸载
65
+ ```shell
66
+ your/maya-root/mayapy -m pip uninstall maya-umbrella
67
+ ```
54
68
 
55
69
  # 开发环境设置
56
70
 
57
- Set up the development environment using a virtual environment,
71
+ Set up the development environment using a virtual environment,
58
72
  and it is recommended to use Python 3.8 or higher versions.
59
73
 
60
74
  通过虚拟环境去设置开发环境, 推荐python-3.8以上的版本
@@ -95,6 +109,14 @@ manual_test_in_maya.start()
95
109
  nox -s ruff_check
96
110
  ```
97
111
 
112
+ # 生成安装包
113
+
114
+ 执行下面的命令可以在<repo>/.zip下面创建zip,参数 `--version` 当前工具的版本号
115
+
116
+ ```shell
117
+ nox -s make-zip -- --version 0.5.0
118
+ ```
119
+
98
120
  # 环境变量
99
121
 
100
122
  我们可以通过下列环境变量去修改maya_umbrella的一些设置,方便有pipeline的公司可以更好的集成
@@ -115,6 +137,45 @@ MAYA_UMBRELLA_LOG_NAME
115
137
 
116
138
  ```shell
117
139
  MAYA_UMBRELLA_LOG_LEVEL
140
+ ```
141
+ 修改杀毒后文件的备份文件夹名称, 默认是`_virus`
142
+ 比如:
143
+ 你文件路径是 `c:/your/path/file.ma`
144
+ 那么备份文件路径是 `c:/your/path/_maya_umbrella/file.ma`
145
+ ```shell
146
+ MAYA_UMBRELLA_BACKUP_FOLDER_NAME
147
+ ```
148
+ 默认的显示语言,包含日志打印输出等,默认是根据你当前maya的界面语言来设置的,当然我们也可以通过下面的环境变量去设置
149
+ ```shell
150
+ MAYA_UMBRELLA_LANG
151
+ ```
152
+
153
+ 忽略保存到备份文件夹,*请注意,如果你不清楚这个会导致的后果请不要轻易修改*,默认批量杀毒后会把源文件自动备份到当前文件的备份文件夹.
154
+ ```shell
155
+ MAYA_UMBRELLA_IGNORE_BACKUP
156
+ ```
157
+ 如果忽略请设置为
158
+ ```shell
159
+ SET MAYA_UMBRELLA_IGNORE_BACKUP=true
160
+ ```
161
+
162
+ # API
163
+ 获取当前场景没有被修复的病毒文件
164
+
165
+ ```python
166
+ from maya_umbrella import MayaVirusDefender
167
+
168
+ api = MayaVirusDefender()
169
+ print(api.get_unfixed_references())
170
+ ```
171
+
172
+ 批量修复文件
173
+ ```python
174
+ from maya_umbrella import MayaVirusScanner
175
+
176
+ api = MayaVirusScanner()
177
+ print(api.scan_files_from_pattern("your/path/*.m[ab]"))
178
+
118
179
  ```
119
180
 
120
181
  ## Contributors ✨
@@ -131,6 +192,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
131
192
  <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>
132
193
  <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>
133
194
  <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>
195
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/uncleschen"><img src="https://avatars.githubusercontent.com/u/37014389?v=4?s=100" width="100px;" alt="Unclechen"/><br /><sub><b>Unclechen</b></sub></a><br /><a href="https://github.com/loonghao/maya_umbrella/commits?author=uncleschen" title="Tests">⚠️</a></td>
134
196
  </tr>
135
197
  </tbody>
136
198
  </table>
@@ -18,18 +18,32 @@
18
18
  [![maya-2018](https://img.shields.io/badge/maya-2018-green)](https://img.shields.io/badge/maya-2018-green)
19
19
 
20
20
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
21
- [![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-)
21
+ [![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-)
22
22
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
23
23
 
24
- This tool is designed to provide a robust solution for identifying and resolving any potential viruses within Autodesk Maya.
24
+ This tool is designed to provide a robust solution for identifying and resolving any potential viruses within Autodesk
25
+ Maya.
25
26
  It ensures a secure and seamless user experience by proactively scanning for threats and effectively neutralizing them.
26
27
 
27
28
  It can be provided as an API for seamless integration into your existing pipeline.
28
29
 
30
+ # 安装
31
+ maya_umbrella是以标准pipy包去发布的,所以我们可以通过pip install去安装
32
+ ```shell
33
+ your/maya-root/mayapy -m pip install maya-umbrella
34
+ ```
35
+ 更新版本
36
+ ```shell
37
+ your/maya-root/mayapy -m pip install maya-umbrella --upgrade
38
+ ```
39
+ 卸载
40
+ ```shell
41
+ your/maya-root/mayapy -m pip uninstall maya-umbrella
42
+ ```
29
43
 
30
44
  # 开发环境设置
31
45
 
32
- Set up the development environment using a virtual environment,
46
+ Set up the development environment using a virtual environment,
33
47
  and it is recommended to use Python 3.8 or higher versions.
34
48
 
35
49
  通过虚拟环境去设置开发环境, 推荐python-3.8以上的版本
@@ -70,6 +84,14 @@ manual_test_in_maya.start()
70
84
  nox -s ruff_check
71
85
  ```
72
86
 
87
+ # 生成安装包
88
+
89
+ 执行下面的命令可以在<repo>/.zip下面创建zip,参数 `--version` 当前工具的版本号
90
+
91
+ ```shell
92
+ nox -s make-zip -- --version 0.5.0
93
+ ```
94
+
73
95
  # 环境变量
74
96
 
75
97
  我们可以通过下列环境变量去修改maya_umbrella的一些设置,方便有pipeline的公司可以更好的集成
@@ -90,6 +112,45 @@ MAYA_UMBRELLA_LOG_NAME
90
112
 
91
113
  ```shell
92
114
  MAYA_UMBRELLA_LOG_LEVEL
115
+ ```
116
+ 修改杀毒后文件的备份文件夹名称, 默认是`_virus`
117
+ 比如:
118
+ 你文件路径是 `c:/your/path/file.ma`
119
+ 那么备份文件路径是 `c:/your/path/_maya_umbrella/file.ma`
120
+ ```shell
121
+ MAYA_UMBRELLA_BACKUP_FOLDER_NAME
122
+ ```
123
+ 默认的显示语言,包含日志打印输出等,默认是根据你当前maya的界面语言来设置的,当然我们也可以通过下面的环境变量去设置
124
+ ```shell
125
+ MAYA_UMBRELLA_LANG
126
+ ```
127
+
128
+ 忽略保存到备份文件夹,*请注意,如果你不清楚这个会导致的后果请不要轻易修改*,默认批量杀毒后会把源文件自动备份到当前文件的备份文件夹.
129
+ ```shell
130
+ MAYA_UMBRELLA_IGNORE_BACKUP
131
+ ```
132
+ 如果忽略请设置为
133
+ ```shell
134
+ SET MAYA_UMBRELLA_IGNORE_BACKUP=true
135
+ ```
136
+
137
+ # API
138
+ 获取当前场景没有被修复的病毒文件
139
+
140
+ ```python
141
+ from maya_umbrella import MayaVirusDefender
142
+
143
+ api = MayaVirusDefender()
144
+ print(api.get_unfixed_references())
145
+ ```
146
+
147
+ 批量修复文件
148
+ ```python
149
+ from maya_umbrella import MayaVirusScanner
150
+
151
+ api = MayaVirusScanner()
152
+ print(api.scan_files_from_pattern("your/path/*.m[ab]"))
153
+
93
154
  ```
94
155
 
95
156
  ## Contributors ✨
@@ -106,6 +167,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
106
167
  <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>
107
168
  <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>
108
169
  <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>
170
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/uncleschen"><img src="https://avatars.githubusercontent.com/u/37014389?v=4?s=100" width="100px;" alt="Unclechen"/><br /><sub><b>Unclechen</b></sub></a><br /><a href="https://github.com/loonghao/maya_umbrella/commits?author=uncleschen" title="Tests">⚠️</a></td>
109
171
  </tr>
110
172
  </tbody>
111
173
  </table>
@@ -0,0 +1,9 @@
1
+ # Import local modules
2
+ from maya_umbrella.cleaner import MayaVirusCleaner
3
+ from maya_umbrella.collector import MayaVirusCollector
4
+ from maya_umbrella.defender import MayaVirusDefender
5
+ from maya_umbrella.defender import context_defender
6
+ from maya_umbrella.scanner import MayaVirusScanner
7
+
8
+
9
+ __all__ = ["MayaVirusDefender", "MayaVirusCleaner", "MayaVirusCollector", "MayaVirusScanner", "context_defender"]
@@ -0,0 +1 @@
1
+ __version__ = "0.6.1"
@@ -0,0 +1,111 @@
1
+ # Import built-in modules
2
+ import glob
3
+ import logging
4
+ import os
5
+ import re
6
+
7
+ # Import local modules
8
+ from maya_umbrella.constants import FILE_VIRUS_SIGNATURES
9
+ from maya_umbrella.filesystem import remove_virus_file_by_signature
10
+ from maya_umbrella.filesystem import safe_remove_file
11
+ from maya_umbrella.filesystem import safe_rmtree
12
+ from maya_umbrella.i18n import Translator
13
+ from maya_umbrella.maya_funs import check_reference_node_exists
14
+ from maya_umbrella.maya_funs import cmds
15
+
16
+
17
+ class MayaVirusCleaner(object):
18
+ """A class to clean Maya virus files.
19
+
20
+ Attributes:
21
+ logger (Logger): Logger object for logging purposes.
22
+ translator (Translator): Translator object for translation purposes.
23
+ collector (MayaVirusCollector): MayaVirusCollector object for collecting issues.
24
+ """
25
+ def __init__(self, collector, logger=None):
26
+ """Initialize the MayaVirusCleaner.
27
+
28
+ Args:
29
+ collector (MayaVirusCollector): MayaVirusCollector object for collecting issues.
30
+ logger (Logger, optional): Logger object for logging purposes. Defaults to None, which creates a new logger.
31
+ """
32
+ self.logger = logger or logging.getLogger(__name__)
33
+ self.translator = Translator()
34
+ self.collector = collector
35
+
36
+ def callback_remove_rename_temp_files(self, *args, **kwargs):
37
+ """Remove temporary files in the local script path."""
38
+ self.logger.debug("Removing temporary files in %s", self.collector.local_script_path)
39
+ for temp_file in glob.glob(os.path.join(self.collector.local_script_path, "._*")):
40
+ safe_remove_file(temp_file)
41
+
42
+ def fix_script_jobs(self):
43
+ """Fix infected script jobs."""
44
+ for script_job in self.collector.infected_script_jobs:
45
+ script_num = int(re.findall(r"^(\d+):", script_job)[0])
46
+ self.logger.debug("Kill script job %s", script_job)
47
+ cmds.scriptJob(kill=script_num, force=True)
48
+ self.collector.remove_infected_script_job(script_job)
49
+
50
+ def fix_malicious_files(self):
51
+ """Fix malicious files."""
52
+ for file_ in self.collector.malicious_files:
53
+ if os.path.exists(file_):
54
+ if os.path.isfile(file_):
55
+ self.logger.debug(self.translator.translate("remove_file", name=file_))
56
+ safe_remove_file(file_)
57
+ self.collector.remove_malicious_file(file_)
58
+ else:
59
+ self.logger.debug(self.translator.translate("remove_path", name=file_))
60
+ safe_rmtree(file_)
61
+ self.collector.remove_malicious_file(file_)
62
+
63
+ def fix_infected_nodes(self):
64
+ """Fix infected nodes."""
65
+ for node in self.collector.infected_nodes:
66
+ is_referenced = check_reference_node_exists(node)
67
+ if is_referenced:
68
+ try:
69
+ self.logger.debug(self.translator.translate("fix_infected_reference_nodes", name=node))
70
+ cmds.setAttr("{node}.before".format(node=node), "", type="string")
71
+ cmds.setAttr("{node}.after".format(node=node), "", type="string")
72
+ cmds.setAttr("{node}.scriptType".format(node=node), 0)
73
+ self.collector.remove_infected_node(node)
74
+ except Exception as e:
75
+ self.logger.debug(e)
76
+ else:
77
+ try:
78
+ cmds.lockNode(node, lock=False)
79
+ except ValueError:
80
+ pass
81
+ try:
82
+ self.logger.debug(self.translator.translate("fix_infected_nodes", name=node))
83
+ cmds.delete(node)
84
+ except ValueError:
85
+ pass
86
+ self.collector.remove_infected_node(node)
87
+
88
+ def setup_default_callbacks(self):
89
+ """Set up default callbacks."""
90
+ self.collector.add_maya_initialized_callback(self.callback_remove_rename_temp_files)
91
+ self.collector.add_maya_exiting_callback(self.callback_remove_rename_temp_files)
92
+
93
+ def fix_infected_files(self):
94
+ """Fix infected files."""
95
+ for file_path in self.collector.infected_files:
96
+ self.logger.info(self.translator.translate("fix_infected_files", name=file_path))
97
+ remove_virus_file_by_signature(file_path, FILE_VIRUS_SIGNATURES)
98
+ self.collector.remove_infected_file(file_path)
99
+
100
+ def fix(self):
101
+ """Fix all issues related to the Maya virus."""
102
+ if self.collector.have_issues:
103
+ maya_file = cmds.file(query=True, sceneName=True, shortName=True) or "empty/scene"
104
+ self.logger.info(self.translator.translate("start_fix_issues", name=maya_file))
105
+ self.fix_malicious_files()
106
+ self.fix_infected_files()
107
+ self.fix_infected_nodes()
108
+ self.fix_script_jobs()
109
+ for func in self.collector.get_additionally_fix_funcs():
110
+ func()
111
+ self.logger.info(self.translator.translate("finish_fix_issues", name=maya_file))