Skip to content

Commit 79511d9

Browse files
authored
Update geoJSON_export.lua
use "lib/dtutils.file"
1 parent bff2df0 commit 79511d9

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

contrib/geoJSON_export.lua

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ USAGE
3333
]]
3434

3535
local dt = require "darktable"
36+
local df = require "lib/dtutils.file"
3637
require "official/yield"
37-
3838
local gettext = dt.gettext
39+
3940
dt.configuration.check_version(...,{3,0,0},{4,0,0})
4041

4142
-- Tell gettext where to find the .mo file translating messages for a particular domain
@@ -73,31 +74,21 @@ local function show_status(storage, image, format, filename, number, total, high
7374
dt.print(string.format(_("Export Image %i/%i"), number, total))
7475
end
7576

76-
local function checkIfBinExists(bin)
77-
local handle = io.popen("which "..bin)
78-
local result = handle:read()
79-
local ret
80-
handle:close()
81-
if (not result) then
82-
dt.print_error(bin.." not found")
83-
ret = false
84-
end
85-
ret = true
86-
return ret
87-
end
88-
8977
local function create_geoJSON_file(storage, image_table, extra_data)
90-
91-
if not checkIfBinExists("mkdir") then
78+
if not df.check_if_bin_exists("mkdir") then
79+
dt.print_error(_("mkdir not found"))
9280
return
9381
end
94-
if not checkIfBinExists("convert") then
82+
if not df.check_if_bin_exists("convert") then
83+
dt.print_error(_("convert not found"))
9584
return
9685
end
97-
if not checkIfBinExists("xdg-open") then
86+
if not df.check_if_bin_exists("xdg-open") then
87+
dt.print_error(_("xdg-open not found"))
9888
return
9989
end
100-
if not checkIfBinExists("xdg-user-dir") then
90+
if not df.check_if_bin_exists("xdg-user-dir") then
91+
dt.print_error(_("xdg-user-dir not found"))
10192
return
10293
end
10394

0 commit comments

Comments
 (0)