From 57b2d40477630c32bb1e454533a3ba5d4ecc5748 Mon Sep 17 00:00:00 2001 From: TheZupZup <16434778+TheZupZup@users.noreply.github.com> Date: Sat, 11 Apr 2026 16:31:10 -0400 Subject: [PATCH] Update connect screen startup instructions for portable paths --- app/lib/screens/connect_screen.dart | 6 +++--- launch_app.sh | 14 +++++++++++- nexanote.sh | 33 ++++++++++++++++++++++------- nexanote/sync/server.py | 5 ++++- 4 files changed, 45 insertions(+), 13 deletions(-) diff --git a/app/lib/screens/connect_screen.dart b/app/lib/screens/connect_screen.dart index ca86346..fb35a1f 100644 --- a/app/lib/screens/connect_screen.dart +++ b/app/lib/screens/connect_screen.dart @@ -23,7 +23,7 @@ class _ConnectScreenState extends State { await state.connect(url: _controller.text.trim()); if (mounted && !state.isConnected) { setState(() { - _error = 'Cannot reach the server.\nMake sure NexaNote backend is running:\n python main.py'; + _error = 'Cannot reach the server.\nStart NexaNote backend from the project folder:\n bash nexanote.sh\nor run:\n python main.py'; _connecting = false; }); } @@ -150,9 +150,9 @@ class _ConnectScreenState extends State { color: scheme.onSurface.withOpacity(0.7))), ]), const SizedBox(height: 8), - _code('cd ~/NexaNote'), - _code('source venv/bin/activate'), + _code('cd /NexaNote'), _code('python main.py'), + _code('# or: bash nexanote.sh'), ], ), ), diff --git a/launch_app.sh b/launch_app.sh index a2d67ed..acfb0a1 100755 --- a/launch_app.sh +++ b/launch_app.sh @@ -1,2 +1,14 @@ #!/bin/bash -GDK_BACKEND=x11 ~/NexaNote/app/build/linux/x64/release/bundle/app +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +APP_BIN="$SCRIPT_DIR/app/build/linux/x64/release/bundle/app" + +if [[ ! -x "$APP_BIN" ]]; then + echo "Binaire Flutter introuvable: $APP_BIN" + echo "Compilez d'abord l'app avec:" + echo " cd $SCRIPT_DIR/app && flutter build linux --release" + exit 1 +fi + +GDK_BACKEND=x11 "$APP_BIN" diff --git a/nexanote.sh b/nexanote.sh index 44f940e..fccc986 100755 --- a/nexanote.sh +++ b/nexanote.sh @@ -1,20 +1,38 @@ #!/bin/bash -NEXANOTE_DIR="$HOME/NexaNote" +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +NEXANOTE_DIR="$SCRIPT_DIR" APP_DIR="$NEXANOTE_DIR/app" -VENV="$NEXANOTE_DIR/venv/bin/activate" +VENV_ACTIVATE="$NEXANOTE_DIR/venv/bin/activate" LOG_FILE="/tmp/nexanote_backend.log" +BACKEND_PID="" + +cleanup() { + if [[ -n "${BACKEND_PID}" ]]; then + kill "$BACKEND_PID" 2>/dev/null || true + fi +} +trap cleanup EXIT -if ! curl -s http://127.0.0.1:8766/health > /dev/null 2>&1; then +if ! curl -s http://127.0.0.1:8766/health >/dev/null 2>&1; then echo "🚀 Démarrage du backend..." - source "$VENV" + if [[ -f "$VENV_ACTIVATE" ]]; then + # shellcheck source=/dev/null + source "$VENV_ACTIVATE" + else + echo "⚠️ venv introuvable ($VENV_ACTIVATE), utilisation du Python système" + fi + cd "$NEXANOTE_DIR" - python main.py > "$LOG_FILE" 2>&1 & + python main.py >"$LOG_FILE" 2>&1 & BACKEND_PID=$! + echo -n "⏳ Attente" - for i in $(seq 1 20); do + for _ in $(seq 1 20); do sleep 0.5 echo -n "." - if curl -s http://127.0.0.1:8766/health > /dev/null 2>&1; then + if curl -s http://127.0.0.1:8766/health >/dev/null 2>&1; then echo " ✅" break fi @@ -25,4 +43,3 @@ fi cd "$APP_DIR" GDK_BACKEND=x11 flutter run -d linux -kill $BACKEND_PID 2>/dev/null diff --git a/nexanote/sync/server.py b/nexanote/sync/server.py index 7622b72..21f82a9 100644 --- a/nexanote/sync/server.py +++ b/nexanote/sync/server.py @@ -12,6 +12,7 @@ import argparse import hashlib +import importlib.util import logging import sys from pathlib import Path @@ -80,7 +81,6 @@ def build_app( # Middleware "middleware_stack": [ - "wsgidav.debug_filter.WsgiDavDebugFilter", "wsgidav.error_printer.ErrorPrinter", "wsgidav.http_authenticator.HTTPAuthenticator", "wsgidav.dir_browser.WsgiDavDirBrowser", @@ -88,6 +88,9 @@ def build_app( ], } + if importlib.util.find_spec("wsgidav.debug_filter"): + config["middleware_stack"].insert(0, "wsgidav.debug_filter.WsgiDavDebugFilter") + return WsgiDAVApp(config)