Skip to content

Commit

Permalink
Set Primary Camera properly (#650)
Browse files Browse the repository at this point in the history
* Properly set the primary camera from the config helper function
* Add "[Primary]" to the __str__
  • Loading branch information
wtgee authored Sep 30, 2018
1 parent 32d8e92 commit 77cd582
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
3 changes: 2 additions & 1 deletion pocs/camera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,11 @@ def kwargs_or_config(item, default=None):

is_primary = ''
if camera_info.get('primary', '') == cam.uid:
cam.is_primary = True
primary_camera = cam
is_primary = ' [Primary]'

logger.debug("Camera created: {} {} {}".format(
logger.debug("Camera created: {} {}{}".format(
cam.name, cam.uid, is_primary))

cameras[cam_name] = cam
Expand Down
14 changes: 5 additions & 9 deletions pocs/camera/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,15 +492,11 @@ def _process_fits(self, file_path, info):
return file_path

def __str__(self):
try:
return "{} ({}) on {} with {}".format(
self.name,
self.uid,
self.port,
self.focuser.name
)
except AttributeError:
return "{} ({}) on {}".format(self.name, self.uid, self.port)
s = "{} ({}) on {}".format(self.name, self.uid, self.port)
if hasattr(self, 'focuser') and self.focuser is not None:
s += ' with {}'.format(self.focuser.name)

return s


class AbstractGPhotoCamera(AbstractCamera): # pragma: no cover
Expand Down
10 changes: 5 additions & 5 deletions pocs/observatory.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ def __init__(self, cameras=None, *args, **kwargs):
self.mount = None
self._create_mount()

if not cameras:
cameras = OrderedDict()
self.cameras = OrderedDict()

if cameras:
self.logger.info('Adding the cameras to the observatory')
self.logger.info('Adding the cameras to the observatory: {}', cameras)
self._primary_camera = None
self.cameras = cameras
for cam_name, camera in cameras.items():
self.add_camera(cam_name, camera)

Expand Down Expand Up @@ -143,7 +141,9 @@ def add_camera(self, cam_name, camera):
assert isinstance(camera, AbstractCamera)
self.logger.debug('Adding {}: {}'.format(cam_name, camera))
if cam_name in self.cameras:
self.logger.debug('{} already exists, replacing existing camera under that name.')
self.logger.debug(
'{} already exists, replacing existing camera under that name.',
cam_name)

self.cameras[cam_name] = camera
if camera.is_primary:
Expand Down

0 comments on commit 77cd582

Please sign in to comment.