mirror of
https://github.com/pirate/ArchiveBox.git
synced 2025-08-26 07:44:41 +02:00
better remote file downloading cli output messages
This commit is contained in:
@@ -72,9 +72,8 @@ def load_links(archive_path=OUTPUT_DIR, import_path=None):
|
|||||||
num_new_links = len(all_links) - len(existing_links)
|
num_new_links = len(all_links) - len(existing_links)
|
||||||
|
|
||||||
if import_path and parser_name:
|
if import_path and parser_name:
|
||||||
print(' > Adding {} new links to index from {} (parsed as {} format)'.format(
|
print(' > Adding {} new links to index (parsed import as {})'.format(
|
||||||
num_new_links,
|
num_new_links,
|
||||||
pretty_path(import_path),
|
|
||||||
parser_name,
|
parser_name,
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@@ -243,10 +243,11 @@ def download_url(url, timeout=TIMEOUT):
|
|||||||
|
|
||||||
source_path = os.path.join(SOURCES_DIR, '{}-{}.txt'.format(domain(url), ts))
|
source_path = os.path.join(SOURCES_DIR, '{}-{}.txt'.format(domain(url), ts))
|
||||||
|
|
||||||
print('[*] [{}] Downloading {} > {}'.format(
|
print('{}[*] [{}] Downloading {}{}'.format(
|
||||||
|
ANSI['green'],
|
||||||
datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
url,
|
url,
|
||||||
pretty_path(source_path),
|
ANSI['reset'],
|
||||||
))
|
))
|
||||||
end = progress(TIMEOUT, prefix=' ')
|
end = progress(TIMEOUT, prefix=' ')
|
||||||
try:
|
try:
|
||||||
@@ -254,12 +255,18 @@ def download_url(url, timeout=TIMEOUT):
|
|||||||
end()
|
end()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
end()
|
end()
|
||||||
print('[!] Failed to download {}\n'.format(url))
|
print('{}[!] Failed to download {}{}\n'.format(
|
||||||
|
ANSI['red'],
|
||||||
|
url,
|
||||||
|
ANSI['reset'],
|
||||||
|
))
|
||||||
print(' ', e)
|
print(' ', e)
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
|
|
||||||
with open(source_path, 'w', encoding='utf-8') as f:
|
with open(source_path, 'w', encoding='utf-8') as f:
|
||||||
f.write(downloaded_xml)
|
f.write(downloaded_xml)
|
||||||
|
|
||||||
|
print(' > {}'.format(pretty_path(source_path)))
|
||||||
|
|
||||||
return source_path
|
return source_path
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user