Title: | A Binary Download Manager |
---|---|
Description: | Tools and functions for managing the download of binary files. Binary repositories are defined in 'YAML' format. Defining new pre-download, download and post-download templates allow additional repositories to be added. |
Authors: | John Harrison [aut] (original author), Ju Yeong Kim [aut] (rOpenSci maintainer), Jonathan Völkle [cre] |
Maintainer: | Jonathan Völkle <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.3 |
Built: | 2024-11-27 03:39:20 UTC |
Source: | https://github.com/ropensci/binman |
Get application directory
app_dir(appname, check = TRUE)
app_dir(appname, check = TRUE)
appname |
A character string giving the name of the application |
check |
check whether the app given by appname exists or not. |
A character string giving the path of the directory
## Not run: appdir <- app_dir("superduperapp", FALSE) ## End(Not run)
## Not run: appdir <- app_dir("superduperapp", FALSE) ## End(Not run)
Assign directory to download list
assign_directory(dllist, appname)
assign_directory(dllist, appname)
dllist |
A named list of data.frames. The name indicates the platform. The data.frame should contain the version, url and file to be processed. |
appname |
Name to give the app |
A named list of data.frames. The data.frame should contain the version, url and file to be processed, the directory to download the file to and whether the file already exists.
## Not run: tdata <- system.file("testdata", "test_dllist.Rdata", package = "binman") load(tdata) assign_directory(test_dllist, "myapp") ## End(Not run)
## Not run: tdata <- system.file("testdata", "test_dllist.Rdata", package = "binman") load(tdata) assign_directory(test_dllist, "myapp") ## End(Not run)
A Binary Download Manager.
Tools and functions for managing the download of binary files. Binary repositories are defined in 'YAML' format. Defining new pre-download, download and post-download templates allow additional repositories to be added.
Download binaries from repository
download_files(dllist, overwrite = FALSE)
download_files(dllist, overwrite = FALSE)
dllist |
A named list of data.frames. The data.frame should contain the version, url and file to be processed, the directory to download the file to and whether the file already exists. |
overwrite |
Overwrite existing binaries. Default value of FALSE |
A data.frame indicating whether a file was downloaded for a platform.
## Not run: trdata <- system.file("testdata", "test_dlres.Rdata", package = "binman") tldata <- system.file("testdata", "test_dllist.Rdata", package = "binman") load(trdata) load(tldata) dllist <- assign_directory(test_dllist, "myapp") testthat::with_mock( `httr::GET` = function(...) { test_llres }, `base::dir.create` = function(...) { TRUE }, dlfiles <- download_files(dllist) ) ## End(Not run)
## Not run: trdata <- system.file("testdata", "test_dlres.Rdata", package = "binman") tldata <- system.file("testdata", "test_dllist.Rdata", package = "binman") load(trdata) load(tldata) dllist <- assign_directory(test_dllist, "myapp") testthat::with_mock( `httr::GET` = function(...) { test_llres }, `base::dir.create` = function(...) { TRUE }, dlfiles <- download_files(dllist) ) ## End(Not run)
List app versions by platform
list_versions(appname, platform = c("ALL"))
list_versions(appname, platform = c("ALL"))
appname |
A character string giving the name of the application |
platform |
A character vector of platforms to list. Defaults to "ALL" |
A list of platforms with version directories
## Not run: appdir <- app_dir("superduperapp", FALSE) platforms <- LETTERS[1:4] versions <- LETTERS[5:7] mkdirs <- file.path(appdir, outer(platforms, versions, file.path)) chk <- vapply(mkdirs, dir.create, logical(1), recursive = TRUE) expect_true(all(chk)) res <- list_versions("superduperapp") unlink(appdir, recursive = TRUE) ## End(Not run)
## Not run: appdir <- app_dir("superduperapp", FALSE) platforms <- LETTERS[1:4] versions <- LETTERS[5:7] mkdirs <- file.path(appdir, outer(platforms, versions, file.path)) chk <- vapply(mkdirs, dir.create, logical(1), recursive = TRUE) expect_true(all(chk)) res <- list_versions("superduperapp") unlink(appdir, recursive = TRUE) ## End(Not run)
Do not post process dlfiles
noproc_dlfiles(dlfiles)
noproc_dlfiles(dlfiles)
dlfiles |
A data.frame of files by platform and indicating whether they were processed |
Returns a list of character vectors indicating files processed
## Not run: ymlfile <- system.file("exdata", "sampleapp4.yml", package = "binman") trdata <- system.file("testdata", "test_dlres.Rdata", package = "binman") load(trdata) testthat::with_mock( `httr::GET` = function(...) { test_llres }, `base::dir.create` = function(...) { TRUE }, procyml <- process_yaml(ymlfile) ) procyml ## End(Not run)
## Not run: ymlfile <- system.file("exdata", "sampleapp4.yml", package = "binman") trdata <- system.file("testdata", "test_dlres.Rdata", package = "binman") load(trdata) testthat::with_mock( `httr::GET` = function(...) { test_llres }, `base::dir.create` = function(...) { TRUE }, procyml <- process_yaml(ymlfile) ) procyml ## End(Not run)
Pre download bitbucket downloads template function
predl_bitbucket_downloads( url, platform, history, appname, platformregex = platform, versionregex = "\\d+(?:\\.\\d+)+" )
predl_bitbucket_downloads( url, platform, history, appname, platformregex = platform, versionregex = "\\d+(?:\\.\\d+)+" )
url |
A url giving the bitbucket download JSON for a project. As an example https://bitbucket.org/ariya/phantomjs/downloads the phantomjs project has an asset JSON available at https://api.bitbucket.org/2.0/repositories/ariya/phantomjs/downloads?pagelen=100 |
platform |
A character vector of platform names |
history |
The maximum number of files to get for a platform |
appname |
Name of the app |
platformregex |
A filter for platforms. Defaults to the platform |
versionregex |
A regex for retrieving the version. |
A named list of data.frames. The name indicates the
platform. The data.frame should contain the version, url and file
to be processed. Used as input for download_files
or
an equivalent.
## Not run: bbdata <- system.file("testdata", "test_bitbucketdl.json", package = "binman" ) platform <- c("linux64", "linux32", "windows", "macosx") platformregex <- c("linux-x86_64", "linux-i686", "windows", "macosx") bbdllist <- predl_bitbucket_downloads( url = bbdata, platform, history = 3L, appname = "binman_chromedriver", platformregex ) ## End(Not run)
## Not run: bbdata <- system.file("testdata", "test_bitbucketdl.json", package = "binman" ) platform <- c("linux64", "linux32", "windows", "macosx") platformregex <- c("linux-x86_64", "linux-i686", "windows", "macosx") bbdllist <- predl_bitbucket_downloads( url = bbdata, platform, history = 3L, appname = "binman_chromedriver", platformregex ) ## End(Not run)
Pre download Github assets template function
predl_github_assets( url, platform, history, appname, fileregex = "", platformregex = platform, versionregex = c("", "") )
predl_github_assets( url, platform, history, appname, fileregex = "", platformregex = platform, versionregex = c("", "") )
url |
A url giving the github asset JSON for a project. As an example https://github.com/mozilla/geckodriver/releases the geckodriver project has an asset JSON available at https://api.github.com/repos/mozilla/geckodriver/releases |
platform |
A character vector of platform names |
history |
The maximum number of files to get for a platform |
appname |
Name of the app |
fileregex |
A filter for files |
platformregex |
A filter for platforms. Defaults to the platform |
versionregex |
A regex for retrieving the version. |
A named list of data.frames. The name indicates the
platform. The data.frame should contain the version, url and file
to be processed. Used as input for download_files
or
an equivalent.
## Not run: gadata <- system.file("testdata", "test_gitassets.json", package = "binman" ) platform <- c("linux64", "win64", "macos") gadllist <- predl_github_assets( url = gadata, platform, history = 3L, appname = "binman_chromedriver" ) ## End(Not run)
## Not run: gadata <- system.file("testdata", "test_gitassets.json", package = "binman" ) platform <- c("linux64", "win64", "macos") gadllist <- predl_github_assets( url = gadata, platform, history = 3L, appname = "binman_chromedriver" ) ## End(Not run)
Pre-Download Google Storage template function
predl_google_storage( url, platform, history, appname, fileregex = "\\.zip$", platformregex = platform, versionregex = c(paste0("(.*)/.*", fileregex), "\\1") )
predl_google_storage( url, platform, history, appname, fileregex = "\\.zip$", platformregex = platform, versionregex = c(paste0("(.*)/.*", fileregex), "\\1") )
url |
A url giving the JSON bucket listings for a project. For example: http://chromedriver.storage.googleapis.com/index.html lists the chromedriver files but https://www.googleapis.com/storage/v1/b/chromedriver/o/ is the JSON listings for the project. |
platform |
A character vector of platform names |
history |
The maximum number of files to get for a platform |
appname |
Name of the app |
fileregex |
A filter for files |
platformregex |
A filter for platforms. Defaults to the platform names. |
versionregex |
A regex for retrieving the version. |
A named list of data.frames. The name indicates the
platform. The data.frame should contain the version, url and file
to be processed. Used as input for download_files
or
an equivalent.
## Not run: gsdata <- system.file("testdata", "test_googstor.json", package = "binman" ) platform <- c("linux64", "win32", "mac64") gsdllist <- predl_google_storage( url = gsdata, platform, history = 5L, appname = "binman_chromedriver" ) ## End(Not run)
## Not run: gsdata <- system.file("testdata", "test_googstor.json", package = "binman" ) platform <- c("linux64", "win32", "mac64") gsdllist <- predl_google_storage( url = gsdata, platform, history = 5L, appname = "binman_chromedriver" ) ## End(Not run)
Process a yaml file. The file defines the pre-download function, the download function and the post download function.
process_yaml(ymlfile, verbose = TRUE)
process_yaml(ymlfile, verbose = TRUE)
ymlfile |
A file in a YAML format defining the pre-download/ download and post download functions together with their arguments. |
verbose |
If TRUE, include status messages (if any) |
A list of files processed (downloaded and post processed)
## Not run: ymlfile <- system.file("exdata", "sampleapp.yml", package = "binman") trdata <- system.file("testdata", "test_dlres.Rdata", package = "binman") load(trdata) testthat::with_mock( `httr::GET` = function(...) { test_llres }, `base::dir.create` = function(...) { TRUE }, `utils::unzip` = function(zipfile, ...) { zipfile }, procyml <- process_yaml(ymlfile) ) procyml ## End(Not run)
## Not run: ymlfile <- system.file("exdata", "sampleapp.yml", package = "binman") trdata <- system.file("testdata", "test_dlres.Rdata", package = "binman") load(trdata) testthat::with_mock( `httr::GET` = function(...) { test_llres }, `base::dir.create` = function(...) { TRUE }, `utils::unzip` = function(zipfile, ...) { zipfile }, procyml <- process_yaml(ymlfile) ) procyml ## End(Not run)
Remove application files/directories for a given platform
rm_platform(appname, platform = c("ALL"))
rm_platform(appname, platform = c("ALL"))
appname |
A character string giving the name of the application |
platform |
A character vector indicating the platform to remove. Defaults to "ALL" |
Returns a logical vector indicating whether the removal of platform was successful. Return is invisible.
## Not run: appdir <- app_dir(appname, FALSE) platforms <- LETTERS[1:4] versions <- LETTERS[5:7] mkdirs <- file.path(appdir, outer(platforms, versions, file.path)) chk <- vapply(mkdirs, dir.create, logical(1), recursive = TRUE) appver <- list_versions(appname) rm_platform(appname, platforms[2:3]) unlink(appdir, recursive = TRUE) ## End(Not run)
## Not run: appdir <- app_dir(appname, FALSE) platforms <- LETTERS[1:4] versions <- LETTERS[5:7] mkdirs <- file.path(appdir, outer(platforms, versions, file.path)) chk <- vapply(mkdirs, dir.create, logical(1), recursive = TRUE) appver <- list_versions(appname) rm_platform(appname, platforms[2:3]) unlink(appdir, recursive = TRUE) ## End(Not run)
Remove application version for a given platform
rm_version(appname, platform, version = c("ALL"))
rm_version(appname, platform, version = c("ALL"))
appname |
A character string giving the name of the application |
platform |
A character string indicating the platform. |
version |
A character vector of versions to remove. Defaults to "ALL" |
Returns a logical vector indicating whether the removal of version was successful. Return is invisible.
## Not run: appdir <- app_dir(appname, FALSE) platforms <- LETTERS[1:4] versions <- LETTERS[5:7] mkdirs <- file.path(appdir, outer(platforms, versions, file.path)) chk <- vapply(mkdirs, dir.create, logical(1), recursive = TRUE) appver <- list_versions(appname) rm_version(appname, platforms[2], versions[1:2]) unlink(appdir, recursive = TRUE) ## End(Not run)
## Not run: appdir <- app_dir(appname, FALSE) platforms <- LETTERS[1:4] versions <- LETTERS[5:7] mkdirs <- file.path(appdir, outer(platforms, versions, file.path)) chk <- vapply(mkdirs, dir.create, logical(1), recursive = TRUE) appver <- list_versions(appname) rm_version(appname, platforms[2], versions[1:2]) unlink(appdir, recursive = TRUE) ## End(Not run)
Unzip/Untar downloaded files. Keeps the original zip file
unziptar_dlfiles(dlfiles, chmod = FALSE)
unziptar_dlfiles(dlfiles, chmod = FALSE)
dlfiles |
A data.frame of files by platform and indicating whether they were processed |
chmod |
change the mode of the unarchived file/files to "755" so they are executable on unix like systems. |
Returns a list of character vectors indicating files processed
## Not run: ymlfile <- system.file("exdata", "sampleapp.yml", package = "binman") trdata <- system.file("testdata", "test_dlres.Rdata", package = "binman") load(trdata) testthat::with_mock( `httr::GET` = function(...) { test_llres }, `base::dir.create` = function(...) { TRUE }, `utils::unzip` = function(zipfile, ...) { zipfile }, procyml <- process_yaml(ymlfile) ) procyml ## End(Not run)
## Not run: ymlfile <- system.file("exdata", "sampleapp.yml", package = "binman") trdata <- system.file("testdata", "test_dlres.Rdata", package = "binman") load(trdata) testthat::with_mock( `httr::GET` = function(...) { test_llres }, `base::dir.create` = function(...) { TRUE }, `utils::unzip` = function(zipfile, ...) { zipfile }, procyml <- process_yaml(ymlfile) ) procyml ## End(Not run)