update to newest API change in master

This commit is contained in:
Jérémy Rosen
2016-04-17 20:46:32 +02:00
parent 204868d733
commit 783194e253
12 changed files with 24 additions and 30 deletions

View File

@@ -118,8 +118,7 @@ end
function get_stdout(cmd)
-- Open the command, for reading
local fd = assert(io.popen(cmd, 'r'))
-- yield to other lua threads until data is ready to be read
coroutine.yield("FILE_READABLE",fd)
dt.control.read(fd)
-- slurp the whole file
local data = assert(fd:read('*a'))

View File

@@ -60,7 +60,7 @@ end
local function convert_image(image)
if string.sub(image.filename, -3) == "CR2" then
local filename = image.path .. "/" .. image.filename
local result = coroutine.yield("RUN_COMMAND", "cr2hdr " .. filename)
local result = dt.control.execute( "cr2hdr " .. filename)
local out_filename = string.gsub(filename, ".CR2", ".DNG")
local file = io.open(out_filename)
if file then

View File

@@ -106,7 +106,7 @@ local function create_geoJSON_file(storage, image_table, extra_data)
-- Creates dir if not exsists
local imageFoldername = "files/"
local mkdirCommand = "mkdir -p "..exportDirectory.."/"..imageFoldername
coroutine.yield("RUN_COMMAND", mkdirCommand)
dt.control.execute( mkdirCommand)
-- Create the thumbnails
for image,exported_image in pairs(image_table) do
@@ -124,10 +124,9 @@ local function create_geoJSON_file(storage, image_table, extra_data)
-- profiles that might be present in the input and aren't needed in the thumbnail.
local convertToThumbCommand = "convert -size 96x96 "..exported_image.." -resize 92x92 -mattecolor \"#FFFFFF\" -frame 2x2 +profile \"*\" "..exportDirectory.."/"..imageFoldername.."thumb_"..filename..".jpg"
-- USE coroutine.yield. It does not block the UI
coroutine.yield("RUN_COMMAND", convertToThumbCommand)
dt.control.execute( convertToThumbCommand)
local concertCommand = "convert -size 438x438 "..exported_image.." -resize 438x438 +profile \"*\" "..exportDirectory.."/"..imageFoldername..filename..".jpg"
coroutine.yield("RUN_COMMAND", concertCommand)
dt.control.execute( concertCommand)
end
-- delete the original image to not get into the kmz file
@@ -280,7 +279,7 @@ local function create_geoJSON_file(storage, image_table, extra_data)
if ( dt.preferences.read("geoJSON_export","OpengeoJSONFile","bool") == true ) then
local geoJSONFileOpenCommand
geoJSONFileOpenCommand = "xdg-open "..exportDirectory.."/\""..exportgeoJSONFilename.."\""
coroutine.yield("RUN_COMMAND", geoJSONFileOpenCommand)
dt.control.execute( geoJSONFileOpenCommand)
end

View File

@@ -77,7 +77,7 @@ local function openLocationInGnomeMaps()
startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\""
dt.print_error(startCommand)
if coroutine.yield("RUN_COMMAND", startCommand) then
if dt.control.execute( startCommand) then
dt.print(_("Command failed ..."))
end

View File

@@ -213,7 +213,7 @@ local function gimp_edit(storage, image_table, extra_data) --finalize
dt.print_error(gimpStartCommand)
coroutine.yield("RUN_COMMAND", gimpStartCommand)
dt.control.execute( gimpStartCommand)
-- for each of the image, exported image pairs
-- move the exported image into the directory with the original

View File

@@ -100,11 +100,11 @@ local function create_panorama(storage, image_table, extra_data) --finalize
if (hugin_executor) then
huginStartCommand = "pto_gen "..img_list.." -o "..dt.configuration.tmp_dir.."/project.pto"
dt.print(_("Creating pto file"))
coroutine.yield("RUN_COMMAND", huginStartCommand)
dt.control.execute( huginStartCommand)
dt.print(_("Running Assistent"))
huginStartCommand = "hugin_executor --assistant "..dt.configuration.tmp_dir.."/project.pto"
coroutine.yield("RUN_COMMAND", huginStartCommand)
dt.control.execute( huginStartCommand)
huginStartCommand = "hugin "..dt.configuration.tmp_dir.."/project.pto"
else
@@ -113,7 +113,7 @@ local function create_panorama(storage, image_table, extra_data) --finalize
dt.print_error(huginStartCommand)
if coroutine.yield("RUN_COMMAND", huginStartCommand)
if dt.control.execute( huginStartCommand)
then
dt.print(_("Command hugin failed ..."))
end

View File

