From 918e5fa306207cf98de1ba9e1979ea39efe3495c Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Wed, 9 Jun 2021 17:31:06 -0700 Subject: [PATCH] Display banner --- RELEASE.md | 2 +- dangerzone/__init__.py | 2 - dangerzone/cli.py | 167 ++++++++++++++++++++++++++++++++++++ dangerzone/global_common.py | 4 + poetry.lock | 2 +- pyproject.toml | 1 + setup.py | 11 ++- share/version.txt | 1 + 8 files changed, 183 insertions(+), 7 deletions(-) create mode 100644 share/version.txt diff --git a/RELEASE.md b/RELEASE.md index b2022d8..b745021 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -7,7 +7,7 @@ This section documents the release process. Unless you're a dangerzone developer Before making a release, all of these should be complete: * Update `version` in `pyproject.toml` -* Update `dangerzone_version` in `dangerzone/__init__.py` +* Update in `share/version.txt` * Update version and download links in `README.md` * CHANGELOG.md should be updated to include a list of all major changes since the last release * There must be a PGP-signed git tag for the version, e.g. for dangerzone 0.1.0, the tag must be `v0.1.0` diff --git a/dangerzone/__init__.py b/dangerzone/__init__.py index 8021fc4..d89750d 100644 --- a/dangerzone/__init__.py +++ b/dangerzone/__init__.py @@ -1,8 +1,6 @@ import os import sys -dangerzone_version = "0.1.5" - # Depending on the filename, decide if we want to run: # dangerzone, dangerzone-cli, or dangerzone-container diff --git a/dangerzone/cli.py b/dangerzone/cli.py index a9ed940..27f66ca 100644 --- a/dangerzone/cli.py +++ b/dangerzone/cli.py @@ -1,9 +1,174 @@ import os import shutil import click +import colorama +from colorama import Fore, Back, Style from .global_common import GlobalCommon from .common import Common +from dangerzone import global_common + + +def display_banner(global_common): + """ + Raw ASCII art example: + ╭──────────────────────────╮ + │ ▄██▄ │ + │ ██████ │ + │ ███▀▀▀██ │ + │ ███ ████ │ + │ ███ ██████ │ + │ ███ ▀▀▀▀████ │ + │ ███████ ▄██████ │ + │ ███████ ▄█████████ │ + │ ████████████████████ │ + │ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ │ + │ │ + │ Dangerzone v0.1.5 │ + │ https://dangerzone.rocks │ + ╰──────────────────────────╯ + """ + colorama.init(autoreset=True) + print(Fore.YELLOW + Style.DIM + "╭──────────────────────────╮") + print( + Fore.YELLOW + + Style.DIM + + "│" + + Fore.LIGHTYELLOW_EX + + Style.NORMAL + + " ▄██▄ " + + Fore.YELLOW + + Style.DIM + + "│" + ) + print( + Fore.YELLOW + + Style.DIM + + "│" + + Fore.LIGHTYELLOW_EX + + Style.NORMAL + + " ██████ " + + Fore.YELLOW + + Style.DIM + + "│" + ) + print( + Fore.YELLOW + + Style.DIM + + "│" + + Fore.LIGHTYELLOW_EX + + Style.NORMAL + + " ███▀▀▀██ " + + Fore.YELLOW + + Style.DIM + + "│" + ) + print( + Fore.YELLOW + + Style.DIM + + "│" + + Fore.LIGHTYELLOW_EX + + Style.NORMAL + + " ███ ████ " + + Fore.YELLOW + + Style.DIM + + "│" + ) + print( + Fore.YELLOW + + Style.DIM + + "│" + + Fore.LIGHTYELLOW_EX + + Style.NORMAL + + " ███ ██████ " + + Fore.YELLOW + + Style.DIM + + "│" + ) + print( + Fore.YELLOW + + Style.DIM + + "│" + + Fore.LIGHTYELLOW_EX + + Style.NORMAL + + " ███ ▀▀▀▀████ " + + Fore.YELLOW + + Style.DIM + + "│" + ) + print( + Fore.YELLOW + + Style.DIM + + "│" + + Fore.LIGHTYELLOW_EX + + Style.NORMAL + + " ███████ ▄██████ " + + Fore.YELLOW + + Style.DIM + + "│" + ) + print( + Fore.YELLOW + + Style.DIM + + "│" + + Fore.LIGHTYELLOW_EX + + Style.NORMAL + + " ███████ ▄█████████ " + + Fore.YELLOW + + Style.DIM + + "│" + ) + print( + Fore.YELLOW + + Style.DIM + + "│" + + Fore.LIGHTYELLOW_EX + + Style.NORMAL + + " ████████████████████ " + + Fore.YELLOW + + Style.DIM + + "│" + ) + print( + Fore.YELLOW + + Style.DIM + + "│" + + Fore.LIGHTYELLOW_EX + + Style.NORMAL + + " ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ " + + Fore.YELLOW + + Style.DIM + + "│" + ) + print(Fore.YELLOW + Style.DIM + "│ │") + left_spaces = (15 - len(global_common.version) - 1) // 2 + right_spaces = left_spaces + if left_spaces + len(global_common.version) + 1 + right_spaces < 15: + right_spaces += 1 + print( + Fore.YELLOW + + Style.DIM + + "│" + + Fore.LIGHTWHITE_EX + + Style.RESET_ALL + + Style.BRIGHT + + f"{' '*left_spaces}Dangerzone v{global_common.version}{' '*right_spaces}" + + Fore.YELLOW + + Style.DIM + + "│" + ) + print( + Fore.YELLOW + + Style.DIM + + "│" + + Fore.LIGHTWHITE_EX + + Style.RESET_ALL + + " https://dangerzone.rocks " + + Fore.YELLOW + + Style.DIM + + "│" + ) + print(Fore.YELLOW + Style.DIM + "╰──────────────────────────╯") def exec_container(global_common, args): @@ -40,6 +205,8 @@ def cli_main(custom_container, safe_pdf_filename, ocr_lang, skip_update, filenam global_common = GlobalCommon() common = Common() + display_banner(global_common) + # Validate filename valid = True try: diff --git a/dangerzone/global_common.py b/dangerzone/global_common.py index 2a4f6ad..47a21e2 100644 --- a/dangerzone/global_common.py +++ b/dangerzone/global_common.py @@ -16,6 +16,10 @@ class GlobalCommon(object): """ def __init__(self): + # Version + with open(self.get_resource_path("version.txt")) as f: + self.version = f.read().strip() + # App data folder self.appdata_path = appdirs.user_config_dir("dangerzone") diff --git a/poetry.lock b/poetry.lock index 27e525f..94a767c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -374,7 +374,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pyt [metadata] lock-version = "1.1" python-versions = ">=3.7,<3.10" -content-hash = "26e6acc883dad4194c45e399fadaabc12730fdd3a7b2264737e4e81838183eee" +content-hash = "72592722794667cf7cb6bea727b31eb60d710c90d488be9d10a13bbbcaa56688" [metadata.files] altgraph = [ diff --git a/pyproject.toml b/pyproject.toml index 0803dbb..860a048 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,7 @@ wmi = {version = "*", platform = "win32"} pyxdg = {version = "*", platform = "linux"} pyobjc-core = {version = "*", platform = "darwin"} pyobjc-framework-launchservices = {version = "*", platform = "darwin"} +colorama = "^0.4.4" [tool.poetry.dev-dependencies] pyinstaller = {version = "*", platform = "darwin"} diff --git a/setup.py b/setup.py index 21a4741..2edcca2 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,9 @@ import setuptools import os import sys -from dangerzone import dangerzone_version + +with open("share/version.txt") as f: + version = f.read().strip() def file_list(path): @@ -15,7 +17,7 @@ def file_list(path): setuptools.setup( name="dangerzone", - version=dangerzone_version, + version=version, author="Micah Lee", author_email="micah.lee@theintercept.com", license="MIT", @@ -23,7 +25,10 @@ setuptools.setup( url="https://github.com/firstlookmedia/dangerzone", packages=["dangerzone"], data_files=[ - ("share/applications", ["install/linux/media.firstlook.dangerzone.desktop"],), + ( + "share/applications", + ["install/linux/media.firstlook.dangerzone.desktop"], + ), ( "share/icons/hicolor/64x64/apps", ["install/linux/media.firstlook.dangerzone.png"], diff --git a/share/version.txt b/share/version.txt new file mode 100644 index 0000000..2f45361 --- /dev/null +++ b/share/version.txt @@ -0,0 +1 @@ +0.2 \ No newline at end of file