From 611a2b7c1bd41537970c65f08d839963bce30e86 Mon Sep 17 00:00:00 2001
From: Nick Sweeting <github@sweeting.me>
Date: Tue, 8 Oct 2024 02:10:08 -0700
Subject: [PATCH] fix a few small nits

---
 archivebox/config/views.py         |  4 ++--
 archivebox/main.py                 |  4 ++--
 archivebox/misc/checks.py          | 13 +++++++++++++
 archivebox/plugins_pkg/pip/apps.py | 16 ++--------------
 4 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/archivebox/config/views.py b/archivebox/config/views.py
index c2f00875..b0f1a8c9 100644
--- a/archivebox/config/views.py
+++ b/archivebox/config/views.py
@@ -319,7 +319,7 @@ def worker_detail_view(request: HttpRequest, key: str, **kwargs) -> ItemContext:
     assert request.user.is_superuser, "Must be a superuser to view configuration settings."
 
     from queues.supervisor_util import get_existing_supervisord_process, get_worker
-    from queues.settings import CONFIG_FILE
+    from queues.settings import SUPERVISORD_CONFIG_FILE
 
     supervisor = get_existing_supervisord_process()
     if supervisor is None:
@@ -332,7 +332,7 @@ def worker_detail_view(request: HttpRequest, key: str, **kwargs) -> ItemContext:
     all_config = cast(List[Dict[str, Any]], supervisor.getAllConfigInfo() or [])
 
     if key == 'supervisord':
-        relevant_config = CONFIG_FILE.read_text()
+        relevant_config = SUPERVISORD_CONFIG_FILE.read_text()
         relevant_logs = cast(str, supervisor.readLog(0, 10_000_000))
         start_ts = [line for line in relevant_logs.split("\n") if "RPC interface 'supervisor' initialized" in line][-1].split(",", 1)[0]
         uptime = str(timezone.now() - parse_date(start_ts)).split(".")[0]
diff --git a/archivebox/main.py b/archivebox/main.py
index 128e532d..d0bf8a0c 100755
--- a/archivebox/main.py
+++ b/archivebox/main.py
@@ -280,7 +280,7 @@ def version(quiet: bool=False,
     data_dir_uid, data_dir_gid = data_dir_stat.st_uid, data_dir_stat.st_gid
     data_owned_by_root = data_dir_uid == 0
     
-    data_owned_by_default_user = data_dir_uid == DEFAULT_PUID or data_dir_gid == DEFAULT_PGID
+    # data_owned_by_default_user = data_dir_uid == DEFAULT_PUID or data_dir_gid == DEFAULT_PGID
     data_owner_doesnt_match = (data_dir_uid != ARCHIVEBOX_USER and data_dir_gid != ARCHIVEBOX_GROUP) and not IS_ROOT
     data_not_writable = not (os.access(DATA_DIR, os.W_OK) and os.access(CONSTANTS.LIB_DIR, os.W_OK) and os.access(CONSTANTS.TMP_DIR, os.W_OK))
     if data_owned_by_root:
@@ -290,7 +290,7 @@ def version(quiet: bool=False,
     else:
         prnt(f':information: [blue]DATA_DIR[/blue] is currently owned by [blue]{data_dir_uid}:{data_dir_gid}[/blue] (PUID:PGID)')
         
-    if data_owned_by_root or data_owner_doesnt_match or data_owned_by_default_user or data_not_writable:
+    if data_owned_by_root or data_owner_doesnt_match or data_not_writable:
         prnt(f'[violet]Hint:[/violet] If you encounter permissions errors, change [red]{data_dir_uid}[/red]:{data_dir_gid} (PUID:PGID) to match the user that will run ArchiveBox, e.g.:')
         prnt(f'    [grey53]sudo[/grey53] chown -R [blue]{DEFAULT_PUID}:{DEFAULT_PGID}[/blue] {DATA_DIR.resolve()}')
         prnt(f'    [grey53]sudo[/grey53] chown -R [blue]{DEFAULT_PUID}:{DEFAULT_PGID}[/blue] {CONSTANTS.LIB_DIR.resolve()}')
diff --git a/archivebox/misc/checks.py b/archivebox/misc/checks.py
index bee8dcb2..9dc753e9 100644
--- a/archivebox/misc/checks.py
+++ b/archivebox/misc/checks.py
@@ -1,6 +1,7 @@
 __package__ = 'archivebox.misc'
 
 import sys
+
 from rich import print
 
 # DO NOT ADD ANY TOP-LEVEL IMPORTS HERE
@@ -59,6 +60,18 @@ def check_io_encoding():
         print('    Confirm that it\'s fixed by opening a new shell and running:', file=sys.stderr)
         print('        python3 -c "import sys; print(sys.stdout.encoding)"   # should output UTF-8', file=sys.stderr)
         raise SystemExit(2)
+    
+    # # hard errors: check python version
+    # if sys.version_info[:3] < (3, 10, 0):
+    #     print('[red][X] Python version is not new enough: {sys.version} (>3.10 is required)[/red]', file=sys.stderr)
+    #     print('    See https://github.com/ArchiveBox/ArchiveBox/wiki/Troubleshooting#python for help upgrading your Python installation.', file=sys.stderr)
+    #     raise SystemExit(2)
+    
+    # # hard errors: check django version
+    # if int(django.VERSION[0]) < 5:
+    #     print('[red][X] Django version is not new enough: {django.VERSION[:3]} (>=5.0 is required)[/red]', file=sys.stderr)
+    #     print('    Upgrade django using pip or your system package manager: pip3 install --upgrade django', file=sys.stderr)
+    #     raise SystemExit(2)
 
 
 def check_not_root():
diff --git a/archivebox/plugins_pkg/pip/apps.py b/archivebox/plugins_pkg/pip/apps.py
index 0508525c..cbad35d7 100644
--- a/archivebox/plugins_pkg/pip/apps.py
+++ b/archivebox/plugins_pkg/pip/apps.py
@@ -226,26 +226,14 @@ class CheckPipEnvironment(BaseCheck):
 
     @staticmethod
     def check(settings, logger) -> List[Warning]:
-        # hard errors: check python version
-        if sys.version_info[:3] < (3, 10, 0):
-            print('[red][X] Python version is not new enough: {sys.version} (>3.10 is required)[/red]', file=sys.stderr)
-            print('    See https://github.com/ArchiveBox/ArchiveBox/wiki/Troubleshooting#python for help upgrading your Python installation.', file=sys.stderr)
-            raise SystemExit(2)
-        
-        # hard errors: check django version
-        if int(django.VERSION[0]) < 5:
-            print('[red][X] Django version is not new enough: {django.VERSION[:3]} (>=5.0 is required)[/red]', file=sys.stderr)
-            print('    Upgrade django using pip or your system package manager: pip3 install --upgrade django', file=sys.stderr)
-            raise SystemExit(2)
-        
         # soft errors: check that lib/pip virtualenv is setup properly
         errors = []
         
         LIB_PIP_BINPROVIDER.setup()
-        if not LIB_PIP_BINPROVIDER.INSTALLER_BIN_ABSPATH:
+        if not LIB_PIP_BINPROVIDER.is_valid:
             errors.append(
                 Error(
-                    "Failed to setup data/lib/pip virtualenv for runtime dependencies!",
+                    f"Failed to setup {LIB_PIP_BINPROVIDER.pip_venv} virtualenv for runtime dependencies!",
                     id="pip.P001",
                     hint="Make sure the data dir is writable and make sure python3-pip and python3-venv are installed & available on the host.",
                 )