contrib/autostyle replaced io.popen functions with wrapper

contrib/color_profile_manager    to properly quote windows commands so
contrib/fujifilm_dynamic_range   that they are sanitized for special
contrib/fujifilm_ratings         characters and spaces
contrib/geoJSON_export
contrib/geoToolbox
contrib/image_stack
contrib/image_time
contrib/kml_export
official/enfuse
tools/executable_manager
tools/get_lib_manpages
tools/get_libdoc
This commit is contained in:
Bill Ferguson
2024-06-04 23:43:21 -04:00
parent fe48d7498c
commit 038418b89f
13 changed files with 28 additions and 18 deletions

View File

@@ -39,6 +39,7 @@ GPLv2
local darktable = require "darktable"
local du = require "lib/dtutils"
local filelib = require "lib/dtutils.file"
local syslib = require "lib/dtutils.system"
du.check_min_api_version("7.0.0", "autostyle")
@@ -68,7 +69,7 @@ script_data.show = nil -- only required for libs since the destroy_method only h
-- run command and retrieve stdout
local function get_stdout(cmd)
-- Open the command, for reading
local fd = assert(io.popen(cmd, 'r'))
local fd = assert(syslib.io_popen(cmd, 'r'))
darktable.control.read(fd)
-- slurp the whole file
local data = assert(fd:read('*a'))

View File

@@ -45,6 +45,7 @@
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
du.check_min_api_version("7.0.0", "color_profile_manager")
@@ -106,7 +107,7 @@ end
local function list_profiles(dir)
local files = {}
local p = io.popen(DIR_CMD .. " " .. dir)
local p = dtsys.io_popen(DIR_CMD .. " " .. dir)
if p then
for line in p:lines() do
table.insert(files, line)

View File

@@ -60,6 +60,7 @@ cameras may behave in other ways.
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
du.check_min_api_version("7.0.0", "fujifilm_dynamic_range")
@@ -105,7 +106,7 @@ local function detect_dynamic_range(event, image)
-- without -n flag, exiftool will round to the nearest tenth
command = command .. " -RawExposureBias -n -t " .. RAF_filename
dt.print_log(command)
output = io.popen(command)
output = dtsys.io_popen(command)
local raf_result = output:read("*all")
output:close()
if #raf_result == 0 then

View File

@@ -26,6 +26,7 @@ Dependencies:
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
du.check_min_api_version("7.0.0", "fujifilm_ratings")
@@ -61,7 +62,7 @@ local function detect_rating(event, image)
local JPEG_filename = string.gsub(RAF_filename, "%.RAF$", ".JPG")
local command = "exiftool -Rating " .. JPEG_filename
dt.print_error(command)
local output = io.popen(command)
local output = dtsys.io_popen(command)
local jpeg_result = output:read("*all")
output:close()
if string.len(jpeg_result) > 0 then
@@ -72,7 +73,7 @@ local function detect_rating(event, image)
end
command = "exiftool -Rating " .. RAF_filename
dt.print_error(command)
output = io.popen(command)
output = dtsys.io_popen(command)
local raf_result = output:read("*all")
output:close()
if string.len(raf_result) > 0 then

View File

@@ -35,6 +35,7 @@ USAGE
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
du.check_min_api_version("7.0.0", "geoJSON_export")
@@ -330,7 +331,7 @@ dt.preferences.register("geoJSON_export",
_("opens the geoJSON file after the export with the standard program for geoJSON files"),
false )
local handle = io.popen("xdg-user-dir DESKTOP")
local handle = dtsys.io_popen("xdg-user-dir DESKTOP")
local result = handle:read()
handle:close()
if (result == nil) then

View File

@@ -28,6 +28,7 @@ require "geoToolbox"
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
du.check_min_api_version("7.0.0", "geoToolbox")
@@ -411,7 +412,7 @@ local function reverse_geocode()
-- jq could be replaced with a Lua JSON parser
startCommand = string.format("curl --silent \"https://api.mapbox.com/geocoding/v5/mapbox.places/%s,%s.json?types=%s&access_token=%s\" | jq '.features | .[0] | '.text''", lon1, lat1, types, tokan)
local handle = io.popen(startCommand)
local handle = dtsys.io_popen(startCommand)
local result = trim12(handle:read("*a"))
handle:close()

View File

@@ -348,7 +348,7 @@ local function list_files(search_string)
search_string = string.gsub(search_string, "/", "\\\\")
end
local f = io.popen(ls .. search_string)
local f = dtsys.io_popen(ls .. search_string)
if f then
local found_file = f:read()
while found_file do

