66from tkinter import filedialog , messagebox
77
88from imgcorrect import corrections
9+ from imgcorrect ._version import __version__ as imgcorrect_version
910
1011logger = logging .getLogger (__name__ )
1112
@@ -34,7 +35,7 @@ def emit(self, record):
3435class CorrectImagesApp (tk .Tk ):
3536 def __init__ (self ):
3637 super ().__init__ ()
37- self .title ("Sentera Radiometric Corrections" )
38+ self .title (f "Sentera Radiometric Corrections v { imgcorrect_version } " )
3839 self .geometry ("600x500" )
3940 self .resizable (True , False ) # Allow horizontal resize, disable vertical resize
4041 self .minsize (600 , 500 ) # Set minimum width to 600px, height to 500px
@@ -255,14 +256,23 @@ def run_correction(self):
255256 if self .exiftool_path_var .get ():
256257 exiftool_path = self .exiftool_path_var .get ()
257258 else :
258- exiftool_path = os .path .join (sys ._MEIPASS , "exiftool.exe" )
259+ try :
260+ exiftool_path = os .path .join (sys ._MEIPASS , "exiftool.exe" )
261+ except Exception :
262+ exiftool_path = "exiftool/exiftool.exe"
259263 uint16_output = self .uint16_var .get ()
260264
261265 self .output_text .delete (1.0 , tk .END )
262266
263267 os .makedirs (self .output_path_var .get (), exist_ok = True )
264268
265269 def run_corrections ():
270+ # Clear existing handlers to prevent duplicates
271+ root_logger = logging .getLogger ()
272+ for handler in root_logger .handlers [:]:
273+ if isinstance (handler , TextHandler ):
274+ root_logger .removeHandler (handler )
275+
266276 handler = TextHandler (self .output_text )
267277 logging .basicConfig (
268278 filename = os .path .join (
@@ -271,9 +281,10 @@ def run_corrections():
271281 ),
272282 level = logging .INFO ,
273283 format = "%(asctime)s %(levelname)s:%(message)s" ,
284+ force = True , # This recreates the basic config
274285 )
275- logging . getLogger () .addHandler (handler )
276- logger .info ("Running Corrections" )
286+ root_logger .addHandler (handler )
287+ logger .info (f "Running Corrections - v { imgcorrect_version } " )
277288 logger .info (f"Input Path: { input_path } " )
278289 logger .info (f"Output Path: { output_path } " )
279290 logger .info (f"ExifTool Path: { exiftool_path } " )
@@ -283,19 +294,22 @@ def run_corrections():
283294 logger .info (f"All Panels: { all_panels } " )
284295 logger .info (f"Delete Original: { delete_original } " )
285296 logger .info (f"UInt16 Output: { uint16_output } " )
286- corrections .correct_images (
287- input_path ,
288- calibration_id ,
289- output_path ,
290- no_ils_correct ,
291- no_reflectance_correct ,
292- all_panels ,
293- delete_original ,
294- exiftool_path ,
295- uint16_output ,
296- )
297+ try :
298+ corrections .correct_images (
299+ input_path ,
300+ calibration_id ,
301+ output_path ,
302+ no_ils_correct ,
303+ no_reflectance_correct ,
304+ all_panels ,
305+ delete_original ,
306+ exiftool_path ,
307+ uint16_output ,
308+ )
309+ logger .info ("Corrections complete!" )
310+ except Exception as e :
311+ logger .error (f"Error during correction: { e } " )
297312 self .enable_buttons ()
298- logger .info ("Corrections complete!" )
299313
300314 threading .Thread (target = run_corrections , daemon = True ).start ()
301315
0 commit comments