159 lines
4.5 KiB
Python
Executable file
159 lines
4.5 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
"""
|
|
Maya Version Detection Script
|
|
Detects Maya installation path, version, and key library locations.
|
|
"""
|
|
|
|
import os
|
|
import re
|
|
import json
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
|
|
def find_maya_installations():
|
|
"""Scan common Maya installation locations."""
|
|
installations = []
|
|
|
|
search_paths = [
|
|
"/usr/autodesk/",
|
|
"/opt/Autodesk/",
|
|
"/usr/local/autodesk/",
|
|
]
|
|
|
|
for base_path in search_paths:
|
|
if not os.path.exists(base_path):
|
|
continue
|
|
|
|
for item in os.listdir(base_path):
|
|
item_path = os.path.join(base_path, item)
|
|
if re.match(r'maya20\d{2}', item, re.IGNORECASE):
|
|
installations.append({
|
|
'path': item_path,
|
|
'version': extract_version(item),
|
|
'type': 'maya'
|
|
})
|
|
|
|
return installations
|
|
|
|
|
|
def extract_version(directory_name):
|
|
"""Extract version number from directory name."""
|
|
match = re.search(r'(\d{4})', directory_name)
|
|
if match:
|
|
return match.group(1)
|
|
return "unknown"
|
|
|
|
|
|
def find_license_libraries(maya_path):
|
|
"""Find licensing-related libraries in Maya installation."""
|
|
libraries = {}
|
|
|
|
lib_path = os.path.join(maya_path, "lib")
|
|
if os.path.exists(lib_path):
|
|
for lib in os.listdir(lib_path):
|
|
if "AdskLicensing" in lib or "adsk" in lib.lower():
|
|
libraries[lib] = os.path.join(lib_path, lib)
|
|
|
|
adsk_licensing = "/opt/Autodesk/AdskLicensing/Current/AdskLicensingAgent/lib"
|
|
if os.path.exists(adsk_licensing):
|
|
for lib in os.listdir(adsk_licensing):
|
|
if "adlm" in lib.lower():
|
|
full_path = os.path.join(adsk_licensing, lib)
|
|
if "libadlmint" in lib:
|
|
libraries[f"adlmint ({lib})"] = full_path
|
|
|
|
return libraries
|
|
|
|
|
|
def get_binary_info(maya_path):
|
|
"""Get information about Maya binary."""
|
|
bin_path = os.path.join(maya_path, "bin", "maya")
|
|
info = {}
|
|
|
|
if os.path.exists(bin_path):
|
|
info['binary_path'] = bin_path
|
|
info['binary_exists'] = True
|
|
|
|
try:
|
|
stat_info = os.stat(bin_path)
|
|
info['binary_size'] = stat_info.st_size
|
|
info['binary_permissions'] = oct(stat_info.st_mode)[-3:]
|
|
except:
|
|
pass
|
|
|
|
return info
|
|
|
|
|
|
def detect_maya():
|
|
"""Main detection function."""
|
|
print("Scanning for Maya installations...")
|
|
|
|
installations = find_maya_installations()
|
|
|
|
if not installations:
|
|
print("No Maya installations found.")
|
|
return {
|
|
"found": False,
|
|
"installations": []
|
|
}
|
|
|
|
results = {
|
|
"found": True,
|
|
"scan_timestamp": subprocess.getoutput("date '+%Y-%m-%d %H:%M:%S'"),
|
|
"installations": []
|
|
}
|
|
|
|
for install in installations:
|
|
print(f"Found Maya {install['version']} at {install['path']}")
|
|
|
|
install_info = {
|
|
"version": install['version'],
|
|
"path": install['path'],
|
|
"libraries": find_license_libraries(install['path']),
|
|
"binary": get_binary_info(install['path']),
|
|
"target_files": []
|
|
}
|
|
|
|
lib_path = os.path.join(install['path'], "lib")
|
|
if os.path.exists(lib_path):
|
|
for lib in os.listdir(lib_path):
|
|
if "libAdskLicensingSDK" in lib:
|
|
install_info["target_files"].append({
|
|
"name": lib,
|
|
"path": os.path.join(lib_path, lib),
|
|
"type": "licensing_sdk"
|
|
})
|
|
|
|
flexnet_path = "/opt/flexnetserver"
|
|
if os.path.exists(flexnet_path):
|
|
install_info["flexnet"] = {
|
|
"path": flexnet_path,
|
|
"exists": True
|
|
}
|
|
|
|
results["installations"].append(install_info)
|
|
print(f" - Found {len(install_info['libraries'])} licensing libraries")
|
|
print(f" - Target files: {len(install_info['target_files'])}")
|
|
|
|
return results
|
|
|
|
|
|
def main():
|
|
"""Entry point."""
|
|
results = detect_maya()
|
|
|
|
print("\n" + "="*60)
|
|
print("DETECTION RESULTS (JSON):")
|
|
print("="*60)
|
|
print(json.dumps(results, indent=2))
|
|
|
|
output_path = "/home/mithral/maya-crack/config/detected_maya.json"
|
|
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
|
with open(output_path, 'w') as f:
|
|
json.dump(results, f, indent=2)
|
|
print(f"\nResults saved to: {output_path}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|