From 859f207c998291c6f2302c7f156dc9e051c5288f Mon Sep 17 00:00:00 2001 From: jamessynge Date: Sun, 24 Dec 2017 18:54:36 -0500 Subject: [PATCH] Replace file-relative imports with root-relative imports. Add some imports to __init__.py files so that the root-relative imports of the typical AbstractBaseClass doesn't look like: from pocs.foo.foo import AbstractFoo. Fix a typo. --- pocs/__init__.py | 2 +- pocs/camera/__init__.py | 2 ++ pocs/camera/camera.py | 12 ++++++------ pocs/camera/canon_gphoto2.py | 8 ++++---- pocs/camera/sbig.py | 10 +++++----- pocs/camera/sbigudrv.py | 2 +- pocs/camera/simulator.py | 4 ++-- pocs/focuser/__init__.py | 1 + pocs/focuser/birger.py | 2 +- pocs/focuser/focuser.py | 6 +++--- pocs/focuser/simulator.py | 2 +- pocs/images.py | 4 ++-- pocs/mount/__init__.py | 1 + pocs/mount/bisque.py | 6 +++--- pocs/mount/ioptron.py | 6 +++--- pocs/mount/mount.py | 4 ++-- pocs/mount/serial.py | 6 +++--- pocs/mount/simulator.py | 4 ++-- pocs/observatory.py | 18 +++++++++--------- pocs/scheduler/__init__.py | 1 + pocs/scheduler/constraint.py | 2 +- pocs/scheduler/dispatch.py | 6 +++--- pocs/scheduler/observation.py | 4 ++-- pocs/scheduler/scheduler.py | 8 ++++---- pocs/state/machine.py | 6 +++--- pocs/state/states/default/observing.py | 2 +- pocs/state/states/default/pointing.py | 4 ++-- pocs/tests/test_base_scheduler.py | 2 +- pocs/utils/__init__.py | 2 +- pocs/utils/error.py | 2 +- pocs/utils/logger.py | 2 +- pocs/utils/rs232.py | 4 ++-- 32 files changed, 75 insertions(+), 70 deletions(-) diff --git a/pocs/__init__.py b/pocs/__init__.py index a4d6a2aa7..8abaa479a 100644 --- a/pocs/__init__.py +++ b/pocs/__init__.py @@ -2,7 +2,7 @@ """ Panoptes Observatory Control System (POCS) is a library for controlling a PANOPTES hardware unit. POCS provides complete automation of all observing -processes and is inteded to be run in an automated fashion. +processes and is intended to be run in an automated fashion. """ from __future__ import absolute_import diff --git a/pocs/camera/__init__.py b/pocs/camera/__init__.py index e69de29bb..e3a70c086 100644 --- a/pocs/camera/__init__.py +++ b/pocs/camera/__init__.py @@ -0,0 +1,2 @@ +from pocs.camera.camera import AbstractCamera +from pocs.camera.camera import AbstractGPhotoCamera diff --git a/pocs/camera/camera.py b/pocs/camera/camera.py index b61794071..d0e74bcd2 100644 --- a/pocs/camera/camera.py +++ b/pocs/camera/camera.py @@ -1,11 +1,11 @@ -from .. import PanBase +from pocs import PanBase -from ..utils import error -from ..utils import listify -from ..utils import load_module -from ..utils import images +from pocs.utils import error +from pocs.utils import listify +from pocs.utils import load_module +from pocs.utils import images -from ..focuser.focuser import AbstractFocuser +from pocs.focuser import AbstractFocuser from astropy.io import fits diff --git a/pocs/camera/canon_gphoto2.py b/pocs/camera/canon_gphoto2.py index 41707a9d9..f158615e3 100644 --- a/pocs/camera/canon_gphoto2.py +++ b/pocs/camera/canon_gphoto2.py @@ -5,10 +5,10 @@ from threading import Event from threading import Timer -from ..utils import current_time -from ..utils import error -from ..utils import images -from .camera import AbstractGPhotoCamera +from pocs.utils import current_time +from pocs.utils import error +from pocs.utils import images +from pocs.camera import AbstractGPhotoCamera class Camera(AbstractGPhotoCamera): diff --git a/pocs/camera/sbig.py b/pocs/camera/sbig.py index ed78f2e99..6bfc4de6a 100644 --- a/pocs/camera/sbig.py +++ b/pocs/camera/sbig.py @@ -4,11 +4,11 @@ from astropy import units as u from astropy.io import fits -from ..utils import current_time -from ..utils import images -from .camera import AbstractCamera -from .sbigudrv import INVALID_HANDLE_VALUE -from .sbigudrv import SBIGDriver +from pocs.utils import current_time +from pocs.utils import images +from pocs.camera import AbstractCamera +from pocs.camera.sbigudrv import INVALID_HANDLE_VALUE +from pocs.camera.sbigudrv import SBIGDriver from pocs.focuser.birger import Focuser as BirgerFocuser diff --git a/pocs/camera/sbigudrv.py b/pocs/camera/sbigudrv.py index f9370a846..4f26dd519 100644 --- a/pocs/camera/sbigudrv.py +++ b/pocs/camera/sbigudrv.py @@ -22,7 +22,7 @@ from astropy.io import fits from astropy.time import Time -from .. import PanBase +from pocs import PanBase ################################################################################ diff --git a/pocs/camera/simulator.py b/pocs/camera/simulator.py index f2f4823a8..4eb0e6e40 100644 --- a/pocs/camera/simulator.py +++ b/pocs/camera/simulator.py @@ -10,9 +10,9 @@ from astropy.io import fits from astropy.time import Time -from ..utils import current_time +from pocs.utils import current_time -from .camera import AbstractCamera +from pocs.camera import AbstractCamera class Camera(AbstractCamera): diff --git a/pocs/focuser/__init__.py b/pocs/focuser/__init__.py index e69de29bb..29fc26e4d 100644 --- a/pocs/focuser/__init__.py +++ b/pocs/focuser/__init__.py @@ -0,0 +1 @@ +from pocs.focuser.focuser import AbstractFocuser diff --git a/pocs/focuser/birger.py b/pocs/focuser/birger.py index 96583e5bc..d8d5036d0 100644 --- a/pocs/focuser/birger.py +++ b/pocs/focuser/birger.py @@ -4,7 +4,7 @@ import time import glob -from pocs.focuser.focuser import AbstractFocuser +from pocs.focuser import AbstractFocuser # Birger adaptor serial numbers should be 5 digits serial_number_pattern = re.compile('^\d{5}$') diff --git a/pocs/focuser/focuser.py b/pocs/focuser/focuser.py index 2984abc78..982b60764 100644 --- a/pocs/focuser/focuser.py +++ b/pocs/focuser/focuser.py @@ -10,9 +10,9 @@ from threading import Thread -from .. import PanBase -from ..utils import current_time -from ..utils import images +from pocs import PanBase +from pocs.utils import current_time +from pocs.utils import images palette = copy(plt.cm.cubehelix) palette.set_over('w', 1.0) diff --git a/pocs/focuser/simulator.py b/pocs/focuser/simulator.py index d0afeaabd..caa89c4cb 100644 --- a/pocs/focuser/simulator.py +++ b/pocs/focuser/simulator.py @@ -1,4 +1,4 @@ -from .focuser import AbstractFocuser +from pocs.focuser import AbstractFocuser import time import random diff --git a/pocs/images.py b/pocs/images.py index 03f756c8e..04f4c9cf6 100644 --- a/pocs/images.py +++ b/pocs/images.py @@ -9,8 +9,8 @@ from astropy.time import Time from collections import namedtuple -from . import PanBase -from .utils import images as img_utils +from pocs import PanBase +from pocs.utils import images as img_utils OffsetError = namedtuple('OffsetError', ['delta_ra', 'delta_dec', 'magnitude']) diff --git a/pocs/mount/__init__.py b/pocs/mount/__init__.py index e69de29bb..4c53a5cbc 100644 --- a/pocs/mount/__init__.py +++ b/pocs/mount/__init__.py @@ -0,0 +1 @@ +from pocs.mount.mount import AbstractMount diff --git a/pocs/mount/bisque.py b/pocs/mount/bisque.py index e954ce0dd..d174da5a8 100644 --- a/pocs/mount/bisque.py +++ b/pocs/mount/bisque.py @@ -7,10 +7,10 @@ from astropy.coordinates import SkyCoord from string import Template -from ..utils import error -from ..utils import theskyx +from pocs.utils import error +from pocs.utils import theskyx -from .mount import AbstractMount +from pocs.mount import AbstractMount class Mount(AbstractMount): diff --git a/pocs/mount/ioptron.py b/pocs/mount/ioptron.py index 5c45da54d..56954e1dc 100644 --- a/pocs/mount/ioptron.py +++ b/pocs/mount/ioptron.py @@ -4,9 +4,9 @@ from astropy import units as u from astropy.coordinates import SkyCoord -from ..utils import current_time -from ..utils import error as error -from .serial import AbstractSerialMount +from pocs.utils import current_time +from pocs.utils import error as error +from pocs.mount.serial import AbstractSerialMount class Mount(AbstractSerialMount): diff --git a/pocs/mount/mount.py b/pocs/mount/mount.py index 0773d111e..0c9e308aa 100644 --- a/pocs/mount/mount.py +++ b/pocs/mount/mount.py @@ -6,8 +6,8 @@ from pocs import PanBase -from ..utils import current_time -from ..utils import error +from pocs.utils import current_time +from pocs.utils import error class AbstractMount(PanBase): diff --git a/pocs/mount/serial.py b/pocs/mount/serial.py index 078075335..370bdc217 100644 --- a/pocs/mount/serial.py +++ b/pocs/mount/serial.py @@ -1,10 +1,10 @@ import os import yaml -from ..utils import error -from ..utils import rs232 +from pocs.utils import error +from pocs.utils import rs232 -from .mount import AbstractMount +from pocs.mount import AbstractMount class AbstractSerialMount(AbstractMount): diff --git a/pocs/mount/simulator.py b/pocs/mount/simulator.py index aaffcc892..859ad14df 100644 --- a/pocs/mount/simulator.py +++ b/pocs/mount/simulator.py @@ -1,7 +1,7 @@ import time -from ..utils import current_time -from .mount import AbstractMount +from pocs.utils import current_time +from pocs.mount import AbstractMount class Mount(AbstractMount): diff --git a/pocs/observatory.py b/pocs/observatory.py index aeefaf844..85d69bdf9 100644 --- a/pocs/observatory.py +++ b/pocs/observatory.py @@ -11,16 +11,16 @@ from astropy.coordinates import get_moon from astropy.coordinates import get_sun -from . import PanBase +from pocs import PanBase import pocs.dome -from .images import Image -from .scheduler.constraint import Duration -from .scheduler.constraint import MoonAvoidance -from .utils import current_time -from .utils import error -from .utils import images as img_utils -from .utils import list_connected_cameras -from .utils import load_module +from pocs.images import Image +from pocs.scheduler.constraint import Duration +from pocs.scheduler.constraint import MoonAvoidance +from pocs.utils import current_time +from pocs.utils import error +from pocs.utils import images as img_utils +from pocs.utils import list_connected_cameras +from pocs.utils import load_module class Observatory(PanBase): diff --git a/pocs/scheduler/__init__.py b/pocs/scheduler/__init__.py index e69de29bb..6607e13e6 100644 --- a/pocs/scheduler/__init__.py +++ b/pocs/scheduler/__init__.py @@ -0,0 +1 @@ +from pocs.scheduler.scheduler import BaseScheduler diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index 5a6229660..3907baaa3 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -1,6 +1,6 @@ from astropy import units as u -from .. import PanBase +from pocs import PanBase class BaseConstraint(PanBase): diff --git a/pocs/scheduler/dispatch.py b/pocs/scheduler/dispatch.py index ac60f8ef6..e965a0fcc 100644 --- a/pocs/scheduler/dispatch.py +++ b/pocs/scheduler/dispatch.py @@ -2,9 +2,9 @@ from astropy.coordinates import get_moon -from ..utils import current_time -from ..utils import listify -from .scheduler import BaseScheduler +from pocs.utils import current_time +from pocs.utils import listify +from pocs.scheduler import BaseScheduler class Scheduler(BaseScheduler): diff --git a/pocs/scheduler/observation.py b/pocs/scheduler/observation.py index 7cbb16037..7ac2ca0eb 100644 --- a/pocs/scheduler/observation.py +++ b/pocs/scheduler/observation.py @@ -1,8 +1,8 @@ from astropy import units as u from collections import OrderedDict -from .. import PanBase -from .field import Field +from pocs import PanBase +from pocs.scheduler.field import Field class Observation(PanBase): diff --git a/pocs/scheduler/scheduler.py b/pocs/scheduler/scheduler.py index bf86c7c43..22fbf19b6 100644 --- a/pocs/scheduler/scheduler.py +++ b/pocs/scheduler/scheduler.py @@ -6,10 +6,10 @@ from astroplan import Observer from astropy import units as u -from .. import PanBase -from ..utils import current_time -from .field import Field -from .observation import Observation +from pocs import PanBase +from pocs.utils import current_time +from pocs.scheduler.field import Field +from pocs.scheduler.observation import Observation class BaseScheduler(PanBase): diff --git a/pocs/state/machine.py b/pocs/state/machine.py index 78c69d2b7..9856affa3 100644 --- a/pocs/state/machine.py +++ b/pocs/state/machine.py @@ -3,9 +3,9 @@ from transitions import State -from ..utils import error -from ..utils import listify -from ..utils import load_module +from pocs.utils import error +from pocs.utils import listify +from pocs.utils import load_module can_graph = False try: # pragma: no cover diff --git a/pocs/state/states/default/observing.py b/pocs/state/states/default/observing.py index a091c7dfc..68e64d143 100644 --- a/pocs/state/states/default/observing.py +++ b/pocs/state/states/default/observing.py @@ -1,4 +1,4 @@ -from ....utils import error +from pocs.utils import error from time import sleep wait_interval = 15. diff --git a/pocs/state/states/default/pointing.py b/pocs/state/states/default/pointing.py index 356b5156e..f082a64bb 100644 --- a/pocs/state/states/default/pointing.py +++ b/pocs/state/states/default/pointing.py @@ -1,7 +1,7 @@ from time import sleep -from ....images import Image -from ....utils import error +from pocs.images import Image +from pocs.utils import error wait_interval = 3. timeout = 150. diff --git a/pocs/tests/test_base_scheduler.py b/pocs/tests/test_base_scheduler.py index 774c211a4..382cb823e 100644 --- a/pocs/tests/test_base_scheduler.py +++ b/pocs/tests/test_base_scheduler.py @@ -6,7 +6,7 @@ from astroplan import Observer -from pocs.scheduler.scheduler import BaseScheduler as Scheduler +from pocs.scheduler import BaseScheduler as Scheduler from pocs.scheduler.constraint import Duration from pocs.scheduler.constraint import MoonAvoidance diff --git a/pocs/utils/__init__.py b/pocs/utils/__init__.py index 01f2563c2..3cdf68fd5 100644 --- a/pocs/utils/__init__.py +++ b/pocs/utils/__init__.py @@ -99,7 +99,7 @@ def load_module(module_name): Returns: module: an imported module name """ - from ..utils import error + from pocs.utils import error try: module = resolve_name(module_name) except ImportError: diff --git a/pocs/utils/error.py b/pocs/utils/error.py index 0cb8bf7c2..7ba5f293c 100644 --- a/pocs/utils/error.py +++ b/pocs/utils/error.py @@ -2,7 +2,7 @@ from astropy.utils.exceptions import AstropyWarning -from .. import PanBase +from pocs import PanBase class PanError(AstropyWarning, PanBase): diff --git a/pocs/utils/logger.py b/pocs/utils/logger.py index 8304fa15d..057ca02a7 100644 --- a/pocs/utils/logger.py +++ b/pocs/utils/logger.py @@ -7,7 +7,7 @@ import logging.config from tempfile import gettempdir -from .config import load_config +from pocs.utils.config import load_config class PanLogger(object): diff --git a/pocs/utils/rs232.py b/pocs/utils/rs232.py index bf45f2dc6..37c423a8f 100644 --- a/pocs/utils/rs232.py +++ b/pocs/utils/rs232.py @@ -3,8 +3,8 @@ import serial as serial import time -from .. import PanBase -from .error import BadSerialConnection +from pocs import PanBase +from pocs.utils.error import BadSerialConnection class SerialData(PanBase):