Skip to content

Commit

Permalink
small python improvements (--version)
Browse files Browse the repository at this point in the history
  • Loading branch information
orgua committed Mar 30, 2023
1 parent 2102918 commit 83c641a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
22 changes: 11 additions & 11 deletions software/python-package/shepherd/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,19 @@ def yamlprovider(file_path: str, cmd_name: str) -> dict:
default=2,
help="4 Levels, but level 4 has serious performance impact",
)
@click.option(
"--version",
is_flag=True,
help="Prints version-infos (combinable with -v)",
)
@click.pass_context
def cli(ctx: click.Context, verbose: int = 2):
"""Shepherd: Synchronized Energy Harvesting Emulator and Recorder
Args:
ctx:
verbose:
Returns:
"""
def cli(ctx: click.Context, verbose: int, version: bool):
"""Shepherd: Synchronized Energy Harvesting Emulator and Recorder"""
set_verbose_level(verbose)
logger.info("Shepherd-Sheep v%s", __version__)
logger.debug("Python v%s", sys.version)
logger.debug("Click v%s", click.__version__)
if version:
logger.info("Shepherd-Sheep v%s", __version__)
logger.debug("Python v%s", sys.version)
logger.debug("Click v%s", click.__version__)
if not ctx.invoked_subcommand:
click.echo("Please specify a valid command")

Expand Down
24 changes: 11 additions & 13 deletions software/shepherd-herd/shepherd_herd/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def yamlprovider(file_path: str, cmd_name: str):
help="Path to private ssh key file",
)
@click.option("-v", "--verbose", count=True, default=2)
@click.option(
"--version",
is_flag=True,
help="Prints version-infos (combinable with -v)",
)
@click.pass_context
def cli(
ctx: click.Context,
Expand All @@ -59,21 +64,14 @@ def cli(
user: Optional[str],
key_filepath: Optional[Path],
verbose: int,
version: bool,
) -> click.Context: # TODO: return type can be removed?!?
"""A primary set of options to configure how to interface the herd
:param ctx:
:param inventory:
:param limit:
:param user:
:param key_filepath:
:param verbose:
:return:
"""
"""A primary set of options to configure how to interface the herd"""
set_verbose_level(verbose)
logger.info("Shepherd-Data v%s", __version__)
logger.debug("Python v%s", sys.version)
logger.debug("Click v%s", click.__version__)
if version:
logger.info("Shepherd-Herd v%s", __version__)
logger.debug("Python v%s", sys.version)
logger.debug("Click v%s", click.__version__)
if not ctx.invoked_subcommand:
click.echo("Please specify a valid command")

Expand Down
4 changes: 3 additions & 1 deletion software/shepherd-herd/shepherd_herd/herd.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ def __init__(
raise ValueError("No remote targets found in list!")

def __del__(self):
# ... overcautious
# ... overcautious closing of connections
if not isinstance(self.group, Group):
return
with contextlib.suppress(TypeError):
for cnx in self.group:
cnx.close()
Expand Down

0 comments on commit 83c641a

Please sign in to comment.