From aca02242636fbc91f86c6979df5709620878b0a3 Mon Sep 17 00:00:00 2001 From: marco44 Date: Sat, 5 May 2018 16:37:27 +0200 Subject: [PATCH] Fix autostyle, checkIfBinExists doesn't seem to exist in latest releases anymore --- contrib/autostyle.lua | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/contrib/autostyle.lua b/contrib/autostyle.lua index 66eca20..25ef537 100644 --- a/contrib/autostyle.lua +++ b/contrib/autostyle.lua @@ -37,7 +37,7 @@ GPLv2 ]] local darktable = require "darktable" - +local filelib = require "lib/dtutils.file" -- Forward declare the functions local autostyle_apply_one_image,autostyle_apply_one_image_event,autostyle_apply,exiftool_attribute,capture @@ -68,7 +68,7 @@ function autostyle_apply_one_image (image) darktable.print("style name not found in " .. darktable.preferences.read("autostyle","exif_tag","string")) return end - if not checkIfBinExists("exiftool") then + if not filelib.check_if_bin_exists("exiftool") then return end @@ -87,15 +87,17 @@ function autostyle_apply_one_image (image) -- Apply the style to image, if it is tagged local ok,auto_dr_attr= pcall(exiftool_attribute,image.path .. '/' .. image.filename,tag) + --darktable.print_error("dr_attr:" .. auto_dr_attr) -- If the lookup fails, stop here if (not ok) then + darktable.print("Couldn't get attribute" ) return end if auto_dr_attr==value then --- darktable.print("Image " .. image.filename .. ": autostyle automatically applied " .. darktable.preferences.read("autostyle","exif_tag","string") ) + darktable.print_error("Image " .. image.filename .. ": autostyle automatically applied " .. darktable.preferences.read("autostyle","exif_tag","string") ) darktable.styles.apply(style,image) --- else --- darktable.print("Image " .. image.filename .. ": autostyle not applied, exif tag " .. darktable.preferences.read("autostyle","exif_tag","string") .. " not matched: " .. auto_dr_attr) + else + darktable.print_error("Image " .. image.filename .. ": autostyle not applied, exif tag " .. darktable.preferences.read("autostyle","exif_tag","string") .. " not matched: " .. auto_dr_attr) end end @@ -109,14 +111,15 @@ end -- Retrieve the attribute through exiftool function exiftool_attribute(path,attr) - local cmd="exiftool -" .. attr .. " '" ..path.. "'"; + local cmd="exiftool -" .. attr .. " '" .. path .. "'"; local exifresult=get_stdout(cmd) local attribute=string.match(exifresult,": (.*)") if (attribute == nil) then - darktable.print( "Could not find the attribute " .. attr .. " using the command: <" .. cmd .. ">") + darktable.print_error( "Could not find the attribute " .. attr .. " using the command: <" .. cmd .. ">") -- Raise an error to the caller error( "Could not find the attribute " .. attr .. " using the command: <" .. cmd .. ">"); end + darktable.print_error("Returning attribute: " .. attribute) return attribute end @@ -124,7 +127,7 @@ end function get_stdout(cmd) -- Open the command, for reading local fd = assert(io.popen(cmd, 'r')) - dt.control.read(fd) + darktable.control.read(fd) -- slurp the whole file local data = assert(fd:read('*a'))