Skip to content

Instantly share code, notes, and snippets.

@jeroen
Created August 19, 2014 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeroen/48be418e87100d7ea1a2 to your computer and use it in GitHub Desktop.
Save jeroen/48be418e87100d7ea1a2 to your computer and use it in GitHub Desktop.
#Assume httr 0.4
library(httr)
stopifnot(packageVersion("httr") >= "0.4")
#submit a package to CRAN, step 1
submit <- function(name, email, pkg, comment = "Thank you", popup = TRUE){
stopifnot(file.exists(pkg))
req1 = httr::POST (
url = "http://xmpalantir.wu.ac.at/cransubmit/index2.php",
encode = "multipart",
body = list(
pkg_id = "",
name = name,
email = email,
uploaded_file = httr::upload_file(pkg),
comment = comment,
upload = "Upload package"
)
)
stop_for_status(req1)
url1 <- req1$url
#success message
strerr1 <- substring(regmatches(url1, gregexpr("strErr=[^&]*", url1)), 8)
message(chartr('+',' ', strerr1))
pkg_id <- substring(regmatches(url1, gregexpr("pkg_id=[^&]*", url1)), 8)
#Confirm
req2 <- httr::POST(
url = "http://xmpalantir.wu.ac.at/cransubmit/index2.php",
encode = "multipart",
body = list (
pkg_id = pkg_id,
name = name,
email = email,
uploaded_file = "",
comment = comment,
policy_check = "1/",
submit = "Submit package"
)
)
stop_for_status(req2)
url2 <- req2$url
#success message
strerr2 <- substring(regmatches(url2, gregexpr("strErr=[^&]*", url2)), 8)
if(nchar(strerr2)) message(strerr2)
#show final page
if(isTRUE(popup)){
browseURL(req2$url)
} else {
message("The maintainer of this package has been sent an email to confirm the submission.")
}
}
#Test
#submit("Jeroen Ooms", "jeroen.ooms@stat.ucla.edu", "~/workspace/opencpu_1.4.4.tar.gz")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment