-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstallEditor.py
More file actions
executable file
·77 lines (62 loc) · 1.99 KB
/
Copy pathinstallEditor.py
File metadata and controls
executable file
·77 lines (62 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python
"""Install the MayaEditor module into the Maya modules directory."""
import os
import platform
import sys
from pathlib import Path
MayaLocations = {
"Linux": "/maya/",
"Darwin": "/Library/Preferences/Autodesk/maya",
"Windows": "\\Documents\\maya\\",
}
def install_module(location: str, os_name: str) -> None:
"""Write the MayaEditor.mod file into the Maya modules directory.
Parameters
----------
location : str
Path to the Maya preferences directory for the current OS.
os_name : str
Operating system name (``Windows``, ``Darwin``, ``Linux``).
"""
print(f"installing to {location}")
current_dir = Path.cwd()
if os_name == "Windows":
module_dir = Path(location + "\\modules")
module_path = location + "modules\\MayaEditor.mod"
else:
module_dir = Path(location + "//modules")
module_path = location + "//modules/MayaEditor.mod"
module_dir.mkdir(exist_ok=True)
if not Path(module_path).is_file():
print("writing module file")
with open(module_path, "w") as file:
file.write(f"+ MayaEditor 1.0 {current_dir}\n")
file.write("MAYA_PLUG_IN_PATH +:= plug-ins\n")
def check_maya_installed(op_sys: str) -> str:
"""Check that a Maya preferences directory exists for the current OS.
Parameters
----------
op_sys : str
The current operating system name.
Returns
-------
str
The Maya preferences directory path.
Raises
------
SystemExit
If the Maya install directory is not found.
"""
mloc = f"{Path.home()}{MayaLocations.get(op_sys)}"
if not os.path.isdir(mloc):
print("Error can't find maya install")
sys.exit(-1)
return mloc
if __name__ == "__main__":
try:
op_sys = platform.system()
m_loc = check_maya_installed(op_sys)
except Exception:
print("Error can't find maya install")
sys.exit(-1)
install_module(m_loc, op_sys)