text stringlengths 1 93.6k |
|---|
'''
|
with open(os.path.join(gi_dir, 'modscan.json'), 'w+') as golden_image_file:
|
golden_image_file.write(json.dumps(modscan.create_golden_image(machine_dict[vm]), indent=4))
|
'''
|
# Getting pslist golden image data
|
with open(os.path.join(gi_dir, 'pslist.json'), 'w+') as golden_image_file:
|
golden_image_file.write(json.dumps(get_new_pslist(memdump), indent=4))
|
print("[*] Done for Machine: {}".format(machine_dict[vm].machine_name))
|
print("[*] Done. Enjoy! ")
|
# <FILESEP>
|
#!/usr/bin/env python3
|
import logging
|
from pathlib import Path
|
import click
|
from rich.logging import RichHandler
|
from blinkist.blinkist import (get_free_daily, get_latest_books,
|
get_latest_collections, get_trending_books,
|
search_books)
|
from blinkist.book import Book # typing only
|
from blinkist.config import LANGUAGES
|
from blinkist.console import console, status, track, track_context
|
logging.basicConfig(
|
level=logging.DEBUG,
|
format="%(message)s",
|
datefmt="[%X]",
|
handlers=[RichHandler()],
|
)
|
logging.getLogger('urllib3').setLevel(logging.WARNING)
|
def download_book(
|
book: Book,
|
language: str,
|
library_dir: Path,
|
# ---
|
yaml: bool = True,
|
markdown: bool = True,
|
audio: bool = True,
|
cover: bool = True,
|
# ---
|
redownload: bool = False,
|
continue_on_error: bool = False,
|
# ---
|
**kwargs,
|
):
|
# check library directory
|
# This comes first so we can fail early if the path doesn't exist.
|
assert library_dir.exists()
|
# set up final book directory
|
book_dir = library_dir / book.slug
|
if book_dir.exists() and not redownload:
|
logging.info(f"Skipping “{book.title}” – already downloaded.")
|
# TODO: This doss not check if the download was complete! Can we do something about that?
|
return
|
if not redownload:
|
# set up temporary book directory
|
book_tmp_dir = book_dir.parent / f"{book.slug}.tmp"
|
i = 0
|
while book_tmp_dir.exists():
|
i += 1
|
book_tmp_dir = book_dir.parent / f"{book.slug}.tmp{i}"
|
book_tmp_dir.mkdir() # We don't make parents in order to avoid user error.
|
else:
|
# Work right in the (existing) final directory.
|
# This way, we never have to explicitly delete anything.
|
book_tmp_dir = book_dir
|
try:
|
# prefetch chapter_list and chapters for nicer progress info
|
with status("Retrieving list of chapters…"):
|
_ = book.chapter_list
|
# this displays a progress bar itself ↓
|
_ = book.chapters
|
# download raw (YAML)
|
# This comes first so we have all information saved as early as possible.
|
if yaml:
|
with status("Downloading raw YAML…"):
|
book.download_raw_yaml(book_tmp_dir)
|
# download text (Markdown)
|
if markdown:
|
with status("Downloading text…"):
|
book.download_text_md(book_tmp_dir)
|
# download audio
|
if audio:
|
if book.is_audio:
|
for chapter in track(book.chapters, description="Downloading audio…"):
|
chapter.download_audio(book_tmp_dir)
|
else:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.