davinci-resolve-mcp 2.97.5 → 2.97.7
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.
- package/CHANGELOG.md +103 -0
- package/README.md +1 -1
- package/README.zh-CN.md +2 -2
- package/docs/SKILL.md +5 -0
- package/install.py +37 -1
- package/package.json +1 -1
- package/src/granular/common.py +1 -1
- package/src/server.py +106 -21
- package/src/utils/resolve_runtime.py +21 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,109 @@
|
|
|
2
2
|
|
|
3
3
|
Release history for the DaVinci Resolve MCP Server. The latest release is summarized in the root README; older entries live here to keep the README focused.
|
|
4
4
|
|
|
5
|
+
## What's New in v2.97.7
|
|
6
|
+
|
|
7
|
+
**`grab_and_export` deleted files it never created.** Reported in
|
|
8
|
+
[#151](https://github.com/samuelgursky/davinci-resolve-mcp/issues/151).
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **The cleanup step removed a directory diff, not the export.** It listed the
|
|
13
|
+
caller's folder before the export and again after, and treated the difference
|
|
14
|
+
as "what this call produced" — so anything that appeared in that window was
|
|
15
|
+
attributed to the call, inlined into the response, and deleted: a background
|
|
16
|
+
render, a file copy, a cloud sync, or a second `grab_and_export`. It then
|
|
17
|
+
finished with `os.rmdir(folder_path)`, removing a directory the caller had
|
|
18
|
+
chosen and this server had not created.
|
|
19
|
+
|
|
20
|
+
`_resolve_safe_dir` made the overlap concrete rather than theoretical. Every
|
|
21
|
+
sandbox/temp path is redirected to one shared `~/Documents/resolve-stills`,
|
|
22
|
+
which is also the folder the documented `/tmp/...` examples land in, so two
|
|
23
|
+
calls aimed at different temp folders arrived in the same place and each swept
|
|
24
|
+
up the other's output.
|
|
25
|
+
|
|
26
|
+
The export now goes to a private staging directory created inside
|
|
27
|
+
`folder_path` for that one call, so what it produced is known by construction
|
|
28
|
+
instead of inferred. Cleanup removes that directory and nothing else;
|
|
29
|
+
`folder_path` is removed only when this call created it and left it empty. A
|
|
30
|
+
folder the caller already had is theirs, empty or not. With `cleanup: false`
|
|
31
|
+
the files move up into `folder_path` under a non-colliding name rather than
|
|
32
|
+
overwriting a still already sitting there — Resolve numbers stills per export,
|
|
33
|
+
so a second call collides with the first by default.
|
|
34
|
+
|
|
35
|
+
Deletion is now confined to one helper that refuses any path it did not name,
|
|
36
|
+
which is the property that was missing: the old code path could be handed the
|
|
37
|
+
caller's folder and delete its contents.
|
|
38
|
+
|
|
39
|
+
The inlining half matters too. A file that was never ours was read into the
|
|
40
|
+
response, so an unrelated document sitting in the export folder could reach an
|
|
41
|
+
assistant's context. Only staged files are read now.
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
|
|
45
|
+
- `tests.test_gallery_still_export_cleanup` runs the action against a real temp
|
|
46
|
+
filesystem with a fake album that writes the way Resolve does, because the
|
|
47
|
+
defect was in what the filesystem looked like afterwards, not in any return
|
|
48
|
+
value: a bystander file written *during* the export must survive and must not
|
|
49
|
+
appear inlined; a pre-existing folder must not be removed; a folder the call
|
|
50
|
+
created must still be cleaned up; `cleanup: false` must not overwrite; and no
|
|
51
|
+
staging directory may survive any exit path, including the two early error
|
|
52
|
+
returns. All fail on 2.97.6.
|
|
53
|
+
|
|
54
|
+
## What's New in v2.97.6
|
|
55
|
+
|
|
56
|
+
**On Windows the server could not see the Resolve it was driving.** Reported in
|
|
57
|
+
[#150](https://github.com/samuelgursky/davinci-resolve-mcp/issues/150) with the
|
|
58
|
+
root cause traced, the fix proposed, and a case table — all of it correct.
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
|
|
62
|
+
- **`runtime_mode` reported `running: false, instances: 0` on every stock
|
|
63
|
+
Windows install.** WMIC wraps a command line in double quotes when the
|
|
64
|
+
executable path contains spaces, which the default install path always does
|
|
65
|
+
(`"C:\Program Files\Blackmagic Design\DaVinci Resolve\Resolve.exe"`). The
|
|
66
|
+
line therefore *ends* with `"`, and `_is_resolve_command()` required it to end
|
|
67
|
+
with `Resolve.exe`. The trailing-flag stripper above the test did not help: it
|
|
68
|
+
removes ` -flag` tokens and leaves the closing quote as the final character.
|
|
69
|
+
A leading quote is now read for what it is — the executable is what sits
|
|
70
|
+
inside the first quoted span, and everything after the closing quote is
|
|
71
|
+
arguments. That also tightens rejection: `"…\cmd.exe" /c start … Resolve.exe`
|
|
72
|
+
is a launcher, not an instance.
|
|
73
|
+
|
|
74
|
+
The reading was the visible half. The consequential half is that
|
|
75
|
+
`get_resolve()` asks this same question before auto-launching, precisely so a
|
|
76
|
+
failed connect to a live Resolve does not open a second application — the
|
|
77
|
+
guard whose comment records being "reported three times before it was
|
|
78
|
+
traced". On Windows its input was a permanent `False`, so the path it exists
|
|
79
|
+
to block was open: connect fails (modal dialog, mid-launch, scripting toggled
|
|
80
|
+
off) → "nothing is running" → launch a second Resolve. `_not_connected_error()`
|
|
81
|
+
reads the same signal, so a Windows user whose Resolve *was* running got the
|
|
82
|
+
"not running, auto-launch failed, check your Studio install" text instead of
|
|
83
|
+
the preference or bridge fix that actually applied. `headless` was
|
|
84
|
+
unreachable too — it is only computed once something is found running, so
|
|
85
|
+
`-nogui` instances were indistinguishable on Windows.
|
|
86
|
+
|
|
87
|
+
- **A successful install ended in a traceback under a redirected stdout.** The
|
|
88
|
+
installer prints box-drawing and check-mark glyphs. A Windows console carries
|
|
89
|
+
them, but redirecting stdout falls back to the locale code page — cp1252 by
|
|
90
|
+
default — and `print(f" {'─' * 50}")` in the summary raised
|
|
91
|
+
`UnicodeEncodeError` after every client had already been configured, so a
|
|
92
|
+
working run looked like a failed one
|
|
93
|
+
(`npx davinci-resolve-mcp setup --clients manual 2>&1 | tail`). Streams that
|
|
94
|
+
cannot encode those glyphs are now reconfigured to UTF-8 with
|
|
95
|
+
`errors="replace"`; a console that can already carry them is left alone
|
|
96
|
+
rather than re-encoded underneath the user.
|
|
97
|
+
|
|
98
|
+
### Added
|
|
99
|
+
|
|
100
|
+
- `tests.test_headless_runtime` covers the quoted Windows command line —
|
|
101
|
+
bare, trailing-whitespace (what WMIC actually prints), and `-nogui` — plus
|
|
102
|
+
the quoted-launcher line that must still be rejected, so the fix cannot
|
|
103
|
+
become a substring test by another route. `tests.test_cdl_and_install_config`
|
|
104
|
+
gains `ConsoleEncodingTests`, including a child interpreter run with
|
|
105
|
+
`PYTHONIOENCODING=cp1252` and a piped stdout: the exact shape of the reported
|
|
106
|
+
failure. Both suites fail on the pre-fix code.
|
|
107
|
+
|
|
5
108
|
## What's New in v2.97.5
|
|
6
109
|
|
|
7
110
|
**`npm ci` was failing outright, and nothing in the release path noticed.**
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
English | [简体中文](README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
[](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
|
|
6
6
|
[](https://www.npmjs.com/package/davinci-resolve-mcp)
|
|
7
7
|
[](docs/reference/api-coverage.md)
|
|
8
8
|
[-blue.svg)](#server-modes)
|
package/README.zh-CN.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | 简体中文
|
|
4
4
|
|
|
5
|
-
[](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
|
|
6
6
|
[](https://www.npmjs.com/package/davinci-resolve-mcp)
|
|
7
7
|
[](docs/reference/api-coverage.md)
|
|
8
8
|
[-blue.svg)](#服务器模式)
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
[](https://www.python.org/downloads/)
|
|
13
13
|
[](https://opensource.org/licenses/MIT)
|
|
14
14
|
|
|
15
|
-
> 本翻译对应 v2.97.
|
|
15
|
+
> 本翻译对应 v2.97.7 版 README。如与英文原版有出入,以 [英文原版](README.md) 为准。
|
|
16
16
|
|
|
17
17
|
一个 Model Context Protocol (MCP) 服务器,让 AI 助手通过官方脚本 API 控制 DaVinci Resolve Studio(达芬奇)。它提供完整的 API 覆盖,外加带护栏的工作流助手,涵盖剪辑、媒体池整理、渲染设置、审阅标记、调色、Fusion、Fairlight、项目生命周期任务、扩展开发,以及不碰源媒体的媒体分析。
|
|
18
18
|
|
package/docs/SKILL.md
CHANGED
|
@@ -1637,6 +1637,11 @@ Key actions:
|
|
|
1637
1637
|
Returns `{files, format, folder, cleaned_up}` where each file entry includes
|
|
1638
1638
|
`data_base64` for image files and `data` (text) for `.drx` grade files.
|
|
1639
1639
|
`cleanup` defaults to `true` — files are deleted from disk after being inlined.
|
|
1640
|
+
Only files this call produced are removed: the export goes to a private
|
|
1641
|
+
staging directory inside `folder_path`, so anything else written there
|
|
1642
|
+
meanwhile is untouched, and `folder_path` itself is removed only if the call
|
|
1643
|
+
created it and left it empty. With `cleanup: false` the files are moved up
|
|
1644
|
+
into `folder_path` without overwriting anything already there.
|
|
1640
1645
|
Requires Color page with Gallery panel visible.
|
|
1641
1646
|
- `delete_stills(still_indices)`
|
|
1642
1647
|
|
package/install.py
CHANGED
|
@@ -37,7 +37,7 @@ from src.utils.update_check import (
|
|
|
37
37
|
|
|
38
38
|
# ─── Version ──────────────────────────────────────────────────────────────────
|
|
39
39
|
|
|
40
|
-
VERSION = "2.97.
|
|
40
|
+
VERSION = "2.97.7"
|
|
41
41
|
# Only hard floor: mcp[cli] requires Python 3.10+. There is no upper bound —
|
|
42
42
|
# Resolve's scripting bridge loads into newer interpreters on recent builds
|
|
43
43
|
# (Python 3.14 verified against Resolve Studio 20.3.2). Older Resolve builds
|
|
@@ -46,6 +46,42 @@ VERSION = "2.97.5"
|
|
|
46
46
|
SUPPORTED_PYTHON_MIN = (3, 10)
|
|
47
47
|
PYTHON_ABI_RISK_MIN = (3, 13)
|
|
48
48
|
|
|
49
|
+
# ─── Console encoding ─────────────────────────────────────────────────────────
|
|
50
|
+
# This installer prints box-drawing and check-mark glyphs. On Windows a console
|
|
51
|
+
# stdout carries them fine, but a *redirected* stdout falls back to the locale
|
|
52
|
+
# code page — cp1252 on a default Windows install — and the first '─' raises
|
|
53
|
+
# UnicodeEncodeError. It fires at the summary, after every client is already
|
|
54
|
+
# configured, so a successful install ends in a traceback and reads as a failed
|
|
55
|
+
# run. Reported in #150 against
|
|
56
|
+
# `npx davinci-resolve-mcp setup --clients manual 2>&1 | tail`.
|
|
57
|
+
#
|
|
58
|
+
# Only streams that cannot already carry the glyphs are touched, so a correctly
|
|
59
|
+
# configured console keeps its own encoding. 'replace' is belt-and-braces: no
|
|
60
|
+
# output path is worth a traceback.
|
|
61
|
+
|
|
62
|
+
_GLYPH_PROBE = "─→✓⊘•"
|
|
63
|
+
|
|
64
|
+
def _ensure_glyph_capable_stdio():
|
|
65
|
+
for stream in (sys.stdout, sys.stderr):
|
|
66
|
+
reconfigure = getattr(stream, "reconfigure", None)
|
|
67
|
+
encoding = getattr(stream, "encoding", None)
|
|
68
|
+
if reconfigure is None or not encoding:
|
|
69
|
+
continue
|
|
70
|
+
try:
|
|
71
|
+
_GLYPH_PROBE.encode(encoding)
|
|
72
|
+
continue
|
|
73
|
+
except (LookupError, UnicodeEncodeError):
|
|
74
|
+
pass
|
|
75
|
+
try:
|
|
76
|
+
reconfigure(encoding="utf-8", errors="replace")
|
|
77
|
+
except Exception:
|
|
78
|
+
try:
|
|
79
|
+
reconfigure(errors="replace")
|
|
80
|
+
except Exception:
|
|
81
|
+
pass
|
|
82
|
+
|
|
83
|
+
_ensure_glyph_capable_stdio()
|
|
84
|
+
|
|
49
85
|
# ─── Colors (disabled on Windows cmd without ANSI support) ────────────────────
|
|
50
86
|
|
|
51
87
|
def _supports_color():
|
package/package.json
CHANGED
package/src/granular/common.py
CHANGED
|
@@ -87,7 +87,7 @@ if not logging.getLogger().handlers:
|
|
|
87
87
|
handlers=[logging.StreamHandler()],
|
|
88
88
|
)
|
|
89
89
|
|
|
90
|
-
VERSION = "2.97.
|
|
90
|
+
VERSION = "2.97.7"
|
|
91
91
|
logger = logging.getLogger("davinci-resolve-mcp")
|
|
92
92
|
logger.info(f"Starting DaVinci Resolve MCP Server v{VERSION}")
|
|
93
93
|
logger.info(f"Detected platform: {get_platform()}")
|
package/src/server.py
CHANGED
|
@@ -11,7 +11,7 @@ Usage:
|
|
|
11
11
|
python src/server.py --full # Start the 353-tool granular server instead
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
-
VERSION = "2.97.
|
|
14
|
+
VERSION = "2.97.7"
|
|
15
15
|
|
|
16
16
|
import base64
|
|
17
17
|
import os
|
|
@@ -1289,6 +1289,50 @@ def _resolve_safe_dir(path):
|
|
|
1289
1289
|
return os.path.join(os.path.expanduser("~"), "Documents", "resolve-stills")
|
|
1290
1290
|
return path
|
|
1291
1291
|
|
|
1292
|
+
#: Prefix of the private per-call directory `gallery_stills(grab_and_export)`
|
|
1293
|
+
#: exports into. Named so that the only thing this server ever deletes is a
|
|
1294
|
+
#: directory it created itself, in this call, for this purpose. Deliberately not
|
|
1295
|
+
#: a dot-directory: Resolve's still exporter is particular about where it will
|
|
1296
|
+
#: write (see `_resolve_safe_dir`, which exists because it fails silently into
|
|
1297
|
+
#: sandbox paths), and an ordinary subdirectory is the least exotic thing to
|
|
1298
|
+
#: hand it.
|
|
1299
|
+
STILL_STAGING_PREFIX = "resolve-mcp-still-"
|
|
1300
|
+
|
|
1301
|
+
|
|
1302
|
+
def _discard_still_staging(staging: str) -> None:
|
|
1303
|
+
"""Remove a still-export staging directory, and refuse anything else.
|
|
1304
|
+
|
|
1305
|
+
The name check is not ceremony. The step it replaces removed whatever the
|
|
1306
|
+
before/after diff of the caller's folder happened to show, and then removed
|
|
1307
|
+
the folder itself — so this helper is the one place a delete can happen, and
|
|
1308
|
+
it declines any path that is not a directory this server named. See #151.
|
|
1309
|
+
"""
|
|
1310
|
+
if not staging or not os.path.basename(staging).startswith(STILL_STAGING_PREFIX):
|
|
1311
|
+
return
|
|
1312
|
+
if not os.path.isdir(staging):
|
|
1313
|
+
return
|
|
1314
|
+
shutil.rmtree(staging, ignore_errors=True)
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
def _unused_path(path: str) -> str:
|
|
1318
|
+
"""`path`, or the first `name_1.ext`, `name_2.ext`… that does not exist yet.
|
|
1319
|
+
|
|
1320
|
+
Used when moving exported stills into the caller's folder: a still named
|
|
1321
|
+
like one already sitting there is a collision to step around, not a file to
|
|
1322
|
+
overwrite.
|
|
1323
|
+
"""
|
|
1324
|
+
import uuid
|
|
1325
|
+
|
|
1326
|
+
if not os.path.exists(path):
|
|
1327
|
+
return path
|
|
1328
|
+
stem, ext = os.path.splitext(path)
|
|
1329
|
+
for n in range(1, 1000):
|
|
1330
|
+
candidate = f"{stem}_{n}{ext}"
|
|
1331
|
+
if not os.path.exists(candidate):
|
|
1332
|
+
return candidate
|
|
1333
|
+
return f"{stem}_{uuid.uuid4().hex}{ext}"
|
|
1334
|
+
|
|
1335
|
+
|
|
1292
1336
|
# Error envelope categories (agentic-flow improvements A1/D1) — see the retryable
|
|
1293
1337
|
# default policy. Lock these names; downstream agents and tests route on them.
|
|
1294
1338
|
ERROR_CATEGORIES = (
|
|
@@ -25253,7 +25297,12 @@ def gallery_stills(action: str, params: Optional[Dict[str, Any]] = None) -> Dict
|
|
|
25253
25297
|
keeping the live GalleryStill reference (more reliable than separate grab + export).
|
|
25254
25298
|
Requires Color page. Automatically produces a companion .drx grade file.
|
|
25255
25299
|
File data is inlined in the response (DRX as text, images as base64).
|
|
25256
|
-
cleanup (default true) deletes exported files
|
|
25300
|
+
cleanup (default true) deletes the exported files after inlining. Only files
|
|
25301
|
+
this call produced are ever removed: the export goes to a private staging
|
|
25302
|
+
directory inside folder_path, so anything else written there meanwhile is
|
|
25303
|
+
untouched, and folder_path itself is removed only if this call created it
|
|
25304
|
+
and left it empty. With cleanup false the files are moved up into
|
|
25305
|
+
folder_path without overwriting anything already there.
|
|
25257
25306
|
"""
|
|
25258
25307
|
p = _params(params)
|
|
25259
25308
|
_, proj, err = _check()
|
|
@@ -25302,31 +25351,53 @@ def gallery_stills(action: str, params: Optional[Dict[str, Any]] = None) -> Dict
|
|
|
25302
25351
|
return _err("No stills to export")
|
|
25303
25352
|
return {"success": bool(album.ExportStills(stills, p["folder_path"], p.get("prefix", "still"), p.get("format", "dpx")))}
|
|
25304
25353
|
elif action == "grab_and_export":
|
|
25305
|
-
import time, os
|
|
25354
|
+
import time, os, shutil, uuid
|
|
25306
25355
|
folder_path = p.get("folder_path")
|
|
25307
25356
|
if not folder_path:
|
|
25308
25357
|
return _err("folder_path is required")
|
|
25309
25358
|
prefix = p.get("prefix", "still")
|
|
25310
25359
|
fmt = p.get("format", "dpx")
|
|
25311
25360
|
delete_after = p.get("delete_after", True)
|
|
25361
|
+
cleanup = p.get("cleanup", True)
|
|
25312
25362
|
# Redirect sandbox/temp paths that Resolve can't access
|
|
25313
25363
|
folder_path = _resolve_safe_dir(folder_path)
|
|
25364
|
+
folder_pre_existed = os.path.isdir(folder_path)
|
|
25314
25365
|
os.makedirs(folder_path, exist_ok=True)
|
|
25315
|
-
#
|
|
25316
|
-
|
|
25366
|
+
# Export into a private staging directory instead of straight into
|
|
25367
|
+
# folder_path, so "what this call produced" is known by construction.
|
|
25368
|
+
#
|
|
25369
|
+
# It used to be a before/after diff of folder_path, which is not the
|
|
25370
|
+
# same question: anything that appeared in that folder during the export
|
|
25371
|
+
# window — a background render, a copy, a cloud sync, a second
|
|
25372
|
+
# grab_and_export — was attributed to this call, inlined into the
|
|
25373
|
+
# response, and then deleted by the cleanup step. `_resolve_safe_dir`
|
|
25374
|
+
# makes that concrete rather than theoretical: every sandbox/temp path
|
|
25375
|
+
# is redirected to the one shared ~/Documents/resolve-stills folder, so
|
|
25376
|
+
# two overlapping calls each swept up the other's output. The old
|
|
25377
|
+
# cleanup also finished with `os.rmdir(folder_path)`, removing a
|
|
25378
|
+
# directory the caller had chosen and this server did not create.
|
|
25379
|
+
# Reported in #151.
|
|
25380
|
+
#
|
|
25381
|
+
# A staging directory is inside folder_path on purpose: same volume and
|
|
25382
|
+
# same permissions, so if Resolve can export to folder_path it can
|
|
25383
|
+
# export here, and the finished files move up with a rename.
|
|
25384
|
+
staging = os.path.join(folder_path, f"{STILL_STAGING_PREFIX}{uuid.uuid4().hex}")
|
|
25385
|
+
os.makedirs(staging)
|
|
25317
25386
|
# Grab still — requires Color page with a clip under the playhead
|
|
25318
25387
|
_, tl, err2 = _get_tl()
|
|
25319
25388
|
if err2:
|
|
25389
|
+
_discard_still_staging(staging)
|
|
25320
25390
|
return err2
|
|
25321
25391
|
still = tl.GrabStill()
|
|
25322
25392
|
if not still:
|
|
25393
|
+
_discard_still_staging(staging)
|
|
25323
25394
|
return _err("GrabStill failed — ensure Color page is active with a clip under the playhead")
|
|
25324
25395
|
time.sleep(0.5)
|
|
25325
25396
|
# Export using the live still reference with format fallback chain
|
|
25326
25397
|
export_ok = False
|
|
25327
25398
|
used_format = fmt
|
|
25328
25399
|
for try_fmt in [fmt, "tif", "dpx"]:
|
|
25329
|
-
result = album.ExportStills([still],
|
|
25400
|
+
result = album.ExportStills([still], staging, prefix, try_fmt)
|
|
25330
25401
|
if result:
|
|
25331
25402
|
export_ok = True
|
|
25332
25403
|
used_format = try_fmt
|
|
@@ -25336,15 +25407,19 @@ def gallery_stills(action: str, params: Optional[Dict[str, Any]] = None) -> Dict
|
|
|
25336
25407
|
if delete_after:
|
|
25337
25408
|
album.DeleteStills([still])
|
|
25338
25409
|
if not export_ok:
|
|
25410
|
+
_discard_still_staging(staging)
|
|
25339
25411
|
return _err("ExportStills failed — ensure the Gallery panel is open on the Color page (Workspace > Gallery)")
|
|
25340
25412
|
# Wait for filesystem
|
|
25341
25413
|
time.sleep(0.3)
|
|
25342
|
-
|
|
25343
|
-
|
|
25344
|
-
|
|
25414
|
+
try:
|
|
25415
|
+
exported = sorted(os.listdir(staging))
|
|
25416
|
+
except OSError:
|
|
25417
|
+
exported = []
|
|
25345
25418
|
file_details = []
|
|
25346
|
-
for f in
|
|
25347
|
-
fpath = os.path.join(
|
|
25419
|
+
for f in exported:
|
|
25420
|
+
fpath = os.path.join(staging, f)
|
|
25421
|
+
if not os.path.isfile(fpath):
|
|
25422
|
+
continue
|
|
25348
25423
|
entry = {"name": f, "path": fpath, "size": os.path.getsize(fpath)}
|
|
25349
25424
|
# Inline file data so cleanup can safely remove files
|
|
25350
25425
|
try:
|
|
@@ -25361,20 +25436,30 @@ def gallery_stills(action: str, params: Optional[Dict[str, Any]] = None) -> Dict
|
|
|
25361
25436
|
except OSError:
|
|
25362
25437
|
pass
|
|
25363
25438
|
file_details.append(entry)
|
|
25364
|
-
# Cleanup: remove exported files now that data is inlined (default: True)
|
|
25365
|
-
cleanup = p.get("cleanup", True)
|
|
25366
25439
|
if cleanup:
|
|
25367
|
-
|
|
25440
|
+
# Only the staging directory is removed, and only ever the files
|
|
25441
|
+
# this call put in it. folder_path is left alone unless this call
|
|
25442
|
+
# created it and it is still empty — a folder the caller already had
|
|
25443
|
+
# is theirs, empty or not.
|
|
25444
|
+
_discard_still_staging(staging)
|
|
25445
|
+
if not folder_pre_existed:
|
|
25368
25446
|
try:
|
|
25369
|
-
os.
|
|
25447
|
+
if os.path.isdir(folder_path) and not os.listdir(folder_path):
|
|
25448
|
+
os.rmdir(folder_path)
|
|
25370
25449
|
except OSError:
|
|
25371
25450
|
pass
|
|
25372
|
-
|
|
25373
|
-
|
|
25374
|
-
|
|
25375
|
-
|
|
25376
|
-
|
|
25377
|
-
|
|
25451
|
+
else:
|
|
25452
|
+
# Keeping the files: move them up into the folder the caller asked
|
|
25453
|
+
# for, never overwriting something already there.
|
|
25454
|
+
for entry in file_details:
|
|
25455
|
+
dest = _unused_path(os.path.join(folder_path, entry["name"]))
|
|
25456
|
+
try:
|
|
25457
|
+
shutil.move(entry["path"], dest)
|
|
25458
|
+
except OSError:
|
|
25459
|
+
continue
|
|
25460
|
+
entry["name"] = os.path.basename(dest)
|
|
25461
|
+
entry["path"] = dest
|
|
25462
|
+
_discard_still_staging(staging)
|
|
25378
25463
|
return {"files": file_details, "format": used_format, "folder": folder_path, "cleaned_up": cleanup}
|
|
25379
25464
|
elif action == "delete_stills":
|
|
25380
25465
|
stills = album.GetStills() or []
|
|
@@ -83,8 +83,13 @@ def _process_lines() -> Optional[List[str]]:
|
|
|
83
83
|
return None
|
|
84
84
|
|
|
85
85
|
|
|
86
|
+
def _matches_pattern(executable: str) -> bool:
|
|
87
|
+
"""Does this bare executable path name a Resolve application?"""
|
|
88
|
+
return any(executable.endswith(pattern) for pattern in RESOLVE_PROCESS_PATTERNS)
|
|
89
|
+
|
|
90
|
+
|
|
86
91
|
def _is_resolve_command(line: str) -> bool:
|
|
87
|
-
"""Is this command line a Resolve *executable*, not merely a mention of one?
|
|
92
|
+
r"""Is this command line a Resolve *executable*, not merely a mention of one?
|
|
88
93
|
|
|
89
94
|
A plain substring test matches any process whose command line happens to
|
|
90
95
|
contain the path — including a shell running a script that references it.
|
|
@@ -96,8 +101,22 @@ def _is_resolve_command(line: str) -> bool:
|
|
|
96
101
|
flags. So strip trailing flag tokens and require what remains to *end* with
|
|
97
102
|
the pattern. That survives the spaces in "DaVinci Resolve.app" (no splitting
|
|
98
103
|
on whitespace) while rejecting a path buried mid-command.
|
|
104
|
+
|
|
105
|
+
Windows quotes that path. WMIC prints the executable wrapped in double
|
|
106
|
+
quotes whenever it contains spaces, which the default install path always
|
|
107
|
+
does (`"C:\Program Files\Blackmagic Design\DaVinci Resolve\Resolve.exe"`),
|
|
108
|
+
so the line ends in `"` and `endswith("Resolve.exe")` was false on every
|
|
109
|
+
stock Windows machine — `runtime_mode` reported nothing running while the
|
|
110
|
+
same server was driving that very instance, and the second-instance guard
|
|
111
|
+
in `get_resolve()` lost its input. Reported in #150. A leading quote means
|
|
112
|
+
the executable is exactly what sits inside the first quoted span; anything
|
|
113
|
+
after the closing quote is arguments, and the flag loop never sees it.
|
|
99
114
|
"""
|
|
100
115
|
text = line.strip()
|
|
116
|
+
if text.startswith('"'):
|
|
117
|
+
close = text.find('"', 1)
|
|
118
|
+
if close > 1:
|
|
119
|
+
return _matches_pattern(text[1:close])
|
|
101
120
|
while True:
|
|
102
121
|
stripped = text.rstrip()
|
|
103
122
|
cut = stripped.rfind(" -")
|
|
@@ -109,7 +128,7 @@ def _is_resolve_command(line: str) -> bool:
|
|
|
109
128
|
if not candidate:
|
|
110
129
|
break
|
|
111
130
|
text = candidate
|
|
112
|
-
return
|
|
131
|
+
return _matches_pattern(text)
|
|
113
132
|
|
|
114
133
|
|
|
115
134
|
def resolve_processes() -> Optional[List[str]]:
|