Skip to content

Commit

Permalink
ran black and isort
Browse files Browse the repository at this point in the history
  • Loading branch information
pgriffin17 committed Jan 11, 2024
1 parent a4c6224 commit 46dfb14
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions pyscope/utils/pinpoint_solve.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,53 @@
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()
try:
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
Expand All @@ -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()

if __name__ == "__main__":
pinpoint_solve()

0 comments on commit 46dfb14

Please sign in to comment.