Skip to content

Commit

Permalink
fixed minor bug in aperture runner
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Berenz committed Dec 18, 2024
1 parent 1846188 commit cdb52f0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
Binary file added dist/nightskycam-0.1.14-py3-none-any.whl
Binary file not shown.
Binary file added dist/nightskycam-0.1.14.tar.gz
Binary file not shown.
38 changes: 27 additions & 11 deletions nightskycam/aperture/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@
from enum import Enum
from typing import Optional, cast

from nightskycam_focus.adapter import (MAX_FOCUS, MIN_FOCUS, Aperture, adapter,
set_aperture, set_focus)
from nightskycam_serialization.status import (ApertureRunnerEntries,
CamRunnerEntries)
from nightskycam_focus.adapter import (
MAX_FOCUS,
MIN_FOCUS,
Aperture,
adapter,
set_aperture,
set_focus,
)
from nightskycam_serialization.status import (
ApertureRunnerEntries,
CamRunnerEntries,
)
from nightskyrunner.config_getter import ConfigGetter
from nightskyrunner.runner import ThreadRunner, status_error
from nightskyrunner.status import Level, NoSuchStatusError, Status
Expand Down Expand Up @@ -117,13 +125,17 @@ def _open_aperture(self, focus: int, reason: str) -> None:
or self._focus != focus
or self._opening in (Opening.CLOSED, Opening.UNSET)
):
self.log(Level.info, f"opening aperture (focus: {focus}): {reason}")
self.log(
Level.info, f"opening aperture (focus: {focus}): {reason}"
)
try:
with adapter():
set_focus(focus)
set_aperture(Aperture.MAX)
except Exception as e:
raise RuntimeError(f"failed to set focus and open aperture: {e}")
raise RuntimeError(
f"failed to set focus and open aperture: {e}"
)
else:
self._opening = Opening.OPENED
self._focus = focus
Expand Down Expand Up @@ -171,8 +183,8 @@ def iterate(self) -> None:
)
status_entries["use_zwo_camera"] = use_zwo_camera
start = _to_time(str(config["start_time"]))
end = _to_time(str(config["end_time"]))
status_entries["time_window"] = f"{start} - {end}"
stop = _to_time(str(config["stop_time"]))
status_entries["time_window"] = f"{start} - {stop}"
try:
focus = config["focus"]
except KeyError:
Expand Down Expand Up @@ -200,13 +212,17 @@ def iterate(self) -> None:
active: Optional[bool] = self._camera_active()
if active is not None:
if active:
return self._return(status_entries, focus, True, "camera active")
return self._return(
status_entries, focus, True, "camera active"
)
else:
return self._return(status_entries, focus, False, "camera inactive")
return self._return(
status_entries, focus, False, "camera inactive"
)

# if not using use_zwo_camera, then must be using start/end time
time_now = datetime.now().time()
period_closed = _period_closed(start, end, time_now)
period_closed = _period_closed(start, stop, time_now)
if period_closed:
return self._return(status_entries, focus, False, "day")
else:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nightskycam"
version = "0.1.14"
version = "0.1.15"
description = "taking pictures at night"
authors = ["Vincent Berenz <[email protected]>"]
packages = [{ include = "nightskycam" }]
Expand Down

0 comments on commit cdb52f0

Please sign in to comment.