Skip to content

Commit

Permalink
Removed most code
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Nov 23, 2023
1 parent b2c4a62 commit fd6198e
Show file tree
Hide file tree
Showing 45 changed files with 92 additions and 3,464 deletions.
78 changes: 33 additions & 45 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ classifiers = [
packages = [
{ include = "lvmnps", from = "src" }
]
include = ["python/lvmnps/etc/*"]
include = ["src/lvmnps/actor/schema.json"]

[tool.poetry.scripts]
lvmnps = "lvmnps.__main__:main"
Expand All @@ -34,7 +34,7 @@ python = ">=3.8,<4.0"
sdsstools = "^1.0.0"
click-default-group = "^1.2.2"
sdss-clu = "^2.0.0"
httpx = "^0.18.1"
httpx = ">=0.18.1"

[tool.poetry.group.dev.dependencies]
ipython = ">=7.11.0"
Expand Down Expand Up @@ -92,7 +92,7 @@ asyncio_mode = "auto"
branch = true
disable_warnings = ["include-ignored"]
omit = [
"python/lvmnps/__main__.py",
"src/lvmnps/__main__.py",
]

[tool.coverage.report]
Expand Down
5 changes: 1 addition & 4 deletions src/lvmnps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
from sdsstools import get_config, get_logger, get_package_version


# pip package name
NAME = "sdss-lvmnps"

# Loads config. config name is the package name.
config = get_config("lvmnps")

log = get_logger(NAME)

# package name should be pip package name
__version__ = get_package_version(path=__file__, package_name=NAME)
36 changes: 6 additions & 30 deletions src/lvmnps/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,20 @@ def wrapper(*args, **kwargs):
"--config",
"config_file",
type=click.Path(exists=True, dir_okay=False),
required=True,
help="Path to the user configuration file.",
)
@click.option(
"-r",
"--rmq_url",
"rmq_url",
default=None,
type=str,
help="rabbitmq url, eg: amqp://guest:guest@localhost:5672/",
)
@click.option(
"-v",
"--verbose",
count=True,
help="Debug mode. Use additional v for more details.",
)
@click.option(
"-s",
"--simulate",
count=True,
help="Simulation mode. Overwrite configured nps device with a dummy device",
)
@click.pass_context
def lvmnps(ctx, config_file, rmq_url, verbose, simulate):
"""Nps Actor."""
def lvmnps(ctx: click.Context, config_file: str, verbose: bool = False):
"""Network Power Supply actor."""

ctx.obj = {
"verbose": verbose,
"config_file": config_file,
"rmq_url": rmq_url,
"simulate": simulate,
}
ctx.obj = {"verbose": verbose, "config_file": config_file}


@lvmnps.group(cls=DaemonGroup, prog="nps_actor", workdir=os.getcwd())
Expand All @@ -69,15 +51,9 @@ def lvmnps(ctx, config_file, rmq_url, verbose, simulate):
async def actor(ctx):
"""Runs the actor."""

default_config_file = os.path.join(os.path.dirname(__file__), "etc/lvmnps.yml")
config_file = ctx.obj["config_file"] or default_config_file
config_file = ctx.obj["config_file"]

lvmnps = NPSActor.from_config(
config_file,
url=ctx.obj["rmq_url"],
verbose=ctx.obj["verbose"],
simulate=ctx.obj["simulate"],
)
lvmnps = NPSActor.from_config(config_file, verbose=ctx.obj["verbose"])

if ctx.obj["verbose"]:
if lvmnps.log.fh:
Expand Down
Loading

0 comments on commit fd6198e

Please sign in to comment.