Merge pull request #157 from theres/dm_timelapse

Timelapse plugin based on ffmpeg
This commit is contained in:
wpferguson
2019-02-21 11:57:03 -05:00
committed by GitHub
3 changed files with 539 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ local dtutils_file = {}
local dt = require "darktable"
local du = require "lib/dtutils"
local ds = require "lib/dtutils.string"
local dsys = require "lib/dtutils.system"
local log = require "lib/dtutils.log"
@@ -554,5 +555,54 @@ function dtutils_file.sanitize_filename(filename)
return ds.sanitize(filename)
end
dtutils_file.libdoc.functions["mkdir"] = {
Name = [[mkdir]],
Synopsis = [[create the directory(ies) if they do not already exists]],
Usage = [[local df = require "lib/dtutils.file"
df.mkdir(path)
path - string - a directory path]],
Description = [[mkdir creates directories if not already exists. It
create whole parents subtree if needed
]],
Return_Value = [[path - string - a directory path]],
Limitations = [[]],
Example = [[]],
See_Also = [[]],
Reference = [[]],
License = [[]],
Copyright = [[]],
}
function dtutils_file.mkdir(path)
if not dtutils_file.check_if_file_exists(path) then
local mkdir_cmd = dt.configuration.running_os == "windows" and "mkdir" or "mkdir -p"
return dsys.external_command(mkdir_cmd.." "..dtutils_file.sanitize_filename(path))
else
return 0
end
end
dtutils_file.libdoc.functions["rm"] = {
Name = [[rm]],
Synopsis = [[remove file or directory]],
Usage = [[local df = require "lib/dtutils.file"
df.rm(path)
path - string - a file or directory path]],
Description = [[rm allow to recursively remove files or directories]],
Return_Value = [[path - string - a file or directory path]],
Limitations = [[]],
Example = [[]],
See_Also = [[]],
Reference = [[]],
License = [[]],
Copyright = [[]],
}
function dtutils_file.rm(path)
local rm_cmd = dt.configuration.running_os == "windows" and "rmdir /S /Q" or "rm -r"
return dsys.external_command(rm_cmd.." "..dtutils_file.sanitize_filename(path))
end
return dtutils_file

View File

@@ -101,4 +101,34 @@ function dtutils_system.windows_command(command)
return result
end
dtutils_system.libdoc.functions["launch_default_app"] = {
Name = [[launch_default_app]],
Synopsis = [[try to open file in default application]],
Usage = [[local dsys = require "lib/dtutils.file"
dsys.launch_default_app(path)
path - string - a file path]],
Description = [[launch_default_app allow to open file in application that is assigned as default
one in users's system for given filetype
]],
Return_Value = [[path - string - a file path]],
Limitations = [[]],
Example = [[]],
See_Also = [[]],
Reference = [[]],
License = [[]],
Copyright = [[]],
}
function dtutils_system.launch_default_app(path)
local open_cmd = "xdg-open"
if (dt.configuration.running_os == "windows") then
open_cmd = "start"
elseif (dt.configuration.running_os == "macos") then
open_cmd = "open"
end
return dtutils_system.external_command(open_cmd..' "'..path..'"')
end
return dtutils_system