Skip to content

Commit

Permalink
Small tweaks for when camera initialization is skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
stefsmeets committed Jun 11, 2018
1 parent 2978897 commit 1a0f4c4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions instamatic/TEMController/TEMController.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def initialize(tem_name: str=default_tem, cam_name: str=default_cam, stream: boo
"""

print(f"Microscope: {tem_name}{' (server)' if use_server else ''}")
print(f"Camera : {cam_name}{' (stream)' if stream else ''}")
print(f"Camera : {cam_name}{' (stream)' if (cam_name and stream) else ''}")

tem = Microscope(tem_name, use_server=use_server)

Expand Down Expand Up @@ -538,7 +538,7 @@ def getImage(self, exposure: float=0.5, binsize: int=1, comment: str="", out: st
"""

if not self.cam:
raise AttributeError("{} object has no attribute 'cam'".format(repr(self.__class__.__name__)))
raise AttributeError("{} object has no attribute 'cam' (Camera has not been initialized)".format(repr(self.__class__.__name__)))

if not header_keys:
h = {}
Expand Down Expand Up @@ -588,7 +588,10 @@ def restore(self, name: str="stash"):
print("Microscope alignment restored from '{}'".format(name))

def close(self):
self.cam.close()
try:
self.cam.close()
except AttributeError:
pass

def show_stream(self):
"""If the camera has been opened as a stream, start a live view in a tkinter window"""
Expand Down

0 comments on commit 1a0f4c4

Please sign in to comment.