Browse Source

Attempted to warn on #984 and #1014

Joseph Turian 3 years ago
parent
commit
2b58cce43f
1 changed files with 16 additions and 0 deletions
  1. 16 0
      archivebox/extractors/__init__.py

+ 16 - 0
archivebox/extractors/__init__.py

@@ -7,6 +7,7 @@ from typing import Optional, List, Iterable, Union
 from datetime import datetime, timezone
 from datetime import datetime, timezone
 from django.db.models import QuerySet
 from django.db.models import QuerySet
 
 
+from ..core.settings import ERROR_LOG
 from ..index.schema import Link
 from ..index.schema import Link
 from ..index.sql import write_link_to_sql_index
 from ..index.sql import write_link_to_sql_index
 from ..index import (
 from ..index import (
@@ -127,10 +128,25 @@ def archive_link(link: Link, overwrite: bool=False, methods: Optional[Iterable[s
                     # print('{black}      X {}{reset}'.format(method_name, **ANSI))
                     # print('{black}      X {}{reset}'.format(method_name, **ANSI))
                     stats['skipped'] += 1
                     stats['skipped'] += 1
             except Exception as e:
             except Exception as e:
+                # Disabled until https://github.com/ArchiveBox/ArchiveBox/issues/984
+                # and https://github.com/ArchiveBox/ArchiveBox/issues/1014
+                # are fixed.
+                """
                 raise Exception('Exception in archive_methods.save_{}(Link(url={}))'.format(
                 raise Exception('Exception in archive_methods.save_{}(Link(url={}))'.format(
                     method_name,
                     method_name,
                     link.url,
                     link.url,
                 )) from e
                 )) from e
+                """
+		        # Instead, use the kludgy workaround from
+                # https://github.com/ArchiveBox/ArchiveBox/issues/984#issuecomment-1150541627
+                with open(ERROR_LOG, "a", encoding='utf-8') as f:
+                    command = ' '.join(sys.argv)
+                    ts = datetime.now(timezone.utc).strftime('%Y-%m-%d__%H:%M:%S')
+                    f.write(("\n" + 'Exception in archive_methods.save_{}(Link(url={}))'.format(
+                        method_name,
+                        link.url,
+                    ) + "\n"))
+                    #f.write(f"\n> {command}; ts={ts} version={config['VERSION']} docker={config['IN_DOCKER']} is_tty={config['IS_TTY']}\n")
 
 
         # print('    ', stats)
         # print('    ', stats)