|
36 | 36 | # ── Configuration ────────────────────────────────────────────────────────────── |
37 | 37 |
|
38 | 38 | PROJECT_DIR = Path(__file__).parent |
39 | | -MANIFEST_FILE = PROJECT_DIR / "manifest.json" |
| 39 | +MANIFEST_FILE = None # set after DATA_DIR is resolved below |
| 40 | + |
| 41 | +# When bundled as an AppImage, __file__ resolves to a temp dir deleted on exit. |
| 42 | +# Credentials and config must be read from the persistent ~/.auto_note/ directory. |
| 43 | +if getattr(sys, "frozen", False): |
| 44 | + DATA_DIR = Path.home() / ".auto_note" |
| 45 | +else: |
| 46 | + DATA_DIR = PROJECT_DIR |
| 47 | + |
| 48 | +MANIFEST_FILE = DATA_DIR / "manifest.json" |
40 | 49 |
|
41 | 50 | # ── User-configurable connection settings (set via GUI Settings page) ────────── |
42 | | -_config_file = PROJECT_DIR / "config.json" |
| 51 | +_config_file = DATA_DIR / "config.json" |
43 | 52 | _config: dict = json.load(open(_config_file)) if _config_file.exists() else {} |
44 | 53 |
|
45 | | -CANVAS_URL = _config.get("CANVAS_URL", "") |
| 54 | +CANVAS_URL = _config.get("CANVAS_URL", "").strip().rstrip("/") |
| 55 | +if CANVAS_URL and not CANVAS_URL.startswith(("http://", "https://")): |
| 56 | + CANVAS_URL = "https://" + CANVAS_URL |
46 | 57 | PANOPTO_HOST = _config.get("PANOPTO_HOST", "") |
47 | 58 |
|
48 | | -_canvas_token_file = PROJECT_DIR / "canvas_token.txt" |
| 59 | +_canvas_token_file = DATA_DIR / "canvas_token.txt" |
49 | 60 | CANVAS_TOKEN = ( |
50 | 61 | _canvas_token_file.read_text().strip() |
51 | 62 | if _canvas_token_file.exists() else |
@@ -649,7 +660,7 @@ def _classify_with_ai(files: list[dict], course_name: str) -> list[dict]: |
649 | 660 | import anthropic |
650 | 661 | key = os.environ.get("ANTHROPIC_API_KEY", "") |
651 | 662 | if not key: |
652 | | - kf = PROJECT_DIR / "anthropic_key.txt" |
| 663 | + kf = DATA_DIR / "anthropic_key.txt" |
653 | 664 | if kf.exists(): |
654 | 665 | key = kf.read_text().strip() |
655 | 666 | client = anthropic.Anthropic(api_key=key) |
@@ -975,7 +986,7 @@ def main() -> None: |
975 | 986 | parser.print_help() |
976 | 987 | sys.exit(0) |
977 | 988 |
|
978 | | - base_dir = Path(args.path) if args.path else PROJECT_DIR |
| 989 | + base_dir = Path(args.path) if args.path else DATA_DIR |
979 | 990 | canvas = Canvas(CANVAS_URL, CANVAS_TOKEN) |
980 | 991 |
|
981 | 992 | # ── --course-list ────────────────────────────────────────────────────────── |
|
0 commit comments