diff --git a/pyscope/utils/pinpoint_solve.py b/pyscope/utils/pinpoint_solve.py index c23fbc50..254a0372 100644 --- a/pyscope/utils/pinpoint_solve.py +++ b/pyscope/utils/pinpoint_solve.py @@ -1,18 +1,22 @@ +import logging import os import time -import logging + import click from win32com.client import Dispatch logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) + def save_image(filepath): maxim.SaveFile(filepath, 3, False, 1) + def open_image(filepath): maxim.OpenFile(filepath) + def platesolve_image(filepath, new_filepath): open_image(filepath) maxim.PinPointSolve() @@ -20,20 +24,30 @@ def platesolve_image(filepath, new_filepath): while maxim.PinPointStatus == 3: time.sleep(0.1) if maxim.PinPointStatus == 2: - logger.info('Solve successful') + logger.info("Solve successful") else: - logger.info('Solve failed') + logger.info("Solve failed") maxim.PinPointStop() except Exception as e: - logger.error(f'Solve failed: {e}, saving unsolved image') + logger.error(f"Solve failed: {e}, saving unsolved image") save_image(new_filepath) - logger.info(f'Saved to {new_filepath}') + logger.info(f"Saved to {new_filepath}") + @click.command() -@click.argument('input_dir', type=click.Path(exists=True), - help="""Directory containing images to solve.""") -@click.option('-o','--out-dir','output_dir', default=None, type=click.Path(), - help="""Directory to save solved images to. If not specified, solved images will be saved to the same directory as the input images.""") +@click.argument( + "input_dir", + type=click.Path(exists=True), + help="""Directory containing images to solve.""", +) +@click.option( + "-o", + "--out-dir", + "output_dir", + default=None, + type=click.Path(), + help="""Directory to save solved images to. If not specified, solved images will be saved to the same directory as the input images.""", +) def pinpoint_solve(input_dir, output_dir=None): if output_dir is None: output_dir = input_dir @@ -51,5 +65,6 @@ def pinpoint_solve(input_dir, output_dir=None): for filepath, new_filepath in zip(day_filepaths, new_filepaths): platesolve_image(filepath, new_filepath) -if __name__ == '__main__': - pinpoint_solve() \ No newline at end of file + +if __name__ == "__main__": + pinpoint_solve()