From 43c471e4af6fade5c55c38b0ff4eda1eeaeef4fe Mon Sep 17 00:00:00 2001
From: Nick Sweeting <git@sweeting.me>
Date: Thu, 25 Jun 2020 17:47:55 -0400
Subject: [PATCH] cli experience improvements

---
 .../migrations/0002_auto_20200625_1521.py     | 18 ++++++++++++++++++
 archivebox/core/models.py                     |  2 +-
 archivebox/extractors/favicon.py              |  1 +
 archivebox/main.py                            |  4 ++--
 archivebox/manage.py                          | 19 ++++++++++---------
 archivebox/system.py                          |  1 +
 6 files changed, 33 insertions(+), 12 deletions(-)
 create mode 100644 archivebox/core/migrations/0002_auto_20200625_1521.py

diff --git a/archivebox/core/migrations/0002_auto_20200625_1521.py b/archivebox/core/migrations/0002_auto_20200625_1521.py
new file mode 100644
index 00000000..48112829
--- /dev/null
+++ b/archivebox/core/migrations/0002_auto_20200625_1521.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.7 on 2020-06-25 15:21
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('core', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='snapshot',
+            name='timestamp',
+            field=models.CharField(default=None, max_length=32, null=True),
+        ),
+    ]
diff --git a/archivebox/core/models.py b/archivebox/core/models.py
index 2c889585..f343fcbc 100644
--- a/archivebox/core/models.py
+++ b/archivebox/core/models.py
@@ -12,7 +12,7 @@ class Snapshot(models.Model):
     id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
 
     url = models.URLField(unique=True)
-    timestamp = models.CharField(unique=True, max_length=32, null=True, default=None)
+    timestamp = models.CharField(max_length=32, null=True, default=None)
 
     title = models.CharField(max_length=128, null=True, default=None)
     tags = models.CharField(max_length=256, null=True, default=None)
diff --git a/archivebox/extractors/favicon.py b/archivebox/extractors/favicon.py
index ab5485c8..6f68fccf 100644
--- a/archivebox/extractors/favicon.py
+++ b/archivebox/extractors/favicon.py
@@ -33,6 +33,7 @@ def save_favicon(link: Link, out_dir: Optional[str]=None, timeout: int=TIMEOUT)
     output: ArchiveOutput = 'favicon.ico'
     cmd = [
         CURL_BINARY,
+        '--silent',
         '--max-time', str(timeout),
         '--location',
         '--output', str(output),
diff --git a/archivebox/main.py b/archivebox/main.py
index 80e4b77b..68e7e8ba 100644
--- a/archivebox/main.py
+++ b/archivebox/main.py
@@ -483,7 +483,7 @@ def add(import_str: Optional[str]=None,
 
     check_data_folder(out_dir=out_dir)
 
-    if import_str and import_path:
+    if (import_str and import_path) or (not import_str and not import_path):
         stderr(
             '[X] You should pass either an import path as an argument, '
             'or pass a list of links via stdin, but not both.\n',
@@ -492,7 +492,7 @@ def add(import_str: Optional[str]=None,
         raise SystemExit(2)
     elif import_str:
         import_path = save_stdin_to_sources(import_str, out_dir=out_dir)
-    else:
+    elif import_path:
         import_path = save_file_to_sources(import_path, out_dir=out_dir)
 
     check_dependencies()
diff --git a/archivebox/manage.py b/archivebox/manage.py
index 3976c2c2..6951d8f7 100755
--- a/archivebox/manage.py
+++ b/archivebox/manage.py
@@ -7,15 +7,16 @@ if __name__ == '__main__':
     # versions of ./manage.py commands whenever possible. When that's not possible
     # (e.g. makemigrations), you can comment out this check temporarily
 
-    print("[X] Don't run ./manage.py directly, use the archivebox CLI instead e.g.:")
-    print('    archivebox manage createsuperuser')
-    print()
-    print('    Hint: Use these archivebox commands instead of the ./manage.py equivalents:')
-    print('        archivebox init          (migrates the databse to latest version)')
-    print('        archivebox server        (runs the Django web server)')
-    print('        archivebox shell         (opens an iPython Django shell with all models imported)')
-    print('        archivebox manage [cmd]  (any other management commands)')
-    raise SystemExit(2)
+    if not ('makemigrations' in sys.argv or 'migrate' in sys.argv):
+        print("[X] Don't run ./manage.py directly, use the archivebox CLI instead e.g.:")
+        print('    archivebox manage createsuperuser')
+        print()
+        print('    Hint: Use these archivebox commands instead of the ./manage.py equivalents:')
+        print('        archivebox init          (migrates the databse to latest version)')
+        print('        archivebox server        (runs the Django web server)')
+        print('        archivebox shell         (opens an iPython Django shell with all models imported)')
+        print('        archivebox manage [cmd]  (any other management commands)')
+        raise SystemExit(2)
 
     os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
     try:
diff --git a/archivebox/system.py b/archivebox/system.py
index aa6263e9..b6063ac2 100644
--- a/archivebox/system.py
+++ b/archivebox/system.py
@@ -25,6 +25,7 @@ from .config import OUTPUT_PERMISSIONS
 def run(*popenargs, input=None, capture_output=False, timeout=None, check=False, **kwargs):
     """Patched of subprocess.run to fix blocking io making timeout=innefective"""
 
+    
     if input is not None:
         if 'stdin' in kwargs:
             raise ValueError('stdin and input arguments may not both be used.')