logging_util.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. __package__ = 'archivebox'
  2. import re
  3. import os
  4. import sys
  5. import stat
  6. import time
  7. import argparse
  8. from math import log
  9. from multiprocessing import Process
  10. from pathlib import Path
  11. from datetime import datetime
  12. from dataclasses import dataclass
  13. from typing import Any, Optional, List, Dict, Union, IO, TYPE_CHECKING
  14. if TYPE_CHECKING:
  15. from .index.schema import Link, ArchiveResult
  16. from .system import get_dir_size
  17. from .util import enforce_types
  18. from .config import (
  19. ConfigDict,
  20. OUTPUT_DIR,
  21. PYTHON_ENCODING,
  22. VERSION,
  23. ANSI,
  24. IS_TTY,
  25. IN_DOCKER,
  26. TERM_WIDTH,
  27. SHOW_PROGRESS,
  28. SOURCES_DIR_NAME,
  29. stderr,
  30. )
  31. @dataclass
  32. class RuntimeStats:
  33. """mutable stats counter for logging archiving timing info to CLI output"""
  34. skipped: int = 0
  35. succeeded: int = 0
  36. failed: int = 0
  37. parse_start_ts: Optional[datetime] = None
  38. parse_end_ts: Optional[datetime] = None
  39. index_start_ts: Optional[datetime] = None
  40. index_end_ts: Optional[datetime] = None
  41. archiving_start_ts: Optional[datetime] = None
  42. archiving_end_ts: Optional[datetime] = None
  43. # globals are bad, mmkay
  44. _LAST_RUN_STATS = RuntimeStats()
  45. def debug_dict_summary(obj: Dict[Any, Any]) -> None:
  46. stderr(' '.join(f'{key}={str(val).ljust(6)}' for key, val in obj.items()))
  47. def get_fd_info(fd) -> Dict[str, Any]:
  48. NAME = fd.name[1:-1]
  49. FILENO = fd.fileno()
  50. MODE = os.fstat(FILENO).st_mode
  51. IS_TTY = hasattr(fd, 'isatty') and fd.isatty()
  52. IS_PIPE = stat.S_ISFIFO(MODE)
  53. IS_FILE = stat.S_ISREG(MODE)
  54. IS_TERMINAL = not (IS_PIPE or IS_FILE)
  55. IS_LINE_BUFFERED = fd.line_buffering
  56. IS_READABLE = fd.readable()
  57. return {key: val for key, val in locals().items() if val is not fd}
  58. # # Log debug information about stdin, stdout, and stderr
  59. # sys.stdout.write('[>&1] this is python stdout\n')
  60. # sys.stderr.write('[>&2] this is python stderr\n')
  61. # debug_dict_summary(get_fd_info(sys.stdin))
  62. # debug_dict_summary(get_fd_info(sys.stdout))
  63. # debug_dict_summary(get_fd_info(sys.stderr))
  64. class SmartFormatter(argparse.HelpFormatter):
  65. """Patched formatter that prints newlines in argparse help strings"""
  66. def _split_lines(self, text, width):
  67. if '\n' in text:
  68. return text.splitlines()
  69. return argparse.HelpFormatter._split_lines(self, text, width)
  70. def reject_stdin(caller: str, stdin: Optional[IO]=sys.stdin) -> None:
  71. """Tell the user they passed stdin to a command that doesn't accept it"""
  72. if not stdin:
  73. return None
  74. if IN_DOCKER:
  75. # when TTY is disabled in docker we cant tell if stdin is being piped in or not
  76. # if we try to read stdin when its not piped we will hang indefinitely waiting for it
  77. return None
  78. if not stdin.isatty():
  79. # stderr('READING STDIN TO REJECT...')
  80. stdin_raw_text = stdin.read()
  81. if stdin_raw_text:
  82. # stderr('GOT STDIN!', len(stdin_str))
  83. stderr(f'[X] The "{caller}" command does not accept stdin.', color='red')
  84. stderr(f' Run archivebox "{caller} --help" to see usage and examples.')
  85. stderr()
  86. raise SystemExit(1)
  87. return None
  88. def accept_stdin(stdin: Optional[IO]=sys.stdin) -> Optional[str]:
  89. """accept any standard input and return it as a string or None"""
  90. if not stdin:
  91. return None
  92. if not stdin.isatty():
  93. # stderr('READING STDIN TO ACCEPT...')
  94. stdin_str = stdin.read()
  95. if stdin_str:
  96. # stderr('GOT STDIN...', len(stdin_str))
  97. return stdin_str
  98. return None
  99. class TimedProgress:
  100. """Show a progress bar and measure elapsed time until .end() is called"""
  101. def __init__(self, seconds, prefix=''):
  102. self.SHOW_PROGRESS = SHOW_PROGRESS
  103. if self.SHOW_PROGRESS:
  104. self.p = Process(target=progress_bar, args=(seconds, prefix))
  105. self.p.start()
  106. self.stats = {'start_ts': datetime.now(), 'end_ts': None}
  107. def end(self):
  108. """immediately end progress, clear the progressbar line, and save end_ts"""
  109. end_ts = datetime.now()
  110. self.stats['end_ts'] = end_ts
  111. if self.SHOW_PROGRESS:
  112. # terminate if we havent already terminated
  113. try:
  114. # kill the progress bar subprocess
  115. try:
  116. self.p.close() # must be closed *before* its terminnated
  117. except:
  118. pass
  119. self.p.terminate()
  120. self.p.join()
  121. # clear whole terminal line
  122. try:
  123. sys.stdout.write('\r{}{}\r'.format((' ' * TERM_WIDTH()), ANSI['reset']))
  124. except (IOError, BrokenPipeError):
  125. # ignore when the parent proc has stopped listening to our stdout
  126. pass
  127. except ValueError:
  128. pass
  129. @enforce_types
  130. def progress_bar(seconds: int, prefix: str='') -> None:
  131. """show timer in the form of progress bar, with percentage and seconds remaining"""
  132. chunk = '█' if PYTHON_ENCODING == 'UTF-8' else '#'
  133. last_width = TERM_WIDTH()
  134. chunks = last_width - len(prefix) - 20 # number of progress chunks to show (aka max bar width)
  135. try:
  136. for s in range(seconds * chunks):
  137. max_width = TERM_WIDTH()
  138. if max_width < last_width:
  139. # when the terminal size is shrunk, we have to write a newline
  140. # otherwise the progress bar will keep wrapping incorrectly
  141. sys.stdout.write('\r\n')
  142. sys.stdout.flush()
  143. chunks = max_width - len(prefix) - 20
  144. pct_complete = s / chunks / seconds * 100
  145. log_pct = (log(pct_complete or 1, 10) / 2) * 100 # everyone likes faster progress bars ;)
  146. bar_width = round(log_pct/(100/chunks))
  147. last_width = max_width
  148. # ████████████████████ 0.9% (1/60sec)
  149. sys.stdout.write('\r{0}{1}{2}{3} {4}% ({5}/{6}sec)'.format(
  150. prefix,
  151. ANSI['green' if pct_complete < 80 else 'lightyellow'],
  152. (chunk * bar_width).ljust(chunks),
  153. ANSI['reset'],
  154. round(pct_complete, 1),
  155. round(s/chunks),
  156. seconds,
  157. ))
  158. sys.stdout.flush()
  159. time.sleep(1 / chunks)
  160. # ██████████████████████████████████ 100.0% (60/60sec)
  161. sys.stdout.write('\r{0}{1}{2}{3} {4}% ({5}/{6}sec)'.format(
  162. prefix,
  163. ANSI['red'],
  164. chunk * chunks,
  165. ANSI['reset'],
  166. 100.0,
  167. seconds,
  168. seconds,
  169. ))
  170. sys.stdout.flush()
  171. # uncomment to have it disappear when it hits 100% instead of staying full red:
  172. # time.sleep(0.5)
  173. # sys.stdout.write('\r{}{}\r'.format((' ' * TERM_WIDTH()), ANSI['reset']))
  174. # sys.stdout.flush()
  175. except (KeyboardInterrupt, BrokenPipeError):
  176. print()
  177. pass
  178. def log_cli_command(subcommand: str, subcommand_args: List[str], stdin: Optional[str], pwd: str):
  179. cmd = ' '.join(('archivebox', subcommand, *subcommand_args))
  180. stderr('{black}[i] [{now}] ArchiveBox v{VERSION}: {cmd}{reset}'.format(
  181. now=datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
  182. VERSION=VERSION,
  183. cmd=cmd,
  184. **ANSI,
  185. ))
  186. stderr('{black} > {pwd}{reset}'.format(pwd=pwd, **ANSI))
  187. stderr()
  188. ### Parsing Stage
  189. def log_importing_started(urls: Union[str, List[str]], depth: int, index_only: bool):
  190. _LAST_RUN_STATS.parse_start_ts = datetime.now()
  191. print('{green}[+] [{}] Adding {} links to index (crawl depth={}){}...{reset}'.format(
  192. _LAST_RUN_STATS.parse_start_ts.strftime('%Y-%m-%d %H:%M:%S'),
  193. len(urls) if isinstance(urls, list) else len(urls.split('\n')),
  194. depth,
  195. ' (index only)' if index_only else '',
  196. **ANSI,
  197. ))
  198. def log_source_saved(source_file: str):
  199. print(' > Saved verbatim input to {}/{}'.format(SOURCES_DIR_NAME, source_file.rsplit('/', 1)[-1]))
  200. def log_parsing_finished(num_parsed: int, parser_name: str):
  201. _LAST_RUN_STATS.parse_end_ts = datetime.now()
  202. print(' > Parsed {} URLs from input ({})'.format(num_parsed, parser_name))
  203. def log_deduping_finished(num_new_links: int):
  204. print(' > Found {} new URLs not already in index'.format(num_new_links))
  205. def log_crawl_started(new_links):
  206. print()
  207. print('{green}[*] Starting crawl of {} sites 1 hop out from starting point{reset}'.format(len(new_links), **ANSI))
  208. ### Indexing Stage
  209. def log_indexing_process_started(num_links: int):
  210. start_ts = datetime.now()
  211. _LAST_RUN_STATS.index_start_ts = start_ts
  212. print()
  213. print('{black}[*] [{}] Writing {} links to main index...{reset}'.format(
  214. start_ts.strftime('%Y-%m-%d %H:%M:%S'),
  215. num_links,
  216. **ANSI,
  217. ))
  218. def log_indexing_process_finished():
  219. end_ts = datetime.now()
  220. _LAST_RUN_STATS.index_end_ts = end_ts
  221. def log_indexing_started(out_path: str):
  222. if IS_TTY:
  223. sys.stdout.write(f' > {out_path}')
  224. def log_indexing_finished(out_path: str):
  225. print(f'\r √ {out_path}')
  226. ### Archiving Stage
  227. def log_archiving_started(num_links: int, resume: Optional[float]=None):
  228. start_ts = datetime.now()
  229. _LAST_RUN_STATS.archiving_start_ts = start_ts
  230. print()
  231. if resume:
  232. print('{green}[▶] [{}] Resuming archive updating for {} pages starting from {}...{reset}'.format(
  233. start_ts.strftime('%Y-%m-%d %H:%M:%S'),
  234. num_links,
  235. resume,
  236. **ANSI,
  237. ))
  238. else:
  239. print('{green}[▶] [{}] Starting archiving of {} snapshots in index...{reset}'.format(
  240. start_ts.strftime('%Y-%m-%d %H:%M:%S'),
  241. num_links,
  242. **ANSI,
  243. ))
  244. def log_archiving_paused(num_links: int, idx: int, timestamp: str):
  245. end_ts = datetime.now()
  246. _LAST_RUN_STATS.archiving_end_ts = end_ts
  247. print()
  248. print('\n{lightyellow}[X] [{now}] Downloading paused on link {timestamp} ({idx}/{total}){reset}'.format(
  249. **ANSI,
  250. now=end_ts.strftime('%Y-%m-%d %H:%M:%S'),
  251. idx=idx+1,
  252. timestamp=timestamp,
  253. total=num_links,
  254. ))
  255. print()
  256. print(' Continue archiving where you left off by running:')
  257. print(' archivebox update --resume={}'.format(timestamp))
  258. def log_archiving_finished(num_links: int):
  259. end_ts = datetime.now()
  260. _LAST_RUN_STATS.archiving_end_ts = end_ts
  261. assert _LAST_RUN_STATS.archiving_start_ts is not None
  262. seconds = end_ts.timestamp() - _LAST_RUN_STATS.archiving_start_ts.timestamp()
  263. if seconds > 60:
  264. duration = '{0:.2f} min'.format(seconds / 60)
  265. else:
  266. duration = '{0:.2f} sec'.format(seconds)
  267. print()
  268. print('{}[√] [{}] Update of {} pages complete ({}){}'.format(
  269. ANSI['green'],
  270. end_ts.strftime('%Y-%m-%d %H:%M:%S'),
  271. num_links,
  272. duration,
  273. ANSI['reset'],
  274. ))
  275. print(' - {} links skipped'.format(_LAST_RUN_STATS.skipped))
  276. print(' - {} links updated'.format(_LAST_RUN_STATS.succeeded + _LAST_RUN_STATS.failed))
  277. print(' - {} links had errors'.format(_LAST_RUN_STATS.failed))
  278. print()
  279. print(' {lightred}Hint:{reset} To manage your archive in a Web UI, run:'.format(**ANSI))
  280. print(' archivebox server 0.0.0.0:8000')
  281. def log_link_archiving_started(link: "Link", link_dir: str, is_new: bool):
  282. # [*] [2019-03-22 13:46:45] "Log Structured Merge Trees - ben stopford"
  283. # http://www.benstopford.com/2015/02/14/log-structured-merge-trees/
  284. # > output/archive/1478739709
  285. print('\n[{symbol_color}{symbol}{reset}] [{symbol_color}{now}{reset}] "{title}"'.format(
  286. symbol_color=ANSI['green' if is_new else 'black'],
  287. symbol='+' if is_new else '√',
  288. now=datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
  289. title=link.title or link.base_url,
  290. **ANSI,
  291. ))
  292. print(' {blue}{url}{reset}'.format(url=link.url, **ANSI))
  293. print(' {} {}'.format(
  294. '>' if is_new else '√',
  295. pretty_path(link_dir),
  296. ))
  297. def log_link_archiving_finished(link: "Link", link_dir: str, is_new: bool, stats: dict):
  298. total = sum(stats.values())
  299. if stats['failed'] > 0 :
  300. _LAST_RUN_STATS.failed += 1
  301. elif stats['skipped'] == total:
  302. _LAST_RUN_STATS.skipped += 1
  303. else:
  304. _LAST_RUN_STATS.succeeded += 1
  305. size = get_dir_size(link_dir)
  306. print(' {black}{} files ({}){reset}'.format(size[2], printable_filesize(size[0]), **ANSI))
  307. def log_archive_method_started(method: str):
  308. print(' > {}'.format(method))
  309. def log_archive_method_finished(result: "ArchiveResult"):
  310. """quote the argument with whitespace in a command so the user can
  311. copy-paste the outputted string directly to run the cmd
  312. """
  313. # Prettify CMD string and make it safe to copy-paste by quoting arguments
  314. quoted_cmd = ' '.join(
  315. '"{}"'.format(arg) if ' ' in arg else arg
  316. for arg in result.cmd
  317. )
  318. if result.status == 'failed':
  319. if result.output.__class__.__name__ == 'TimeoutExpired':
  320. duration = (result.end_ts - result.start_ts).seconds
  321. hint_header = [
  322. '{lightyellow}Extractor timed out after {}s.{reset}'.format(duration, **ANSI),
  323. ]
  324. else:
  325. hint_header = [
  326. '{lightyellow}Extractor failed:{reset}'.format(**ANSI),
  327. ' {reset}{} {red}{}{reset}'.format(
  328. result.output.__class__.__name__.replace('ArchiveError', ''),
  329. result.output,
  330. **ANSI,
  331. ),
  332. ]
  333. # Prettify error output hints string and limit to five lines
  334. hints = getattr(result.output, 'hints', None) or ()
  335. if hints:
  336. hints = hints if isinstance(hints, (list, tuple)) else hints.split('\n')
  337. hints = (
  338. ' {}{}{}'.format(ANSI['lightyellow'], line.strip(), ANSI['reset'])
  339. for line in hints[:5] if line.strip()
  340. )
  341. # Collect and prefix output lines with indentation
  342. output_lines = [
  343. *hint_header,
  344. *hints,
  345. '{}Run to see full output:{}'.format(ANSI['lightred'], ANSI['reset']),
  346. *([' cd {};'.format(result.pwd)] if result.pwd else []),
  347. ' {}'.format(quoted_cmd),
  348. ]
  349. print('\n'.join(
  350. ' {}'.format(line)
  351. for line in output_lines
  352. if line
  353. ))
  354. print()
  355. def log_list_started(filter_patterns: Optional[List[str]], filter_type: str):
  356. print('{green}[*] Finding links in the archive index matching these {} patterns:{reset}'.format(
  357. filter_type,
  358. **ANSI,
  359. ))
  360. print(' {}'.format(' '.join(filter_patterns or ())))
  361. def log_list_finished(links):
  362. from .index.csv import links_to_csv
  363. print()
  364. print('---------------------------------------------------------------------------------------------------')
  365. print(links_to_csv(links, cols=['timestamp', 'is_archived', 'num_outputs', 'url'], header=True, ljust=16, separator=' | '))
  366. print('---------------------------------------------------------------------------------------------------')
  367. print()
  368. def log_removal_started(links: List["Link"], yes: bool, delete: bool):
  369. print('{lightyellow}[i] Found {} matching URLs to remove.{reset}'.format(len(links), **ANSI))
  370. if delete:
  371. file_counts = [link.num_outputs for link in links if Path(link.link_dir).exists()]
  372. print(
  373. f' {len(links)} Links will be de-listed from the main index, and their archived content folders will be deleted from disk.\n'
  374. f' ({len(file_counts)} data folders with {sum(file_counts)} archived files will be deleted!)'
  375. )
  376. else:
  377. print(
  378. ' Matching links will be de-listed from the main index, but their archived content folders will remain in place on disk.\n'
  379. ' (Pass --delete if you also want to permanently delete the data folders)'
  380. )
  381. if not yes:
  382. print()
  383. print('{lightyellow}[?] Do you want to proceed with removing these {} links?{reset}'.format(len(links), **ANSI))
  384. try:
  385. assert input(' y/[n]: ').lower() == 'y'
  386. except (KeyboardInterrupt, EOFError, AssertionError):
  387. raise SystemExit(0)
  388. def log_removal_finished(all_links: int, to_remove: int):
  389. if all_links == 0:
  390. print()
  391. print('{red}[X] No matching links found.{reset}'.format(**ANSI))
  392. else:
  393. print()
  394. print('{red}[√] Removed {} out of {} links from the archive index.{reset}'.format(
  395. to_remove,
  396. all_links,
  397. **ANSI,
  398. ))
  399. print(' Index now contains {} links.'.format(all_links - to_remove))
  400. def log_shell_welcome_msg():
  401. from .cli import list_subcommands
  402. print('{green}# ArchiveBox Imports{reset}'.format(**ANSI))
  403. print('{green}from core.models import Snapshot, User{reset}'.format(**ANSI))
  404. print('{green}from archivebox import *\n {}{reset}'.format("\n ".join(list_subcommands().keys()), **ANSI))
  405. print()
  406. print('[i] Welcome to the ArchiveBox Shell!')
  407. print(' https://github.com/ArchiveBox/ArchiveBox/wiki/Usage#Shell-Usage')
  408. print()
  409. print(' {lightred}Hint:{reset} Example use:'.format(**ANSI))
  410. print(' print(Snapshot.objects.filter(is_archived=True).count())')
  411. print(' Snapshot.objects.get(url="https://example.com").as_json()')
  412. print(' add("https://example.com/some/new/url")')
  413. ### Helpers
  414. @enforce_types
  415. def pretty_path(path: Union[Path, str]) -> str:
  416. """convert paths like .../ArchiveBox/archivebox/../output/abc into output/abc"""
  417. pwd = Path('.').resolve()
  418. # parent = os.path.abspath(os.path.join(pwd, os.path.pardir))
  419. return str(path).replace(str(pwd) + '/', './')
  420. @enforce_types
  421. def printable_filesize(num_bytes: Union[int, float]) -> str:
  422. for count in ['Bytes','KB','MB','GB']:
  423. if num_bytes > -1024.0 and num_bytes < 1024.0:
  424. return '%3.1f %s' % (num_bytes, count)
  425. num_bytes /= 1024.0
  426. return '%3.1f %s' % (num_bytes, 'TB')
  427. @enforce_types
  428. def printable_folders(folders: Dict[str, Optional["Link"]],
  429. with_headers: bool=False) -> str:
  430. return '\n'.join(
  431. f'{folder} {link and link.url} "{link and link.title}"'
  432. for folder, link in folders.items()
  433. )
  434. @enforce_types
  435. def printable_config(config: ConfigDict, prefix: str='') -> str:
  436. return f'\n{prefix}'.join(
  437. f'{key}={val}'
  438. for key, val in config.items()
  439. if not (isinstance(val, dict) or callable(val))
  440. )
  441. @enforce_types
  442. def printable_folder_status(name: str, folder: Dict) -> str:
  443. if folder['enabled']:
  444. if folder['is_valid']:
  445. color, symbol, note = 'green', '√', 'valid'
  446. else:
  447. color, symbol, note, num_files = 'red', 'X', 'invalid', '?'
  448. else:
  449. color, symbol, note, num_files = 'lightyellow', '-', 'disabled', '-'
  450. if folder['path']:
  451. if Path(folder['path']).exists():
  452. num_files = (
  453. f'{len(os.listdir(folder["path"]))} files'
  454. if Path(folder['path']).is_dir() else
  455. printable_filesize(Path(folder['path']).stat().st_size)
  456. )
  457. else:
  458. num_files = 'missing'
  459. path = str(folder['path']).replace(str(OUTPUT_DIR), '.') if folder['path'] else ''
  460. if path and ' ' in path:
  461. path = f'"{path}"'
  462. # if path is just a plain dot, replace it back with the full path for clarity
  463. if path == '.':
  464. path = str(OUTPUT_DIR)
  465. return ' '.join((
  466. ANSI[color],
  467. symbol,
  468. ANSI['reset'],
  469. name.ljust(21),
  470. num_files.ljust(14),
  471. ANSI[color],
  472. note.ljust(8),
  473. ANSI['reset'],
  474. path.ljust(76),
  475. ))
  476. @enforce_types
  477. def printable_dependency_version(name: str, dependency: Dict) -> str:
  478. version = None
  479. if dependency['enabled']:
  480. if dependency['is_valid']:
  481. color, symbol, note, version = 'green', '√', 'valid', ''
  482. parsed_version_num = re.search(r'[\d\.]+', dependency['version'])
  483. if parsed_version_num:
  484. version = f'v{parsed_version_num[0]}'
  485. if not version:
  486. color, symbol, note, version = 'red', 'X', 'invalid', '?'
  487. else:
  488. color, symbol, note, version = 'lightyellow', '-', 'disabled', '-'
  489. path = str(dependency["path"]).replace(str(OUTPUT_DIR), '.') if dependency["path"] else ''
  490. if path and ' ' in path:
  491. path = f'"{path}"'
  492. return ' '.join((
  493. ANSI[color],
  494. symbol,
  495. ANSI['reset'],
  496. name.ljust(21),
  497. version.ljust(14),
  498. ANSI[color],
  499. note.ljust(8),
  500. ANSI['reset'],
  501. path.ljust(76),
  502. ))