panoptes.pocs.utils.cli package¶
Submodules¶
panoptes.pocs.utils.cli.camera module¶
Typer CLI commands for camera setup and quick image capture.
Provides helpers to detect connected cameras (DSLR via gphoto2 and ZWO via SDK), populate the configuration, and take one-off test images with optional post-processing (convert/compress/solve/pretty).
- class panoptes.pocs.utils.cli.camera.RecentFilesRenderable(recent_files_ref: list[str], show_max: int = 5)[source]¶
Bases:
objectRenderable that displays the 5 most recent completed file paths for a camera.
This reads directly from a shared list reference so that Rich’s Live re-render will always show the latest content without reconstructing the layout.
- panoptes.pocs.utils.cli.camera.process_image(process_queue: Queue, complete_queue: Queue, convert_flag: bool, compress_flag: bool, solve_flag: bool, pretty_flag: bool, verbose_flag: bool, per_cam_progress: dict)[source]¶
Process all the images that come into the queue until we receive a None.
- panoptes.pocs.utils.cli.camera.setup_cameras(detect_dslr: bool = True, detect_zwo: bool = True, asi_library_path: Path = None, test_image: bool = True) None[source]¶
Set up the config for the cameras.
Try to detect DSLRs via gphoto2.
- Try to detect ZWOs via ZWO SDK.
a). Look for filterwheel.
Update config options for camera.
Update camera with any initialization settings.
Take a test picture with each camera if test_image is True.
- panoptes.pocs.utils.cli.camera.take_bias_cmd(num_images: int = <typer.models.OptionInfo object>, output_dir: Path = <typer.models.OptionInfo object>, convert: bool = <typer.models.OptionInfo object>, verbose: bool = <typer.models.OptionInfo object>) None[source]¶
Take bias frames (zero exposure time), stack them, and report statistics.
Takes n bias frames with zero exposure time, stacks them into a master bias, and reports sigma-clipped mean, median, std, min, and max values.
- panoptes.pocs.utils.cli.camera.take_pictures(cameras: dict[str, AbstractCamera], num_images: int = 1, exptime: float | str = 1.0, output_dir: str = '/home/panoptes/images', delay: float = 0.0, convert: bool = False, compress: bool = False, solve: bool = False, pretty: bool = False, verbose: bool = False) dict[str, list[Path]] | None[source]¶
Capture images concurrently from one or more cameras with optional processing.
Spawns a thread pool to trigger exposures across all cameras and a background worker thread to perform post-processing steps (convert, compress, solve, pretty) as files are produced. A Rich Live layout displays per-camera progress and a list of the most recent files.
- Parameters:
cameras (dict[str, AbstractCamera]) – Mapping of camera names to instances.
num_images (int) – Number of images to take per camera. Defaults to 1.
exptime (float | str) – Exposure time in seconds (or string parsable to float).
output_dir (str) – Base directory where images will be written. A timestamped subdirectory is created automatically. Defaults to ‘/home/panoptes/images’.
delay (float) – Optional delay in seconds between exposures. Defaults to 0.0.
convert (bool) – If True, convert proprietary formats (e.g., CR2) to FITS.
compress (bool) – If True, compress FITS files to .fz via fpack.
solve (bool) – If True, run astrometric solving on FITS outputs.
pretty (bool) – If True, generate a PNG preview image.
verbose (bool) – If True, print additional processing details.
- Returns:
- Optional mapping of camera name to list of
produced files. Currently returns None; printed progress indicates completion.
- Return type:
- panoptes.pocs.utils.cli.camera.take_pictures_cmd(num_images: int = 1, exptime: float = 1.0, output_dir: str = '/home/panoptes/images', delay: float = 0.0, convert: bool = <typer.models.OptionInfo object>, compress: bool = <typer.models.OptionInfo object>, solve: bool = <typer.models.OptionInfo object>, pretty: bool = <typer.models.OptionInfo object>, verbose: bool = <typer.models.OptionInfo object>) dict[str, list[Path]] | None[source]¶
Takes pictures with cameras and optionally processes them.
panoptes.pocs.utils.cli.config module¶
Typer CLI helpers for interacting with the PANOPTES config server.
Provides commands to query and update configuration values via the running panoptes-utils config server, along with a status check and restart helper.
- class panoptes.pocs.utils.cli.config.HostInfo(*, host: str = '127.0.0.1', port: int = 6563, verbose: bool = False)[source]¶
Bases:
BaseModelMetadata for the Config Server
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- property url¶
Base URL of the config server.
- Returns:
Host and port combined as ‘host:port’.
- Return type:
- panoptes.pocs.utils.cli.config.get_value(key: str | None = <typer.models.ArgumentInfo object>, parse: bool = <typer.models.OptionInfo object>)[source]¶
Get an item from the config.
- Parameters:
key – The dotted-key of the config item to retrieve. If None, returns the full config.
parse – If True, parse the item into a native Python type when possible.
- Returns:
None
- panoptes.pocs.utils.cli.config.main(context: Context)[source]¶
Set up shared options and host info for the config CLI commands.
- Parameters:
context – Typer context used to access parent parameters (e.g., config host/port).
- Returns:
None
- panoptes.pocs.utils.cli.config.restart()[source]¶
Restart the config server process via supervisorctl.
- Returns:
None
- panoptes.pocs.utils.cli.config.set_value(key: str = <typer.models.ArgumentInfo object>, value: str = <typer.models.ArgumentInfo object>)[source]¶
Set an item in the config.
- Parameters:
key – The dotted-key of the config item to set.
value – The new value to set. Will be coerced to int/float if possible, otherwise kept as str.
- Returns:
None
panoptes.pocs.utils.cli.main module¶
panoptes.pocs.utils.cli.mount module¶
Typer CLI helpers for common mount operations (park, home, slew, setup).
Provides small interactive commands that call into the configured mount driver for safe parking, homing, slewing to a named target, and setting the park position. These commands are intended for manual use during setup or recovery.
- panoptes.pocs.utils.cli.mount.park_mount(confirm: Annotated[bool, <typer.models.OptionInfo object at 0x74512c771280>]=False)[source]¶
Parks the mount.
Warning: This will move the mount to the park position but will not do any safety checking. Please make sure the mount is safe to park before running this command.
- Parameters:
confirm – Set to True to skip the interactive confirmation prompt.
- Returns:
None
- panoptes.pocs.utils.cli.mount.search_for_home(confirm: Annotated[bool, <typer.models.OptionInfo object at 0x74512c770890>]=False)[source]¶
Search for the mount home position.
Warning: This will move the mount to the home position but will not do any safety checking. Please make sure the mount is safe to move before running this command.
- Parameters:
confirm – Set to True to skip the interactive confirmation prompt.
- Returns:
None
- panoptes.pocs.utils.cli.mount.set_park_position(confirm: Annotated[bool, <typer.models.OptionInfo object at 0x74512c770350>]=False)[source]¶
Set the current position as the park position.
Warning: This will move the mount to the park position but will not do any safety checking. Please make sure the mount is safe to move before running this command.
- Parameters:
confirm – Set to True to skip the interactive confirmation prompt.
- Returns:
None
- panoptes.pocs.utils.cli.mount.setup_mount(confirm: Annotated[bool, <typer.models.OptionInfo object at 0x74512c7709b0>]=False)[source]¶
Sets up the mount port, type, and firmware.
- panoptes.pocs.utils.cli.mount.slew_to_home(confirm: Annotated[bool, <typer.models.OptionInfo object at 0x74512c770560>]=False)[source]¶
Slew the mount to the home position.
Warning: This will move the mount to the home position but will not do any safety checking. Please make sure the mount is safe to move before running this command.
- Parameters:
confirm – Set to True to skip the interactive confirmation prompt.
- Returns:
None
- panoptes.pocs.utils.cli.mount.slew_to_target(confirm: Annotated[bool, <typer.models.OptionInfo object at 0x74512c770620>]=False, target: Annotated[str, <typer.models.OptionInfo object at 0x74512c7706b0>]=None, comet: Annotated[bool, <typer.models.OptionInfo object at 0x74512c770770>]=False)[source]¶
Slew the mount to a target by name and begin tracking.
- Parameters:
confirm – Set to True to skip the interactive confirmation prompt.
target – The name or coordinate string of the target to slew to.
comet – If True, search comet catalog for the given target name.
- Returns:
None
panoptes.pocs.utils.cli.network module¶
panoptes.pocs.utils.cli.notebook module¶
Typer CLI for managing a Jupyter server on a PANOPTES unit.
Provides commands to start Jupyter Lab/Notebook, set a password, and restart the supervised service.
- panoptes.pocs.utils.cli.notebook.restart()[source]¶
Restart the jupyter server process via supervisorctl
- panoptes.pocs.utils.cli.notebook.set_password(environment: str = <typer.models.OptionInfo object>)[source]¶
Set a password for the Jupyter server.
- Parameters:
environment (str) – Which frontend to configure: ‘lab’ or ‘notebook’. Defaults to ‘lab’.
- Returns:
None
- panoptes.pocs.utils.cli.notebook.start(environment: str = <typer.models.OptionInfo object>, public: bool = <typer.models.OptionInfo object>, port: int = <typer.models.OptionInfo object>, notebook_dir: Path = <typer.models.OptionInfo object>)[source]¶
Start a Jupyter server (Lab or classic Notebook).
- Parameters:
environment (str) – Which frontend to start: ‘lab’ or ‘notebook’. Defaults to ‘lab’.
public (bool) – If True, bind to 0.0.0.0 for remote access; otherwise localhost only.
port (int) – TCP port to listen on. Defaults to 8888.
notebook_dir (Path) – Directory to serve notebooks from. Defaults to $HOME.
- Returns:
None
panoptes.pocs.utils.cli.power module¶
Typer CLI for interacting with the power monitoring/control service.
Provides commands to query relay status and readings, and to toggle relays via HTTP calls to the FastAPI service implemented in panoptes.pocs.utils.service.power.
- class panoptes.pocs.utils.cli.power.HostInfo(host: str = 'localhost', port: str = '6564')[source]¶
Bases:
objectSimple host/port holder for the power service.
- panoptes.pocs.utils.cli.power.common(context: Context, host: str = <typer.models.OptionInfo object>, port: str = <typer.models.OptionInfo object>)[source]¶
Shared options setup for all power CLI commands.
- Parameters:
context – Typer context used to share HostInfo across commands.
host – Power service host address.
port – Power service TCP port.
- Returns:
None
- panoptes.pocs.utils.cli.power.control(context: Context, relay: str = <typer.models.OptionInfo object>, command: str = <typer.models.OptionInfo object>)[source]¶
Control a relay by label or relay index.
- Parameters:
context – Typer context with HostInfo state.
relay – Relay label or index to control.
command – Action to perform, either “turn_on” or “turn_off”.
- Returns:
None
- panoptes.pocs.utils.cli.power.off(context: Context, relay: str = <typer.models.ArgumentInfo object>)[source]¶
Turn a relay off by label or index.
- Parameters:
context – Typer context carrying HostInfo state.
relay – Relay label or index to control.
- Returns:
None
- panoptes.pocs.utils.cli.power.on(context: Context, relay: str = <typer.models.ArgumentInfo object>)[source]¶
Turn a relay on by label or index.
- Parameters:
context – Typer context carrying HostInfo state.
relay – Relay label or index to control.
- Returns:
None
- panoptes.pocs.utils.cli.power.readings(context: Context)[source]¶
Fetch and display recent readings for each relay.
- Parameters:
context – Typer context containing HostInfo with base URL.
- Returns:
None
- panoptes.pocs.utils.cli.power.setup_power(confirm: Annotated[bool, <typer.models.OptionInfo object at 0x74512c772300>]=False, arduino_device: str = <typer.models.OptionInfo object>)[source]¶
Set up the power board port and labels; optionally install Arduino sketch.
- Parameters:
confirm – Confirmation flag to proceed with setup.
arduino_device – Path to the Arduino device for uploading the sketch.
- Returns:
None
panoptes.pocs.utils.cli.run module¶
panoptes.pocs.utils.cli.sensor module¶
Typer CLI for monitoring remote sensors exposed via HTTP endpoints.
- panoptes.pocs.utils.cli.sensor.main(context: Context)[source]¶
Common options setup for all sensor CLI commands.
- Parameters:
context – Typer context used to access shared options.
- Returns:
None
- panoptes.pocs.utils.cli.sensor.monitor(sensor_name: str, endpoint: str | None = <typer.models.OptionInfo object>, store: bool = <typer.models.OptionInfo object>, read_frequency: int = <typer.models.OptionInfo object>, verbose: bool = False)[source]¶
Continuously read a remote sensor, optionally storing results.
- Parameters:
sensor_name – Name of the sensor (used for looking up default endpoint in config).
endpoint – Optional override for the sensor endpoint URL.
store – If True, persist readings to the local JSON database.
read_frequency – Polling interval in seconds between readings.
verbose – If True, echo readings to the console.
- Returns:
None
panoptes.pocs.utils.cli.weather module¶
Typer CLI for interacting with the PANOPTES weather station service.
Provides commands to query status/config and to restart the service.
- class panoptes.pocs.utils.cli.weather.HostInfo(host: str = 'localhost', port: str = '6566')[source]¶
Bases:
objectClass to store and manage weather station host information.
This class stores the host and port information for a weather station and provides a property to generate the complete URL.
- panoptes.pocs.utils.cli.weather.common(context: Context, host: str = <typer.models.OptionInfo object>, port: str = <typer.models.OptionInfo object>)[source]¶
Common callback for all commands in the weather CLI.
This function sets up the context object with host information that will be available to all commands in the CLI application.
- Parameters:
context – The Typer context object
host – The hostname or IP address of the weather station
port – The port number the weather station is listening on
- panoptes.pocs.utils.cli.weather.config(context: Context, page='config')[source]¶
Get the configuration of the weather station.
This command retrieves the configuration settings from the weather station and prints them to the console in their raw JSON format.
- Parameters:
context – The Typer context object containing the host information
page – The API endpoint to query (defaults to ‘config’)
- Returns:
This function prints the configuration data to the console
- Return type:
None
- panoptes.pocs.utils.cli.weather.display_weather_table(data: dict)[source]¶
Display weather data in a formatted table.
This function takes weather data in dictionary format and displays it in a nicely formatted table using the Rich library. The table includes information about temperatures, wind speed, and various safety conditions (cloud, wind, rain). The table is color-coded based on safety status (green for safe, red for unsafe).
- Parameters:
data – A dictionary containing weather data with keys such as ‘is_safe’, ‘ambient_temp’, ‘sky_temp’, ‘wind_speed’, ‘cloud_condition’, ‘wind_condition’, ‘rain_condition’, ‘timestamp’, etc.
- Returns:
This function prints the formatted table to the console
- Return type:
None
Note
The table’s title color is determined by the ‘is_safe’ value in the data. Individual rows for cloud, wind, and rain conditions are also color-coded based on their respective safety status.
- panoptes.pocs.utils.cli.weather.get_page(page, base_url)[source]¶
Get JSON data from the specified page on the weather station.
This function makes an HTTP request to the weather station API and returns the JSON response. It handles various error conditions that might occur during the request, providing helpful error messages and suggestions.
- Parameters:
page – The endpoint to access (e.g., ‘status’, ‘config’)
base_url – The base URL of the weather station
- Returns:
The parsed JSON data from the response
- Return type:
- Raises:
SystemExit – If the request fails for any reason, with appropriate error messages printed to the console before exiting
Note
This function has a timeout of 10 seconds for the HTTP request. If the request times out or fails, it will print a helpful error message with possible reasons and solutions before exiting.
- panoptes.pocs.utils.cli.weather.restart(service: str = 'pocs-weather-reader')[source]¶
Restart the weather station service via supervisorctl.
This command uses the supervisorctl utility to restart the specified service. It’s useful when the weather station service is not responding or needs to be refreshed after configuration changes.
- Parameters:
service – The name of the service to restart (defaults to ‘pocs-weather-reader’)
- Returns:
This function executes the restart command and prints the command being run
- Return type:
None
Note
This command requires that supervisor is installed and configured on the system, and that the user has appropriate permissions to restart services.
- panoptes.pocs.utils.cli.weather.status(context: Context, page='status', show_raw_values: bool = False)[source]¶
Get the status of the weather station.
This command retrieves the latest weather data from the weather station and displays it in a formatted table on the command line. The table includes information about temperature, wind speed, cloud/wind/rain conditions, and their safety status.
- Parameters:
context – The Typer context object containing the host information
page – The API endpoint to query (defaults to ‘status’)
show_raw_values – If True, prints the raw JSON data instead of a formatted table
- Returns:
This function prints the weather data to the console
- Return type:
None