Title: | Detection and Localization of Executable Files |
---|---|
Description: | A set of functions to locate some programs available on the user machine. The package provides functions to locate 'Node.js', 'npm', 'LibreOffice', 'Microsoft Word', 'Microsoft PowerPoint', 'Microsoft Excel', 'Python', 'pip', 'Mozilla Firefox' and 'Google Chrome'. User can test the availability of a program with eventually a version and call it with function system2() or system(). This allows the use of a single function to retrieve the path to a program regardless of the operating system and its configuration. |
Authors: | David Gohel [aut, cre], ArData [cph] |
Maintainer: | David Gohel <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2024-11-21 02:48:00 UTC |
Source: | https://github.com/ardata-fr/locatexec |
return the full path of 'Google Chrome' executable if found.
chrome_exec()
chrome_exec()
chrome executable full path in a character vector of length 1.
Other executable full path:
excel_exec()
,
firefox_exec()
,
libreoffice_exec()
,
node_exec()
,
npm_exec()
,
pip_exec()
,
powerpoint_exec()
,
python_exec()
,
word_exec()
if(exec_available("chrome")) message(chrome_exec())
if(exec_available("chrome")) message(chrome_exec())
return the full path of 'Microsoft Excel' executable if found.
excel_exec()
excel_exec()
executable full path in a character vector of length 1.
Other executable full path:
chrome_exec()
,
firefox_exec()
,
libreoffice_exec()
,
node_exec()
,
npm_exec()
,
pip_exec()
,
powerpoint_exec()
,
python_exec()
,
word_exec()
if(exec_available("excel")) message(excel_exec())
if(exec_available("excel")) message(excel_exec())
determine whether an executable is currently available on the user machine (optionally checking for a specific or greater version).
exec_available(exec, version = NULL, error = FALSE)
exec_available(exec, version = NULL, error = FALSE)
exec |
executable identifier, a single character. Use one of these values:
|
version |
required version of executable |
error |
if |
a logical indicating whether the executable is available.
if (exec_available("python")) { cat("python", as.character(exec_version("python")), "is available!\n") } if(exec_available("python", "3.9")) { cat("required version of python is available!\n") } if (exec_available("pip")) { cat("pip", as.character(exec_version("pip")), "is available!\n") } if (exec_available("pip", "19.3")) { cat("pip", as.character(exec_version("pip")), "is available!\n") } if (exec_available("chrome")) { cat("chrome", as.character(exec_version("chrome")), "is available!\n") } if (exec_available("firefox")) { cat("firefox", as.character(exec_version("firefox")), "is available!\n") } if (exec_available("node")) { cat("node.js", as.character(exec_version("node")), "is available!\n") } if (exec_available("npm")) { cat("npm", as.character(exec_version("npm")), "is available!\n") } if (exec_available("npm", version = "10.13.0")) { cat("npm", as.character(exec_version("npm")), "is available!\n") } if (exec_available("excel")) { cat("excel", as.character(exec_version("excel")), "is available!\n") } if (exec_available("word")) { cat("word", as.character(exec_version("word")), "is available!\n") } if (exec_available("powerpoint")) { cat("powerpoint", as.character(exec_version("powerpoint")), "is available!\n") }
if (exec_available("python")) { cat("python", as.character(exec_version("python")), "is available!\n") } if(exec_available("python", "3.9")) { cat("required version of python is available!\n") } if (exec_available("pip")) { cat("pip", as.character(exec_version("pip")), "is available!\n") } if (exec_available("pip", "19.3")) { cat("pip", as.character(exec_version("pip")), "is available!\n") } if (exec_available("chrome")) { cat("chrome", as.character(exec_version("chrome")), "is available!\n") } if (exec_available("firefox")) { cat("firefox", as.character(exec_version("firefox")), "is available!\n") } if (exec_available("node")) { cat("node.js", as.character(exec_version("node")), "is available!\n") } if (exec_available("npm")) { cat("npm", as.character(exec_version("npm")), "is available!\n") } if (exec_available("npm", version = "10.13.0")) { cat("npm", as.character(exec_version("npm")), "is available!\n") } if (exec_available("excel")) { cat("excel", as.character(exec_version("excel")), "is available!\n") } if (exec_available("word")) { cat("word", as.character(exec_version("word")), "is available!\n") } if (exec_available("powerpoint")) { cat("powerpoint", as.character(exec_version("powerpoint")), "is available!\n") }
Searches for an executable in a some places and use the highest version found (unless a specific version is requested).
The function mimic the behavior of the rmarkdown::find_pandoc()
function in order to locate programs.
Some methods work differently depending on the OS or the program:
Under Windows, the search
for 'Google Chrome', 'Mozilla Firefox', 'Microsoft Word', 'Microsoft PowerPoint'
and 'Microsoft Excel' is done in the registry, which means that only one version
can be chosen, the one referenced in the registry. (you still can force another path
with argument dir
).
'Microsoft Word', 'Microsoft PowerPoint' and 'Microsoft Excel' can not be located on linux OS.
the search for 'pip' is using the result of the search of 'python' to find the corresponding 'pip' executable.
exec_locate(exec, cache = TRUE, dir = NULL, version = NULL)
exec_locate(exec, cache = TRUE, dir = NULL, version = NULL)
exec |
executable identifier, a single character. Use one of these values:
|
cache |
if |
dir |
A character vector of directory paths under which the executable may be found. |
version |
The version of the executable to look for (e.g., |
A list containing the path of the executable and its version if found. If not found,
the version will be 0
and the exec_file
will be NULL
.
On some Ubuntu platforms, 'LibreOffice' require to add in
the environment variable LD_LIBRARY_PATH
the following path:
/usr/lib/libreoffice/program
(you should see the message
"libreglo.so cannot open shared object file" if it is the case). This
can be done with R
command Sys.setenv(LD_LIBRARY_PATH = "/usr/lib/libreoffice/program/")
exec_available()
will check if an executable is available
and exec_version()
will return the version of a located executable.
exec_locate("firefox") exec_locate("chrome") exec_locate("chrome", version = "88.0.4324.150") exec_locate("libreoffice") exec_locate("node") exec_locate("npm") exec_locate("python") exec_locate("pip") exec_locate("excel") exec_locate("word") exec_locate("powerpoint")
exec_locate("firefox") exec_locate("chrome") exec_locate("chrome", version = "88.0.4324.150") exec_locate("libreoffice") exec_locate("node") exec_locate("npm") exec_locate("python") exec_locate("pip") exec_locate("excel") exec_locate("word") exec_locate("powerpoint")
get the version of an executable.
exec_version(exec)
exec_version(exec)
exec |
executable identifier, a single character. Use one of these values:
|
a numeric_version()
with the version of the executable found.
if(exec_available("chrome")) message(exec_version("chrome")) if(exec_available("node")) message(exec_version("node")) if(exec_available("python")) message(exec_version("python")) if(exec_available("libreoffice")) message(exec_version("libreoffice")) if(exec_available("word")) message(exec_version("word")) if(exec_available("powerpoint")) message(exec_version("powerpoint")) if(exec_available("firefox")) message(exec_version("firefox"))
if(exec_available("chrome")) message(exec_version("chrome")) if(exec_available("node")) message(exec_version("node")) if(exec_available("python")) message(exec_version("python")) if(exec_available("libreoffice")) message(exec_version("libreoffice")) if(exec_available("word")) message(exec_version("word")) if(exec_available("powerpoint")) message(exec_version("powerpoint")) if(exec_available("firefox")) message(exec_version("firefox"))
return the full path of 'Mozilla Firefox' executable if found.
firefox_exec()
firefox_exec()
Firefox executable full path in a character vector of length 1.
Other executable full path:
chrome_exec()
,
excel_exec()
,
libreoffice_exec()
,
node_exec()
,
npm_exec()
,
pip_exec()
,
powerpoint_exec()
,
python_exec()
,
word_exec()
if(exec_available("firefox")) message(firefox_exec())
if(exec_available("firefox")) message(firefox_exec())
Test if the operating system is "macOS"
is_osx()
is_osx()
TRUE or FALSE
Other operating system testing:
is_unix()
,
is_windows()
is_osx()
is_osx()
Test if the operating system is "unix"
is_unix()
is_unix()
TRUE or FALSE
Other operating system testing:
is_osx()
,
is_windows()
is_unix()
is_unix()
Test if the operating system is "Windows"
is_windows()
is_windows()
TRUE or FALSE
Other operating system testing:
is_osx()
,
is_unix()
is_windows()
is_windows()
return the full path of 'LibreOffice' executable if found.
libreoffice_exec()
libreoffice_exec()
executable full path in a character vector of length 1.
Other executable full path:
chrome_exec()
,
excel_exec()
,
firefox_exec()
,
node_exec()
,
npm_exec()
,
pip_exec()
,
powerpoint_exec()
,
python_exec()
,
word_exec()
if(exec_available("libreoffice")) { message(libreoffice_exec()) }
if(exec_available("libreoffice")) { message(libreoffice_exec()) }
return the full path of 'node.js' executable if found.
node_exec()
node_exec()
executable full path in a character vector of length 1.
Other executable full path:
chrome_exec()
,
excel_exec()
,
firefox_exec()
,
libreoffice_exec()
,
npm_exec()
,
pip_exec()
,
powerpoint_exec()
,
python_exec()
,
word_exec()
if(exec_available("node")) message(node_exec())
if(exec_available("node")) message(node_exec())
return the full path of 'npm' executable if found.
npm_exec()
npm_exec()
executable full path in a character vector of length 1.
Other executable full path:
chrome_exec()
,
excel_exec()
,
firefox_exec()
,
libreoffice_exec()
,
node_exec()
,
pip_exec()
,
powerpoint_exec()
,
python_exec()
,
word_exec()
if(exec_available("npm")) message(npm_exec())
if(exec_available("npm")) message(npm_exec())
return the full path of 'pip' executable if found.
pip_exec()
pip_exec()
executable full path in a character vector of length 1.
Other executable full path:
chrome_exec()
,
excel_exec()
,
firefox_exec()
,
libreoffice_exec()
,
node_exec()
,
npm_exec()
,
powerpoint_exec()
,
python_exec()
,
word_exec()
if(exec_available("pip")) message(pip_exec())
if(exec_available("pip")) message(pip_exec())
return the full path of 'Microsoft PowerPoint' executable if found.
powerpoint_exec()
powerpoint_exec()
executable full path in a character vector of length 1.
Other executable full path:
chrome_exec()
,
excel_exec()
,
firefox_exec()
,
libreoffice_exec()
,
node_exec()
,
npm_exec()
,
pip_exec()
,
python_exec()
,
word_exec()
if(exec_available("powerpoint")) message(powerpoint_exec())
if(exec_available("powerpoint")) message(powerpoint_exec())
return the full path of 'python' executable if found.
python_exec()
python_exec()
executable full path in a character vector of length 1.
Other executable full path:
chrome_exec()
,
excel_exec()
,
firefox_exec()
,
libreoffice_exec()
,
node_exec()
,
npm_exec()
,
pip_exec()
,
powerpoint_exec()
,
word_exec()
if(exec_available("python")) message(python_exec())
if(exec_available("python")) message(python_exec())
return the full path of 'Microsoft Word' executable if found.
word_exec()
word_exec()
executable full path in a character vector of length 1.
Other executable full path:
chrome_exec()
,
excel_exec()
,
firefox_exec()
,
libreoffice_exec()
,
node_exec()
,
npm_exec()
,
pip_exec()
,
powerpoint_exec()
,
python_exec()
if(exec_available("word")) message(word_exec())
if(exec_available("word")) message(word_exec())