Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Say where access was denied on the launcher's failure card, and keep the details in its report

Bowen Xue2f737c526084
diff --git a/freevideo_engine/comfy_launcher_runtime.py b/freevideo_engine/comfy_launcher_runtime.py
index c78a85a..7feb804 100644
--- a/freevideo_engine/comfy_launcher_runtime.py
+++ b/freevideo_engine/comfy_launcher_runtime.py
@@ -1026,7 +1026,7 @@ class Controller:
# A link check in flight finishes first, so it cannot overwrite this task's state.
poll.join()
self.cancelled.clear()
- self.state = dict(self.state, status='running', action=operation, error=None, exception=None, task={}, overall={},
+ self.state = dict(self.state, status='running', action=operation, error=None, exception=None, denied=None, task={}, overall={},
model_groups=[] if operation == 'inspect' else self.state.get('model_groups', []))
if operation in ('connect', 'launch', 'configure_access'):
self.sections = [('open', 1)]
@@ -1041,8 +1041,13 @@ class Controller:
# A remembered URL alone cannot prove the local page is usable.
opened = bool(self.state.get('url')) and server_info(self.state['url'].split('/?')[0])['status'] == 'freevideo'
status = 'open' if opened else 'failed'
+ from .denied_access import describe
+ # Inspection fails before a selection exists, so the requested folder stands in.
+ engine = (self.selection or {}).get('engine') or (
+ args[0].get('engine') if args and isinstance(args[0], dict) else None)
+ roots = [('INSTALL', engine)] if engine else []
self.state = dict(self.state, status='cancelled' if self.cancelled.is_set() else status,
- error=str(error), exception=exception_details(error))
+ error=str(error), exception=exception_details(error), denied=describe(error, roots))
self.thread = threading.Thread(target=work, daemon=True)
self.thread.start()
diff --git a/freevideo_engine/denied_access.py b/freevideo_engine/denied_access.py
new file mode 100644
index 0000000..890e75b
--- /dev/null
+++ b/freevideo_engine/denied_access.py
@@ -0,0 +1,158 @@
+"""Where an access-denied failure happened, worded without a user name or a private folder.
+
+Windows reports "[WinError 5] Access is denied" for many different operations, and when the call
+names no file the message says nothing else. The launcher keeps this description next to the
+message: the folder as the drive letter plus the part inside FreeVideo's own folders, and the last
+FreeVideo functions that were running.
+"""
+import errno
+import os
+import re
+import tempfile
+
+DENIED_ERRNO = (errno.EACCES, errno.EPERM)
+# Folders that stay in the description when the denied path is inside one of them.
+OWN_NAME = re.compile(r'^(?:freevideo|fv$)', re.I)
+# The installation folder the launcher creates by default; it is kept even where no installation root is known.
+ENGINE_NAME = re.compile(r'^freevideo-engine$', re.I)
+# Folders named below FreeVideo's own folder: user-named files (models, inputs, outputs) sit deeper.
+INSIDE = 2
+STEPS = 3
+SOCKET_DENIED = 10013
+
+
+def is_denied(error):
+ if getattr(error, 'winerror', None) == SOCKET_DENIED:
+ # A port that Windows reserved is not a refused file or folder.
+ return False
+ return isinstance(error, PermissionError) or (isinstance(error, OSError) and (
+ getattr(error, 'winerror', None) == 5 or error.errno in DENIED_ERRNO))
+
+
+def _segments(path):
+ path = str(path)
+ if path.startswith('\\\\?\\') and not path.startswith('\\\\?\\UNC\\'):
+ path = path[4:]
+ drive = ''
+ match = re.match(r'([A-Za-z]):(?:[\\/]|$)', path)
+ if match:
+ drive, path = match.group(1).upper() + ':', path[match.end():]
+ return drive, [part for part in re.split(r'[\\/]+', path) if part]
+
+
+def _under(parts, root):
+ return len(parts) >= len(root) and all(a.casefold() == b.casefold() for a, b in zip(parts, root))
+
+
+def _inside(parts):
+ """The first folders below one of FreeVideo's own, then an ellipsis where more follow."""
+ return parts[:INSIDE] + (['…'] if len(parts) > INSIDE else [])
+
+
+def default_roots():
+ """The user's own folders, which are named by a placeholder and never spelled out."""
+ roots = []
+ for label, value in (('HOME', os.path.expanduser('~')), ('TEMP', tempfile.gettempdir()),
+ ('PROGRAMDATA', os.environ.get('ProgramData', ''))):
+ if value and value != '~':
+ roots.append((label, value))
+ return roots
+
+
+def location(path, roots=()):
+ """A path as "[D:] INSTALL\\launcher": the drive letter and a placeholder in place of every folder that
+ is not FreeVideo's own. The installation root is the engine folder itself, so no folder above it is named,
+ and nothing below it deeper than INSIDE folders. The text does not look like a path to the launcher's redaction."""
+ path = str(path or '')
+ if not path:
+ return ''
+ if path.startswith(('\\\\', '//')) and (not path.startswith('\\\\?\\') or path.upper().startswith('\\\\?\\UNC\\')):
+ return '[network share]'
+ drive, parts = _segments(path)
+ best = None
+ for label, root in list(roots) + default_roots():
+ root_drive, root_parts = _segments(root)
+ # A root with no folder (a whole drive) would make every path on it FreeVideo's own.
+ if root_parts and root_drive == drive and _under(parts, root_parts) and (
+ best is None or len(root_parts) > len(best[1])):
+ best = (label, root_parts)
+ prefix = '[%s] ' % drive if drive else ''
+ if best is None:
+ # A name outside FreeVideo's folders may be a person, a project or a video, so none is kept,
+ # except the engine folder the launcher creates by default.
+ own = next((index for index, part in enumerate(parts) if ENGINE_NAME.match(part)), None)
+ if own is not None:
+ return prefix + '\\'.join(['…', parts[own]] + _inside(parts[own + 1:]))
+ return prefix + '…' if parts else prefix.strip()
+ label, root_parts = best
+ rest = parts[len(root_parts):]
+ if label in ('HOME', 'TEMP'):
+ # Only what FreeVideo created below the user's folder is named.
+ own = next((index for index, part in enumerate(rest) if OWN_NAME.match(part)), None)
+ rest = ['…'] + ([rest[own]] + _inside(rest[own + 1:]) if own is not None else [])
+ elif label == 'INSTALL':
+ rest = _inside(rest)
+ return prefix + '\\'.join([label] + rest)
+
+
+def _chain(error):
+ seen = set()
+ while isinstance(error, BaseException) and id(error) not in seen:
+ seen.add(id(error))
+ yield error
+ error = error.__cause__ or (None if error.__suppress_context__ else error.__context__)
+
+
+def steps(error):
+ """The innermost FreeVideo functions of the traceback, newest first: "processes.popen:211"."""
+ rows, tb = [], error.__traceback__
+ while tb is not None:
+ module = str(tb.tb_frame.f_globals.get('__name__') or '')
+ if module == 'freevideo_engine' or module.startswith('freevideo_engine.'):
+ rows.append('%s.%s:%d' % (module.partition('.')[2] or module, tb.tb_frame.f_code.co_name, tb.tb_lineno))
+ tb = tb.tb_next
+ return rows[-STEPS:][::-1]
+
+
+def describe(error, roots=()):
+ """The access-denied error in this exception chain as plain data, or None when there is none."""
+ for item in _chain(error):
+ if is_denied(item):
+ winerror = getattr(item, 'winerror', None)
+ result = dict(code=winerror or item.errno, windows=bool(winerror), steps=steps(item))
+ paths = [location(name, roots) for name in (item.filename, item.filename2) if name]
+ if paths:
+ result['path'] = ' → '.join(paths)
+ return result
+ return None
+
+
+def text(info, zh=False):
+ """The line kept in the report: what was denied, where, and the FreeVideo steps that were running."""
+ if not info:
+ return ''
+ label = (('Windows 错误 %s' if zh else 'Windows error %s') if info.get('windows') else ('错误 %s' if zh else 'error %s'))
+ code = ('(%s)' if zh else ' (%s)') % (label % info['code']) if info.get('code') else ''
+ if info.get('path'):
+ head = ('访问被拒绝%s:%s' if zh else 'Access denied%s: %s') % (code, info['path'])
+ else:
+ head = ('访问被拒绝%s,系统没有说明是哪个文件或文件夹' if zh else
+ 'Access denied%s; the system did not name a file or folder') % code
+ if info.get('steps'):
+ head += (';步骤:' if zh else '; steps: ') + ' < '.join(info['steps'])
+ return head
+
+
+PLACEHOLDERS = (('INSTALL', '[安装目录]', '[installation folder]'), ('HOME', '[用户文件夹]', '[user folder]'),
+ ('TEMP', '[临时文件夹]', '[temp folder]'), ('[network share]', '[网络共享]', '[network share]'))
+
+
+def card_text(info, zh=False):
+ """The line on the failure card: only where access was denied, with readable names for the placeholders."""
+ value = (info or {}).get('path')
+ if not value:
+ return ''
+ for token, chinese, english in PLACEHOLDERS:
+ value = re.sub(r'(?<![\w\[])%s(?![\w\]])' % re.escape(token) if token[0] != '[' else re.escape(token),
+ chinese if zh else english, value)
+ return ('被拒绝的位置:' if zh else 'Denied location: ') + value
diff --git a/freevideo_engine/failure_details.py b/freevideo_engine/failure_details.py
index bad53f5..9f44db3 100644
--- a/freevideo_engine/failure_details.py
+++ b/freevideo_engine/failure_details.py
@@ -777,7 +777,7 @@ def _launcher_failure(value, *, zh=False, other_disk=False, disk_name='', can_re
('Smart App Control in Windows blocked these files. Search Windows for "Smart App Control", or open Windows Security → App & browser control → Smart App Control settings.',
'Windows 的“智能应用控制”拦截了这些文件。在 Windows 中搜索“智能应用控制”,或打开“Windows 安全中心 → 应用和浏览器控制 → 智能应用控制设置”。')),
(r'PermissionError|Access is denied|Permission denied|WinError 5\b|os error 5\b', 'permission',
- ('This folder is not writable', '无法写入这个目录'),
+ ('Access denied', '访问被拒绝'),
('Choose an installation folder you can write to, then retry.', '选择有写入权限的安装目录后重试。')),
# A worker's own check of the cuDNN files it loaded (runtime_libraries).
(r"FreeVideo's PyTorch library files do not match", 'runtime-libraries',
diff --git a/freevideo_engine/launcher_session.py b/freevideo_engine/launcher_session.py
index 865d8b3..d2aa157 100644
--- a/freevideo_engine/launcher_session.py
+++ b/freevideo_engine/launcher_session.py
@@ -1140,7 +1140,15 @@ class Session:
shortcut = row.get('shortcut') or {}
if shortcut.get('status') == 'failed':
errors.append(shortcut.get('error_zh' if self.language.startswith('zh') else 'error') or shortcut.get('error', ''))
- return plain_text('\n'.join(str(e) for e in errors if e))
+ message = plain_text('\n'.join(str(e) for e in errors if e))
+ if row.get('error') and row.get('denied'):
+ from .denied_access import text
+ from .failure_details import launcher_failure
+ # Windows words many refusals alike and often names no file; where it happened travels with the message.
+ # Only a permission failure takes the line: the other cards read the first lines of the message.
+ if launcher_failure(message)['kind'] == 'permission':
+ message = plain_text(text(row['denied'], self.language.startswith('zh')) + '\n' + message)
+ return message
def diagnostic_error(self):
"""Full retained causes, including alias failures shown in storage settings."""
@@ -2297,6 +2305,12 @@ class Session:
if line.startswith(MISMATCH_PATH + ': ') and line[len(MISMATCH_PATH) + 2:]:
failure['path'] = line[len(MISMATCH_PATH) + 2:]
break
+ if failure.get('kind') == 'permission' and row.get('error') and row.get('denied'):
+ from .denied_access import card_text
+ # The card shows the detail instead of the action, so the action goes under the location.
+ location = card_text(row['denied'], zh)
+ if location:
+ failure = dict(failure, detail=location + '\n' + failure['action'], action='')
reasons = self.importer.state.get('write_reasons') or []
if (self.importer.state.get('status') == 'error' and reasons
and self.error == self.importer.state.get('error') and failure.get('kind') != 'runtime-alias'):