DaVinci MCP Professional v2.1.1
A modern, professional Model Context Protocol server for DaVinci Resolve integration
Loading...
Searching...
No Matches
platform.py
Go to the documentation of this file.
1"""
2Platform detection and environment setup utilities.
3"""
4
5import os
6import sys
7import platform
8from typing import Dict, Optional
9from pathlib import Path
10
11
12def get_platform() -> str:
13 """Get the current platform name."""
14 system = platform.system().lower()
15 if system == "darwin":
16 return "macos"
17 elif system == "windows":
18 return "windows"
19 elif system == "linux":
20 return "linux"
21 else:
22 return system
23
24
25def get_resolve_paths() -> Dict[str, Path]:
26 """Get platform-specific paths for DaVinci Resolve scripting API."""
27 current_platform = get_platform()
28
29 if current_platform == "macos":
30 api_path = Path("/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting")
31 lib_path = Path("/Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/fusionscript.so")
32
33 elif current_platform == "windows":
34 program_data = Path(os.environ.get("PROGRAMDATA", "C:\\ProgramData"))
35 program_files = Path(os.environ.get("PROGRAMFILES", "C:\\Program Files"))
36
37 api_path = program_data / "Blackmagic Design" / "DaVinci Resolve" / "Support" / "Developer" / "Scripting"
38 lib_path = program_files / "Blackmagic Design" / "DaVinci Resolve" / "fusionscript.dll"
39
40 elif current_platform == "linux":
41 # Default Linux paths - may need adjustment based on installation
42 api_path = Path("/opt/resolve/Developer/Scripting")
43 lib_path = Path("/opt/resolve/libs/fusionscript.so")
44
45 else:
46 raise RuntimeError(f"Unsupported platform: {current_platform}")
47
48 return {
49 "api_path": api_path,
50 "lib_path": lib_path,
51 "modules_path": api_path / "Modules",
52 }
53
54
56 """Set up environment variables for DaVinci Resolve scripting."""
57 try:
58 paths = get_resolve_paths()
59
60 # Set environment variables
61 os.environ["RESOLVE_SCRIPT_API"] = str(paths["api_path"])
62 os.environ["RESOLVE_SCRIPT_LIB"] = str(paths["lib_path"])
63
64 # Add modules path to Python path if not already there
65 modules_path_str = str(paths["modules_path"])
66 if modules_path_str not in sys.path:
67 sys.path.insert(0, modules_path_str)
68
69 return True
70 except Exception:
71 return False
72
73
74def check_resolve_installation() -> Dict[str, bool]:
75 """Check if DaVinci Resolve is properly installed."""
76 paths = get_resolve_paths()
77
78 return {
79 "api_path_exists": paths["api_path"].exists(),
80 "lib_path_exists": paths["lib_path"].exists(),
81 "modules_path_exists": paths["modules_path"].exists(),
82 }
83
84
86 """Check if DaVinci Resolve is currently running."""
87 current_platform = get_platform()
88
89 try:
90 if current_platform == "windows":
91 import subprocess
92 result = subprocess.run(
93 ["tasklist", "/FI", "IMAGENAME eq Resolve.exe"],
94 capture_output=True,
95 text=True,
96 check=False
97 )
98 return "Resolve.exe" in result.stdout
99
100 elif current_platform in ["macos", "linux"]:
101 import subprocess
102 result = subprocess.run(
103 ["pgrep", "-f", "DaVinci Resolve"],
104 capture_output=True,
105 check=False
106 )
107 return result.returncode == 0
108
109 return False
110 except Exception:
111 return False
Dict[str, Path] get_resolve_paths()
Definition platform.py:25
Dict[str, bool] check_resolve_installation()
Definition platform.py:74