-
Notifications
You must be signed in to change notification settings - Fork 4
/
installEditor.py
executable file
·53 lines (41 loc) · 1.36 KB
/
installEditor.py
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
#!/usr/bin/env python
import argparse
import os
import platform
import sys
from pathlib import Path
maya_locations = {
"Linux": "/maya/",
"Darwin": "/Library/Preferences/Autodesk/maya",
"Windows": "\\Documents\\maya\\",
}
def install_module(location, os):
print(f"installing to {location}")
# first write the module file
current_dir = Path.cwd()
# if the module folder doesn't exist make it
module_dir = Path(location + "//modules")
module_path = location + "//modules/MayaEditor.mod"
## change to \\ for windows (easier then messing with Path objects)
if os == "Windows":
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):
mloc = f"{Path.home()}{maya_locations.get(op_sys)}"
if not os.path.isdir(mloc):
raise
return mloc
if __name__ == "__main__":
try:
op_sys=platform.system()
m_loc = check_maya_installed(op_sys)
except:
print("Error can't find maya install")
sys.exit(-1)
install_module(m_loc, op_sys)