View File

@@ -107,6 +107,7 @@ local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local ds = require "lib/dtutils.string"
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
local img_time = {}
@@ -225,7 +226,7 @@ local function get_image_taken_time(image)
local exiv2 = df.check_if_bin_exists("exiv2")
if exiv2 then
p = io.popen(exiv2 .. " -K Exif.Image.DateTime " .. image.path .. PS .. image.filename)
p = dtsys.io_popen(exiv2 .. " -K Exif.Image.DateTime " .. image.path .. PS .. image.filename)
if p then
for line in p:lines() do
if string.match(line, "Exif.Image.DateTime") then
@@ -243,7 +244,7 @@ end
local function _get_windows_image_file_creation_time(image)
local datetime = nil
local p = io.popen("dir " .. image.path .. PS .. image.filename)
local p = dtsys.io_popen("dir " .. image.path .. PS .. image.filename)
if p then
for line in p:lines() do
if string.match(line, ds.sanitize_lua(image.filename)) then
@@ -264,7 +265,7 @@ end
local function _get_nix_image_file_creation_time(image)
local datetime = nil
local p = io.popen("ls -lL --time-style=full-iso " .. image.path .. PS .. image.filename)
local p = dtsys.io_popen("ls -lL --time-style=full-iso " .. image.path .. PS .. image.filename)
if p then
for line in p:lines() do
if string.match(line, ds.sanitize_lua(image.filename)) then

View File

@@ -343,7 +343,7 @@ if dt.configuration.running_os == "windows" then
elseif dt.configuration.running_os == "macos" then
defaultDir = os.getenv("HOME")
else
local handle = io.popen("xdg-user-dir DESKTOP")
local handle = dsys.io_popen("xdg-user-dir DESKTOP")
defaultDir = handle:read()
handle:close()
end

View File

@@ -116,7 +116,7 @@ if enfuse_installed then
local version = nil
local p = io.popen(enfuse_installed .. " --version")
local p = dtsys.io_popen(enfuse_installed .. " --version")
local f = p:read("all")
p:close()
version = string.match(f, "enfuse (%d.%d)")

View File

@@ -31,6 +31,7 @@
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
du.check_min_api_version("7.0.0", "executable_manager")
@@ -75,7 +76,7 @@ local function grep(file, pattern)
if dt.configuration.running_os == "windows" then
-- use find to get the matches
local command = "\\windows\\system32\\find.exe " .. "\"" .. pattern .. "\"" .. " " .. file
local f = io.popen(command)
local f = dtsys.io_popen(command)
local output = f:read("all")
f:close()
-- strip out the first line
@@ -84,7 +85,7 @@ local function grep(file, pattern)
else
-- use grep and just return the answers
local command = "grep " .. pattern .. " " .. file
local f = io.popen(command)
local f = dtsys.io_popen(command)
local output = f:read("all")
f:close()
result = du.split(output, "\n")

View File

@@ -7,6 +7,7 @@
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
local log = require "lib/dtutils.log"
local libname = nil
@@ -33,7 +34,7 @@ local function output_man(d)
libname = name
end
local fname = "/tmp/" .. name .. ".3"
local mf = io.open(fname, "w")
local mf = dtsys.io_open(fname, "w")
if mf then
mf:write(".TH " .. string.upper(name) .. " 3 \"\" \"\" \"Darktable " .. libname .. " functions\"\n")
for _,section in ipairs(keys) do
@@ -59,7 +60,7 @@ end
-- find the libraries
local output = io.popen("cd "..dt.configuration.config_dir.."/lua/lib ;find . -name \\*.lua -print | sort")
local output = dtsys.io_popen("cd "..dt.configuration.config_dir.."/lua/lib ;find . -name \\*.lua -print | sort")
-- loop through the libraries

View File

@@ -6,6 +6,7 @@
local dt = require "darktable"
local du = require "lib/dtutils"
local dtsys = require "lib/dtutils.system"
du.check_min_api_version("3.0.0", "get_libdoc")
@@ -36,7 +37,7 @@ end
-- find the libraries
local output = io.popen("cd "..dt.configuration.config_dir.."/lua/lib ;find . -name \\*.lua -print | sort")
local output = dtsys.io_popen("cd "..dt.configuration.config_dir.."/lua/lib ;find . -name \\*.lua -print | sort")
-- loop through the libraries