@@ -186,7 +186,7 @@ local function create_kml_file(storage, image_table, extra_data)
-- Creates dir if not exsists
imageFoldername = "files/"
local mkdirCommand = "mkdir -p "..exportDirectory.."/"..imageFoldername
coroutine.yield("RUN_COMMAND", mkdirCommand)
dt.control.execute( mkdirCommand)
end
@@ -206,11 +206,10 @@ local function create_kml_file(storage, image_table, extra_data)
-- profiles that might be present in the input and aren't needed in the thumbnail.
local convertToThumbCommand = "convert -size 96x96 "..exported_image.." -resize 92x92 -mattecolor \"#FFFFFF\" -frame 2x2 +profile \"*\" "..exportDirectory.."/"..imageFoldername.."thumb_"..filename..".jpg"
-- USE coroutine.yield. It does not block the UI
coroutine.yield("RUN_COMMAND", convertToThumbCommand)
dt.control.execute( convertToThumbCommand)
local concertCommand = "convert -size 438x438 "..exported_image.." -resize 438x438 +profile \"*\" "..exportDirectory.."/"..imageFoldername..filename..".jpg"
coroutine.yield("RUN_COMMAND", concertCommand)
dt.control.execute( concertCommand)
end
-- delete the original image to not get into the kmz file
@@ -321,7 +320,6 @@ local function create_kml_file(storage, image_table, extra_data)
-- Compress the files to create a KMZ file
if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true ) then
exportDirectory = dt.preferences.read("kml_export","ExportDirectory","string")
-- USE coroutine.yield. It does not block the UI
local createKMZCommand = "zip --test --move --junk-paths "
createKMZCommand = createKMZCommand .."\""..exportDirectory.."/"..exportKMZFilename.."\" " -- KMZ filename
@@ -338,7 +336,7 @@ local function create_kml_file(storage, image_table, extra_data)
end
end
coroutine.yield("RUN_COMMAND", createKMZCommand)
dt.control.execute( createKMZCommand)
end
-- Open the file with the standard programm
@@ -350,7 +348,7 @@ local function create_kml_file(storage, image_table, extra_data)
else
kmlFileOpenCommand = "xdg-open "..exportDirectory.."/\""..exportKMLFilename.."\""
end
coroutine.yield("RUN_COMMAND", kmlFileOpenCommand)
dt.control.execute( kmlFileOpenCommand)
end

View File

@@ -65,12 +65,12 @@ local function playSlideshowMusic(_, old_view, new_view)
playCommand = 'rhythmbox-client --play-uri="'..filename..'"'
--dt.print_error(playCommand)
coroutine.yield("RUN_COMMAND", playCommand)
dt.control.execute( playCommand)
else
if (old_view and old_view.id == "slideshow") then
stopCommand = "rhythmbox-client --pause"
--dt.print_error(stopCommand)
coroutine.yield("RUN_COMMAND", stopCommand)
dt.control.execute( stopCommand)
end
end
end

View File

@@ -92,15 +92,13 @@ local function create_video_mencoder(storage, image_table, extra_data)
end
dt.print_error("this is the command: "..command)
-- USE coroutine.yield. It does not block the UI
coroutine.yield("RUN_COMMAND", command)
dt.control.execute( command)
dt.print("Video created in "..exportDirectory)
if ( dt.preferences.read("video_mencoder","OpenVideo","bool") == true ) then
-- USE coroutine.yield. It does not block the UI
local playVideoCommand = "xdg-open "..exportDirectory.."/"..exportFilename
coroutine.yield("RUN_COMMAND", playVideoCommand)
dt.control.execute( playVideoCommand)
end
end

View File

@@ -147,7 +147,7 @@ dt.register_lib(
local output_image = target_dir.."/enfuse.tiff"
local command = "enfuse --depth "..depth.value.." --exposure-mu "..ugly_decimal_point_hack
.." -o \""..output_image.."\" \"@"..response_file.."\""
if coroutine.yield("RUN_COMMAND", command) > 0 then
if dt.control.execute( command) > 0 then
dt.print("enfuse failed, see terminal output for details")
os.remove(response_file)
return

View File

@@ -97,7 +97,7 @@ dt.register_event("mouse-over-image-changed", function(event, img)
local command = command_setting:gsub("%$%(FILE_NAME%)", '"'..img_filename..'"')..' > "'..txt_filename..'"'
-- finally, run it
coroutine.yield("RUN_COMMAND", command)
dt.control.execute( command)
end
)

View File

@@ -128,7 +128,7 @@ dt.register_storage("export_pdf","Export thumbnails to pdf",
local dir=string.gsub(filename, "(.*/)(.*)", "%1")
local locfile=string.gsub(filename, "(.*/)(.*)", "%2")
local command = "pdflatex -halt-on-error -output-directory "..dir.." "..locfile
local result = coroutine.yield("RUN_COMMAND",command)
local result = dt.control.execute(command)
if result ~= 0 then
dt.print("Problem running pdflatex") -- this one is probably usefull to the user
error("Problem running "..command)
@@ -138,7 +138,7 @@ dt.register_storage("export_pdf","Export thumbnails to pdf",
local pdffile=string.gsub(filename, ".tex", ".pdf")
command = dt.preferences.read("selection_to_pdf","Open with","string")
command = command.." "..pdffile
local result = coroutine.yield("RUN_COMMAND",command)
local result = dt.control.execute(command)
if result ~= 0 then
dt.print("Problem running pdf viewer") -- this one is probably usefull to the user
error("Problem running "..command)