Updated all log strings to new format
This commit is contained in:
parent
36e837d374
commit
9f5252194a
35 changed files with 121 additions and 715 deletions
|
|
@ -72,7 +72,7 @@ root_log.addHandler(fh)
|
|||
access_log.addHandler(afh)
|
||||
|
||||
# Log server paths being used
|
||||
logging.info("Running with data path %s", OPENFLEXURE_VAR_PATH)
|
||||
logging.info("Running with data path {}", OPENFLEXURE_VAR_PATH)
|
||||
|
||||
logging.info("Creating app")
|
||||
# Create flask app
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ def handle_extension_error(extension_name):
|
|||
yield
|
||||
except Exception: # pylint: disable=W0703
|
||||
logging.error(
|
||||
"Exception loading builtin extension %s: \n%s",
|
||||
"Exception loading builtin extension {}: \n{}",
|
||||
extension_name,
|
||||
traceback.format_exc(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class JPEGSharpnessMonitor:
|
|||
raise e
|
||||
if stop < 1:
|
||||
stop = len(jpeg_times)
|
||||
logging.debug("changing stop to {}".format(stop))
|
||||
logging.debug("changing stop to {}", (stop))
|
||||
jpeg_times = jpeg_times[start:stop]
|
||||
jpeg_zs = np.interp(jpeg_times, stage_times, stage_zs)
|
||||
return jpeg_times, jpeg_zs, jpeg_sizes[start:stop]
|
||||
|
|
@ -292,9 +292,8 @@ def fast_up_down_up_autofocus(
|
|||
logging.debug("Correction move")
|
||||
correction_move = best_z + target_z - jz[inow]
|
||||
logging.debug(
|
||||
"Fast autofocus scan: correcting backlash by moving {} steps".format(
|
||||
correction_move
|
||||
)
|
||||
"Fast autofocus scan: correcting backlash by moving {} steps",
|
||||
(correction_move),
|
||||
)
|
||||
m.focus_rel(correction_move)
|
||||
return m.data_dict()
|
||||
|
|
|
|||
|
|
@ -95,10 +95,10 @@ class AutostorageExtension(BaseExtension):
|
|||
|
||||
def on_microscope(self, microscope_obj):
|
||||
"""Function to automatically call when the parent LabThing has a microscope attached."""
|
||||
logging.debug("Autostorage extension found microscope %s", microscope_obj)
|
||||
logging.debug("Autostorage extension found microscope {}", microscope_obj)
|
||||
if hasattr(microscope_obj, "captures"):
|
||||
logging.debug(
|
||||
"Autostorage extension bound to CaptureManager %s", self.capture_manager
|
||||
"Autostorage extension bound to CaptureManager {}", self.capture_manager
|
||||
)
|
||||
|
||||
# Store a reference to the CaptureManager
|
||||
|
|
@ -117,7 +117,7 @@ class AutostorageExtension(BaseExtension):
|
|||
# If preferred path does not exist, or cannot be written to
|
||||
if not (os.path.isdir(location) and check_rw(location)):
|
||||
logging.error(
|
||||
"Preferred capture path %s is missing or cannot be written to. Restoring defaults.",
|
||||
"Preferred capture path {} is missing or cannot be written to. Restoring defaults.",
|
||||
location,
|
||||
)
|
||||
# Reset the storage location to default
|
||||
|
|
|
|||
|
|
@ -63,17 +63,15 @@ def auto_expose_and_freeze_settings(camera):
|
|||
|
||||
logging.info("Freezing the camera settings...")
|
||||
camera.shutter_speed = camera.exposure_speed
|
||||
logging.info("Shutter speed = {}".format(camera.shutter_speed))
|
||||
logging.info("Shutter speed = {}", (camera.shutter_speed))
|
||||
camera.exposure_mode = "off"
|
||||
logging.info("Auto exposure disabled")
|
||||
g = camera.awb_gains
|
||||
camera.awb_mode = "off"
|
||||
camera.awb_gains = g
|
||||
logging.info("Auto white balance disabled, gains are {}".format(g))
|
||||
logging.info("Auto white balance disabled, gains are {}", (g))
|
||||
logging.info(
|
||||
"Analogue gain: {}, Digital gain: {}".format(
|
||||
camera.analog_gain, camera.digital_gain
|
||||
)
|
||||
"Analogue gain: {}, Digital gain: {}", camera.analog_gain, camera.digital_gain
|
||||
)
|
||||
adjust_exposure_to_setpoint(camera, 215)
|
||||
|
||||
|
|
@ -100,7 +98,7 @@ def lst_from_channels(channels):
|
|||
# lst_resolution = list(np.ceil(full_resolution / 64.0).astype(int))
|
||||
lst_resolution = [(r // 64) + 1 for r in full_resolution]
|
||||
# NB the size of the LST is 1/64th of the image, but rounded UP.
|
||||
logging.info("Generating a lens shading table at {}x{}".format(*lst_resolution))
|
||||
logging.info("Generating a lens shading table at {}x{}", *lst_resolution)
|
||||
lens_shading = np.zeros([channels.shape[0]] + lst_resolution, dtype=np.float)
|
||||
for i in range(lens_shading.shape[0]):
|
||||
image_channel = channels[i, :, :]
|
||||
|
|
@ -118,9 +116,12 @@ def lst_from_channels(channels):
|
|||
image_channel, [(0, lw * 32 - iw), (0, lh * 32 - ih)], mode="edge"
|
||||
) # Pad image to the right and bottom
|
||||
logging.info(
|
||||
"Channel shape: {}x{}, shading table shape: {}x{}, after padding {}".format(
|
||||
iw, ih, lw * 32, lh * 32, padded_image_channel.shape
|
||||
)
|
||||
"Channel shape: {}x{}, shading table shape: {}x{}, after padding {}",
|
||||
iw,
|
||||
ih,
|
||||
lw * 32,
|
||||
lh * 32,
|
||||
padded_image_channel.shape,
|
||||
)
|
||||
# Next, fill the shading table (except edge pixels). Please excuse the
|
||||
# for loop - I know it's not fast but this code needn't be!
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ class ScanExtension(BaseExtension):
|
|||
|
||||
for x_y in line:
|
||||
# Move to new grid position without changing z
|
||||
logging.debug("Moving to step {}".format([x_y[0], x_y[1], next_z]))
|
||||
logging.debug("Moving to step {}", ([x_y[0], x_y[1], next_z]))
|
||||
microscope.stage.move_abs([x_y[0], x_y[1], next_z])
|
||||
# Refocus
|
||||
if autofocus_enabled:
|
||||
|
|
@ -270,11 +270,11 @@ class ScanExtension(BaseExtension):
|
|||
# Make sure we use our current best estimate of focus (i.e. the current position) next point
|
||||
next_z = microscope.stage.position[2]
|
||||
|
||||
logging.debug("Returning to {}".format(initial_position))
|
||||
logging.debug("Returning to {}", (initial_position))
|
||||
microscope.stage.move_abs(initial_position)
|
||||
|
||||
end = time.time()
|
||||
logging.info("Scan took %s seconds", end - start)
|
||||
logging.info("Scan took {} seconds", end - start)
|
||||
|
||||
def stack(
|
||||
self,
|
||||
|
|
@ -298,17 +298,17 @@ class ScanExtension(BaseExtension):
|
|||
|
||||
# Store initial position
|
||||
initial_position = microscope.stage.position
|
||||
logging.debug("Starting z-stack from position %s", microscope.stage.position)
|
||||
logging.debug("Starting z-stack from position {}", microscope.stage.position)
|
||||
|
||||
with microscope.lock:
|
||||
# Move to center scan
|
||||
logging.debug("Moving to z-stack starting position")
|
||||
microscope.stage.move_rel([0, 0, int((-step_size * steps) / 2)])
|
||||
logging.debug("Starting scan from position %s", microscope.stage.position)
|
||||
logging.debug("Starting scan from position {}", microscope.stage.position)
|
||||
|
||||
for i in range(steps):
|
||||
time.sleep(0.1)
|
||||
logging.debug("Capturing from position %s", microscope.stage.position)
|
||||
logging.debug("Capturing from position {}", microscope.stage.position)
|
||||
self.capture(
|
||||
microscope,
|
||||
basename,
|
||||
|
|
@ -328,10 +328,10 @@ class ScanExtension(BaseExtension):
|
|||
return
|
||||
|
||||
if i != steps - 1:
|
||||
logging.debug("Moving z by {}".format(step_size))
|
||||
logging.debug("Moving z by {}", (step_size))
|
||||
microscope.stage.move_rel([0, 0, step_size])
|
||||
if return_to_start:
|
||||
logging.debug("Returning to {}".format(initial_position))
|
||||
logging.debug("Returning to {}", (initial_position))
|
||||
microscope.stage.move_abs(initial_position)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ class ZipGetterAPIView(View):
|
|||
if not session_id in default_zip_manager.session_zips:
|
||||
return abort(404) # 404 Not Found
|
||||
|
||||
logging.info("Session ID: %s", session_id)
|
||||
logging.info("Session ID: {}", session_id)
|
||||
|
||||
return send_file(
|
||||
default_zip_manager.zip_fp_from_id(session_id).name,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class SleepFor(ActionView):
|
|||
|
||||
def post(self, args):
|
||||
sleep_time = args.get("time")
|
||||
logging.info("Going to sleep for %s...", sleep_time)
|
||||
logging.info("Going to sleep for {}...", sleep_time)
|
||||
start = time.time()
|
||||
time.sleep(sleep_time)
|
||||
end = time.time()
|
||||
|
|
|
|||
|
|
@ -73,12 +73,10 @@ def init_default_extensions(extension_dir):
|
|||
default_ext_path = os.path.join(extension_dir, "defaults.py")
|
||||
|
||||
if not os.path.isfile(default_ext_path): # If user extensions file doesn't exist
|
||||
logging.warning(
|
||||
"No extension file found at {}. Creating...".format(extension_dir)
|
||||
)
|
||||
logging.warning("No extension file found at {}. Creating...", (extension_dir))
|
||||
create_file(default_ext_path)
|
||||
|
||||
logging.info("Populating {}...".format(default_ext_path))
|
||||
logging.info("Populating {}...", (default_ext_path))
|
||||
with open(default_ext_path, "w") as outfile:
|
||||
outfile.write(_DEFAULT_EXTENSION_INIT)
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ def build_gui_from_dict(gui_description, extension_object):
|
|||
if "route" in form and form["route"] in ext_rules.keys():
|
||||
form["route"] = ext_rules[form["route"]]["urls"][0]
|
||||
else:
|
||||
logging.warning("No valid expandable route found for %s", form["route"])
|
||||
logging.warning("No valid expandable route found for {}", form["route"])
|
||||
|
||||
# Inject extension information
|
||||
api_gui["id"] = extension_object.name
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ class MoveStageAPI(ActionView):
|
|||
# Handle absolute positioning (calculate a relative move from current position and target)
|
||||
if (args.get("absolute")) and (microscope.stage): # Only if stage exists
|
||||
target_position = axes_to_array(args, ["x", "y", "z"])
|
||||
logging.debug("TARGET: {}".format(target_position))
|
||||
logging.debug("TARGET: {}", (target_position))
|
||||
position = [
|
||||
target_position[i] - microscope.stage.position[i] for i in range(3)
|
||||
]
|
||||
logging.debug("DELTA: {}".format(position))
|
||||
logging.debug("DELTA: {}", (position))
|
||||
|
||||
else:
|
||||
# Get coordinates from payload
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue