style: apply ruff auto-fixes
This commit is contained in:
@@ -203,7 +203,6 @@ def run_platform_bootstrap(repo_root: Path) -> int:
|
||||
|
||||
def playwright_package_installed() -> bool:
|
||||
try:
|
||||
import playwright # type: ignore
|
||||
|
||||
return True
|
||||
except Exception:
|
||||
@@ -751,7 +750,7 @@ def main() -> int:
|
||||
user_bin = Path(os.environ.get("USERPROFILE", str(home))) / "bin"
|
||||
mm_bat = user_bin / "mm.bat"
|
||||
|
||||
print(f"Checking for shim files:")
|
||||
print("Checking for shim files:")
|
||||
print(f" mm.bat: {'✓' if mm_bat.exists() else '✗'} ({mm_bat})")
|
||||
print()
|
||||
|
||||
@@ -760,14 +759,14 @@ def main() -> int:
|
||||
if "REPO=" in bat_content or "ENTRY=" in bat_content:
|
||||
print(f" mm.bat content looks valid ({len(bat_content)} bytes)")
|
||||
else:
|
||||
print(f" ⚠️ mm.bat content may be corrupted")
|
||||
print(" ⚠️ mm.bat content may be corrupted")
|
||||
print()
|
||||
|
||||
# Check PATH
|
||||
path = os.environ.get("PATH", "")
|
||||
user_bin_str = str(user_bin)
|
||||
in_path = user_bin_str in path
|
||||
print(f"Checking PATH environment variable:")
|
||||
print("Checking PATH environment variable:")
|
||||
print(f" {user_bin_str} in current session PATH: {'✓' if in_path else '✗'}")
|
||||
|
||||
# Check registry
|
||||
@@ -792,7 +791,7 @@ def main() -> int:
|
||||
try:
|
||||
result = subprocess.run(["mm", "--help"], capture_output=True, text=True, timeout=5)
|
||||
if result.returncode == 0:
|
||||
print(f" ✓ 'mm --help' works!")
|
||||
print(" ✓ 'mm --help' works!")
|
||||
print(f" Output (first line): {result.stdout.split(chr(10))[0]}")
|
||||
else:
|
||||
print(f" ✗ 'mm --help' failed with exit code {result.returncode}")
|
||||
@@ -800,8 +799,8 @@ def main() -> int:
|
||||
print(f" Error: {result.stderr.strip()}")
|
||||
except FileNotFoundError:
|
||||
# mm not found via PATH, try calling the .ps1 directly
|
||||
print(f" ✗ 'mm' command not found in PATH")
|
||||
print(f" Shims exist but command is not accessible via PATH")
|
||||
print(" ✗ 'mm' command not found in PATH")
|
||||
print(" Shims exist but command is not accessible via PATH")
|
||||
print()
|
||||
print("Attempting to call shim directly...")
|
||||
try:
|
||||
@@ -810,23 +809,23 @@ def main() -> int:
|
||||
capture_output=True, text=True, timeout=5
|
||||
)
|
||||
if result.returncode == 0:
|
||||
print(f" ✓ Direct shim call works!")
|
||||
print(f" The shim files are valid and functional.")
|
||||
print(" ✓ Direct shim call works!")
|
||||
print(" The shim files are valid and functional.")
|
||||
print()
|
||||
print("⚠️ 'mm' is not in PATH, but the shims are working correctly.")
|
||||
print()
|
||||
print("Possible causes and fixes:")
|
||||
print(f" 1. Terminal needs restart: Close and reopen your terminal/PowerShell")
|
||||
print(f" 2. PATH reload: Run: $env:Path = [Environment]::GetEnvironmentVariable('PATH', 'User') + ';' + [Environment]::GetEnvironmentVariable('PATH', 'Machine')")
|
||||
print(" 1. Terminal needs restart: Close and reopen your terminal/PowerShell")
|
||||
print(" 2. PATH reload: Run: $env:Path = [Environment]::GetEnvironmentVariable('PATH', 'User') + ';' + [Environment]::GetEnvironmentVariable('PATH', 'Machine')")
|
||||
print(f" 3. Manual PATH: Add {user_bin} to your system PATH manually")
|
||||
else:
|
||||
print(f" ✗ Direct shim call failed")
|
||||
print(" ✗ Direct shim call failed")
|
||||
if result.stderr:
|
||||
print(f" Error: {result.stderr.strip()}")
|
||||
except Exception as e:
|
||||
print(f" ✗ Could not test direct shim: {e}")
|
||||
except subprocess.TimeoutExpired:
|
||||
print(f" ✗ 'mm' command timed out")
|
||||
print(" ✗ 'mm' command timed out")
|
||||
except Exception as e:
|
||||
print(f" ✗ Error testing 'mm': {e}")
|
||||
else:
|
||||
@@ -835,7 +834,7 @@ def main() -> int:
|
||||
locations = [home / ".local" / "bin" / "mm", Path("/usr/local/bin/mm"), Path("/usr/bin/mm")]
|
||||
found_shims = [p for p in locations if p.exists()]
|
||||
|
||||
print(f"Checking for shim files:")
|
||||
print("Checking for shim files:")
|
||||
for p in locations:
|
||||
if p.exists():
|
||||
print(f" mm: ✓ ({p})")
|
||||
@@ -844,23 +843,23 @@ def main() -> int:
|
||||
print(f" mm: ✗ ({p})")
|
||||
|
||||
if not found_shims:
|
||||
print(f" mm: ✗ (No shim found in standard locations)")
|
||||
print(" mm: ✗ (No shim found in standard locations)")
|
||||
print()
|
||||
|
||||
path = os.environ.get("PATH", "")
|
||||
|
||||
# Find which 'mm' is actually being run
|
||||
actual_mm = shutil.which("mm")
|
||||
print(f"Checking PATH environment variable:")
|
||||
print("Checking PATH environment variable:")
|
||||
if actual_mm:
|
||||
print(f" 'mm' resolved to: {actual_mm}")
|
||||
# Check if it's in a directory on the PATH
|
||||
if any(str(Path(actual_mm).parent) in p for p in path.split(os.pathsep)):
|
||||
print(f" Command is accessible via current session PATH: ✓")
|
||||
print(" Command is accessible via current session PATH: ✓")
|
||||
else:
|
||||
print(f" Command is found but directory may not be in current PATH: ⚠️")
|
||||
print(" Command is found but directory may not be in current PATH: ⚠️")
|
||||
else:
|
||||
print(f" 'mm' not found in current session PATH: ✗")
|
||||
print(" 'mm' not found in current session PATH: ✗")
|
||||
print()
|
||||
|
||||
# Test if mm command works
|
||||
@@ -868,14 +867,14 @@ def main() -> int:
|
||||
try:
|
||||
result = subprocess.run(["mm", "--help"], capture_output=True, text=True, timeout=5)
|
||||
if result.returncode == 0:
|
||||
print(f" ✓ 'mm --help' works!")
|
||||
print(" ✓ 'mm --help' works!")
|
||||
print(f" Output (first line): {result.stdout.split(chr(10))[0]}")
|
||||
else:
|
||||
print(f" ✗ 'mm --help' failed with exit code {result.returncode}")
|
||||
if result.stderr:
|
||||
print(f" Error: {result.stderr.strip()}")
|
||||
except FileNotFoundError:
|
||||
print(f" ✗ 'mm' command not found in PATH")
|
||||
print(" ✗ 'mm' command not found in PATH")
|
||||
except Exception as e:
|
||||
print(f" ✗ Error testing 'mm': {e}")
|
||||
|
||||
@@ -1002,7 +1001,7 @@ def main() -> int:
|
||||
|
||||
try:
|
||||
_run_cmd([str(python_path), "-m", "ensurepip", "--upgrade"])
|
||||
except subprocess.CalledProcessError as exc:
|
||||
except subprocess.CalledProcessError:
|
||||
print(
|
||||
"Failed to install pip inside the local virtualenv via ensurepip; ensure your Python build includes ensurepip and retry.",
|
||||
file=sys.stderr,
|
||||
@@ -1326,10 +1325,10 @@ if (Test-Path (Join-Path $repo 'CLI.py')) {
|
||||
|
||||
if not args.quiet:
|
||||
print(f"Installed global launcher to: {user_bin}")
|
||||
print(f"✓ mm.bat (Command Prompt and PowerShell)")
|
||||
print("✓ mm.bat (Command Prompt and PowerShell)")
|
||||
print()
|
||||
print("You can now run 'mm' from any terminal window.")
|
||||
print(f"If 'mm' is not found, restart your terminal or reload PATH:")
|
||||
print("If 'mm' is not found, restart your terminal or reload PATH:")
|
||||
print(" PowerShell: $env:PATH = [Environment]::GetEnvironmentVariable('PATH','User') + ';' + [Environment]::GetEnvironmentVariable('PATH','Machine')")
|
||||
print(" CMD: path %PATH%")
|
||||
|
||||
|
||||
@@ -5,6 +5,6 @@ import traceback
|
||||
try:
|
||||
importlib.import_module("CLI")
|
||||
print("CLI imported OK")
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
|
||||
19
scripts/check_pattern.py
Normal file
19
scripts/check_pattern.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import re
|
||||
from pathlib import Path
|
||||
p = Path(r'c:\Forgejo\Medios-Macina\CLI.py')
|
||||
s = p.read_text(encoding='utf-8')
|
||||
pattern = re.compile(r'(?s)if False:\s*class _OldPipelineExecutor:.*?from rich\\.markdown import Markdown\\s*')
|
||||
m = pattern.search(s)
|
||||
print('found', bool(m))
|
||||
if m:
|
||||
print('start', m.start(), 'end', m.end())
|
||||
print('snippet:', s[m.start():m.start()+120])
|
||||
else:
|
||||
# print a slice around the if False for debugging
|
||||
i = s.find('if False:')
|
||||
print('if False index', i)
|
||||
print('around if False:', s[max(0,i-50):i+200])
|
||||
j = s.find('from rich.markdown import Markdown', i)
|
||||
print('next from rich index after if False', j)
|
||||
if j!=-1:
|
||||
print('around that:', s[j-50:j+80])
|
||||
35
scripts/check_try_balance.py
Normal file
35
scripts/check_try_balance.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from pathlib import Path
|
||||
p=Path('SYS/pipeline.py')
|
||||
s=p.read_text(encoding='utf-8')
|
||||
lines=s.splitlines()
|
||||
stack=[]
|
||||
for i,l in enumerate(lines,1):
|
||||
stripped=l.strip()
|
||||
# Skip commented lines
|
||||
if stripped.startswith('#'):
|
||||
continue
|
||||
# compute indent as leading spaces (tabs are converted)
|
||||
indent = len(l) - len(l.lstrip(' '))
|
||||
if stripped.startswith('try:'):
|
||||
stack.append((indent, i))
|
||||
if stripped.startswith('except ') or stripped=='except:' or stripped.startswith('finally:'):
|
||||
# find the most recent try with same indent
|
||||
for idx in range(len(stack)-1, -1, -1):
|
||||
if stack[idx][0] == indent:
|
||||
stack.pop(idx)
|
||||
break
|
||||
else:
|
||||
# no matching try at same indent
|
||||
print(f"Found {stripped.split()[0]} at line {i} with no matching try at same indent")
|
||||
|
||||
print('Unmatched try count', len(stack))
|
||||
if stack:
|
||||
print('Unmatched try positions (indent, line):', stack)
|
||||
for indent, lineno in stack:
|
||||
start = max(1, lineno - 10)
|
||||
end = min(len(lines), lineno + 10)
|
||||
print(f"Context around line {lineno}:")
|
||||
for i in range(start, end + 1):
|
||||
print(f"{i:5d}: {lines[i-1]}")
|
||||
else:
|
||||
print("All try statements appear matched")
|
||||
@@ -1,4 +1,5 @@
|
||||
import importlib, traceback
|
||||
import importlib
|
||||
import traceback
|
||||
|
||||
try:
|
||||
m = importlib.import_module('Provider.vimm')
|
||||
|
||||
@@ -28,7 +28,6 @@ import sys
|
||||
import tempfile
|
||||
import urllib.request
|
||||
import zipfile
|
||||
import shlex
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import Optional, Tuple
|
||||
@@ -870,7 +869,7 @@ def main(argv: Optional[list[str]] = None) -> int:
|
||||
args.root = str(default_root)
|
||||
|
||||
# Ask for destination folder name
|
||||
dest_input = input(f"Enter folder name for Hydrus [default: hydrusnetwork]: ").strip()
|
||||
dest_input = input("Enter folder name for Hydrus [default: hydrusnetwork]: ").strip()
|
||||
if dest_input:
|
||||
args.dest_name = dest_input
|
||||
except (EOFError, KeyboardInterrupt):
|
||||
|
||||
@@ -41,7 +41,6 @@ from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import argparse
|
||||
import logging
|
||||
import threading
|
||||
@@ -54,7 +53,6 @@ from functools import wraps
|
||||
# Add parent directory to path for imports
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
from SYS.logger import log
|
||||
|
||||
# ============================================================================
|
||||
# CONFIGURATION
|
||||
@@ -419,29 +417,32 @@ def create_app():
|
||||
|
||||
filename = sanitize_filename(file_storage.filename or "upload")
|
||||
incoming_dir = STORAGE_PATH / "incoming"
|
||||
ensure_directory(incoming_dir)
|
||||
target_path = incoming_dir / filename
|
||||
target_path = unique_path(target_path)
|
||||
|
||||
try:
|
||||
# Save uploaded file to storage
|
||||
file_storage.save(str(target_path))
|
||||
|
||||
# Extract optional metadata
|
||||
tags = []
|
||||
if 'tag' in request.form:
|
||||
# Support repeated form fields or comma-separated list
|
||||
tags = request.form.getlist('tag') or []
|
||||
if not tags and request.form.get('tag'):
|
||||
tags = [t.strip() for t in str(request.form.get('tag') or "").split(",") if t.strip()]
|
||||
|
||||
urls = []
|
||||
if 'url' in request.form:
|
||||
urls = request.form.getlist('url') or []
|
||||
if not urls and request.form.get('url'):
|
||||
urls = [u.strip() for u in str(request.form.get('url') or "").split(",") if u.strip()]
|
||||
|
||||
# Initialize the DB first (run safety checks) before creating any files.
|
||||
with API_folder_store(STORAGE_PATH) as db:
|
||||
# Ensure the incoming directory exists only after DB safety checks pass.
|
||||
ensure_directory(incoming_dir)
|
||||
|
||||
# Save uploaded file to storage
|
||||
file_storage.save(str(target_path))
|
||||
|
||||
# Extract optional metadata
|
||||
tags = []
|
||||
if 'tag' in request.form:
|
||||
# Support repeated form fields or comma-separated list
|
||||
tags = request.form.getlist('tag') or []
|
||||
if not tags and request.form.get('tag'):
|
||||
tags = [t.strip() for t in str(request.form.get('tag') or "").split(",") if t.strip()]
|
||||
|
||||
urls = []
|
||||
if 'url' in request.form:
|
||||
urls = request.form.getlist('url') or []
|
||||
if not urls and request.form.get('url'):
|
||||
urls = [u.strip() for u in str(request.form.get('url') or "").split(",") if u.strip()]
|
||||
|
||||
db.get_or_create_file_entry(target_path)
|
||||
|
||||
if tags:
|
||||
@@ -723,7 +724,7 @@ def main():
|
||||
local_ip = "127.0.0.1"
|
||||
|
||||
print(f"\n{'='*70}")
|
||||
print(f"Remote Storage Server - Medios-Macina")
|
||||
print("Remote Storage Server - Medios-Macina")
|
||||
print(f"{'='*70}")
|
||||
print(f"Storage Path: {STORAGE_PATH}")
|
||||
print(f"Local IP: {local_ip}")
|
||||
|
||||
18
scripts/remove_old_executor.py
Normal file
18
scripts/remove_old_executor.py
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
from pathlib import Path
|
||||
p = Path(r"c:\Forgejo\Medios-Macina\CLI.py")
|
||||
s = p.read_text(encoding='utf-8')
|
||||
start = s.find('\nif False:')
|
||||
if start == -1:
|
||||
print('No if False found')
|
||||
else:
|
||||
after = s[start+1:]
|
||||
idx = after.find('\nfrom rich.markdown import Markdown')
|
||||
if idx == -1:
|
||||
print('No subsequent import found')
|
||||
else:
|
||||
before = s[:start]
|
||||
rest = after[idx+1:]
|
||||
new = before + '\nfrom rich.markdown import Markdown\n' + rest
|
||||
p.write_text(new, encoding='utf-8')
|
||||
print('Removed legacy block')
|
||||
@@ -14,10 +14,9 @@ from __future__ import annotations
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from typing import Any
|
||||
from pathlib import Path
|
||||
|
||||
from SYS.logger import log, debug
|
||||
from SYS.logger import log
|
||||
|
||||
try:
|
||||
from API import zerotier
|
||||
|
||||
Reference in New Issue
Block a user