diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-11 09:25:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-12 05:31:22 +0000 |
commit | 7ad1d0e0af695fa7f872b740a1bb7b2897eb41bd (patch) | |
tree | 13dd59a8ea98206a8c56ffd466f59c146f9f19c7 /eos_downloader/cli/debug | |
parent | Initial commit. (diff) | |
download | eos-downloader-7ad1d0e0af695fa7f872b740a1bb7b2897eb41bd.tar.xz eos-downloader-7ad1d0e0af695fa7f872b740a1bb7b2897eb41bd.zip |
Adding upstream version 0.8.1.upstream/0.8.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'eos_downloader/cli/debug')
-rw-r--r-- | eos_downloader/cli/debug/__init__.py | 0 | ||||
-rw-r--r-- | eos_downloader/cli/debug/commands.py | 53 |
2 files changed, 53 insertions, 0 deletions
diff --git a/eos_downloader/cli/debug/__init__.py b/eos_downloader/cli/debug/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/eos_downloader/cli/debug/__init__.py diff --git a/eos_downloader/cli/debug/commands.py b/eos_downloader/cli/debug/commands.py new file mode 100644 index 0000000..107b8a0 --- /dev/null +++ b/eos_downloader/cli/debug/commands.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +# coding: utf-8 -*- +# pylint: disable=no-value-for-parameter +# pylint: disable=too-many-arguments +# pylint: disable=line-too-long +# pylint: disable=duplicate-code +# flake8: noqa E501 + +""" +Commands for ARDL CLI to get data. +""" + +import xml.etree.ElementTree as ET +from xml.dom import minidom + +import click +from loguru import logger +from rich.console import Console + +import eos_downloader.eos + + +@click.command() +@click.pass_context +@click.option('--output', default=str('arista.xml'), help='Path to save XML file', type=click.Path(), show_default=True) +@click.option('--log-level', '--log', help='Logging level of the command', default=None, type=click.Choice(['debug', 'info', 'warning', 'error', 'critical'], case_sensitive=False)) +def xml(ctx: click.Context, output: str, log_level: str) -> None: + # sourcery skip: remove-unnecessary-cast + """Extract XML directory structure""" + console = Console() + # Get from Context + token = ctx.obj['token'] + + logger.remove() + if log_level is not None: + logger.add("eos-downloader.log", rotation="10 MB", level=log_level.upper()) + + my_download = eos_downloader.eos.EOSDownloader( + image='unset', + software='EOS', + version='unset', + token=token, + hash_method='sha512sum') + + my_download.authenticate() + xml_object: ET.ElementTree = my_download._get_folder_tree() # pylint: disable=protected-access + xml_content = xml_object.getroot() + + xmlstr = minidom.parseString(ET.tostring(xml_content)).toprettyxml(indent=" ", newl='') + with open(output, "w", encoding='utf-8') as f: + f.write(str(xmlstr)) + + console.print(f'XML file saved in: { output }') |