From 783194e25330cd0fec6e91d82d06f08b0a03e9ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rosen?= Date: Sun, 17 Apr 2016 20:46:32 +0200 Subject: [PATCH] update to newest API change in master --- contrib/autostyle.lua | 3 +-- contrib/cr2hdr.lua | 2 +- contrib/geoJSON_export.lua | 9 ++++----- contrib/geo_uri.lua | 2 +- contrib/gimp.lua | 2 +- contrib/hugin.lua | 6 +++--- contrib/kml_export.lua | 12 +++++------- contrib/slideshowMusic.lua | 4 ++-- contrib/video_mencoder.lua | 6 ++---- official/enfuse.lua | 2 +- official/generate_image_txt.lua | 2 +- official/selection_to_pdf.lua | 4 ++-- 12 files changed, 24 insertions(+), 30 deletions(-) diff --git a/contrib/autostyle.lua b/contrib/autostyle.lua index c8dafaf..9d026ab 100644 --- a/contrib/autostyle.lua +++ b/contrib/autostyle.lua @@ -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')) diff --git a/contrib/cr2hdr.lua b/contrib/cr2hdr.lua index d57e912..9b21e3c 100644 --- a/contrib/cr2hdr.lua +++ b/contrib/cr2hdr.lua @@ -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 diff --git a/contrib/geoJSON_export.lua b/contrib/geoJSON_export.lua index c5fc0b7..74629d6 100644 --- a/contrib/geoJSON_export.lua +++ b/contrib/geoJSON_export.lua @@ -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 diff --git a/contrib/geo_uri.lua b/contrib/geo_uri.lua index 04ad553..d86018c 100644 --- a/contrib/geo_uri.lua +++ b/contrib/geo_uri.lua @@ -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 diff --git a/contrib/gimp.lua b/contrib/gimp.lua index 896fec3..a15ca6b 100644 --- a/contrib/gimp.lua +++ b/contrib/gimp.lua @@ -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 diff --git a/contrib/hugin.lua b/contrib/hugin.lua index d6f6622..8d80629 100644 --- a/contrib/hugin.lua +++ b/contrib/hugin.lua @@ -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 diff --git a/contrib/kml_export.lua b/contrib/kml_export.lua index eeee8f5..7960287 100644 --- a/contrib/kml_export.lua +++ b/contrib/kml_export.lua @@ -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 diff --git a/contrib/slideshowMusic.lua b/contrib/slideshowMusic.lua index 776c71e..fdece6a 100644 --- a/contrib/slideshowMusic.lua +++ b/contrib/slideshowMusic.lua @@ -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 diff --git a/contrib/video_mencoder.lua b/contrib/video_mencoder.lua index 8198780..e65adaa 100644 --- a/contrib/video_mencoder.lua +++ b/contrib/video_mencoder.lua @@ -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 diff --git a/official/enfuse.lua b/official/enfuse.lua index 3a0ac59..829a969 100644 --- a/official/enfuse.lua +++ b/official/enfuse.lua @@ -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 diff --git a/official/generate_image_txt.lua b/official/generate_image_txt.lua index 416a8ce..b650de1 100644 --- a/official/generate_image_txt.lua +++ b/official/generate_image_txt.lua @@ -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 ) diff --git a/official/selection_to_pdf.lua b/official/selection_to_pdf.lua index 8444e8e..f6bf890 100644 --- a/official/selection_to_pdf.lua +++ b/official/selection_to_pdf.lua @@ -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)