[GenABEL-dev] [Genabel-commits] r1772 - pkg/DatABEL/R
L.C. Karssen
lennart at karssen.org
Mon Jul 28 12:07:01 CEST 2014
Hi Maksim,
Thanks for the quick fix!
Lennart
On 28-07-14 11:41, noreply at r-forge.r-project.org wrote:
> Author: maksim
> Date: 2014-07-28 11:41:46 +0200 (Mon, 28 Jul 2014)
> New Revision: 1772
>
> Modified:
> pkg/DatABEL/R/checkPackageVersionOnCRAN.R
> Log:
> Fixed version check from CRAN site
>
> Modified: pkg/DatABEL/R/checkPackageVersionOnCRAN.R
> ===================================================================
> --- pkg/DatABEL/R/checkPackageVersionOnCRAN.R 2014-07-25 14:29:59 UTC (rev 1771)
> +++ pkg/DatABEL/R/checkPackageVersionOnCRAN.R 2014-07-28 09:41:46 UTC (rev 1772)
> @@ -26,35 +26,67 @@
> checkPackageVersionOnCRAN <- function(packageName,baseUrlCRAN="http://cran.r-project.org/web/packages/",
> timeout = 2)
> {
> - # change default timout
> - svtmo <- options("timeout")
> - options("timeout"=timeout)
> - # page to check is
> - pageAddress <- paste(baseUrlCRAN,packageName,sep="/")
> - # establish connection to the CRAN page of the package
> - suppressWarnings(
> - conn <- try( url(pageAddress) , silent=TRUE )
> - )
> - # if connection ok, read full page, store the results in pageContent; if failed, pageContent <- "try-error"
> - if ( all( class(conn) != "try-error") ) {
> - suppressWarnings(
> - pageContent <- try( readLines(conn) , silent=TRUE )
> - )
> - close(conn)
> - } else {
> - pageContent <- "try-error"
> - class(pageContent) <- "try-error"
> - }
> - # restore default timeout
> - options("timeout"=svtmo)
> - # if failed in reading (pageContent is "try-error"), return NULL
> - if (class(pageContent) == "try-error") return(NULL)
> - # parse the page and get string starting with "Package source:"
> - targetLine <- pageContent[grep("source:",pageContent)]
> - # split the string at "Package_" and ".tar.gz"; the element before the last will contain the version
> - splitPattern <- paste(packageName,"_|.tar.gz",sep="")
> - stringSplit <- strsplit(targetLine,splitPattern)
> - cranVersion <- stringSplit[[1]][length(stringSplit[[1]])-1]
> - # return version
> - return(cranVersion)
> +
> +CRAN_mirror_ref <- "http://cran.xl-mirror.nl/src/contrib" # Amsterdam mirror
> +
> +all_cran_packs <- available.packages(contriburl=CRAN_mirror_ref)
> +all_cran_packs_df <- as.data.frame(all_cran_packs)
> +
> +databel_info <- all_cran_packs_df[all_cran_packs_df$Package == "DatABEL",]
> +cranVersion <- as.character(databel_info$Version)
> +
> +return(cranVersion)
> +
> +
> +
> +# Below is an old verion which depends on CRAN site content that is unreliable.
> +
> +# # change default timout
> +# svtmo <- options("timeout")
> +# options("timeout"=timeout)
> +# # page to check is
> +# pageAddress <- paste(baseUrlCRAN,packageName,sep="/")
> +# # establish connection to the CRAN page of the package
> +# suppressWarnings(
> +# conn <- try( url(pageAddress) , silent=TRUE )
> +# )
> +# # if connection ok, read full page, store the results in pageContent; if failed, pageContent <- "try-error"
> +# if ( all( class(conn) != "try-error") ) {
> +# suppressWarnings(
> +# pageContent <- try( readLines(conn) , silent=TRUE )
> +# )
> +# close(conn)
> +# } else {
> +# pageContent <- "try-error"
> +# class(pageContent) <- "try-error"
> +# }
> +# # restore default timeout
> +# options("timeout"=svtmo)
> +# # if failed in reading (pageContent is "try-error"), return NULL
> +# if (class(pageContent) == "try-error") return(NULL)
> +# # parse the page and get string starting with "Package source:"
> +# targetLine <- pageContent[grep("source:",pageContent)]
> +# # split the string at "Package_" and ".tar.gz"; the element before the last will contain the version
> +# splitPattern <- paste(packageName,"_|.tar.gz",sep="")
> +# stringSplit <- strsplit(targetLine,splitPattern)
> +# cranVersion <- stringSplit[[1]][length(stringSplit[[1]])-1]
> +# # return version
> +# return(cranVersion)
> +
> +
> +
> +# Below is a patch received from Marco De Simone <marco.desimone at cbm.fvg.it>. This version is, however, use content if CRAN that is aso unreliable.
> +#
> +#options("timeout"=svtmo)
> +## if failed in reading (pageContent is "try-error"), return NULL
> +#if (class(pageContent) == "try-error") return(NULL)
> +## parse the table inside the page for the cell with the content "Version:" and select the following cell that contains the version"
> +#targetLine <- pageContent[grep("Version:",pageContent)+1]
> +## Strip the html tags <td> and </td> and get the content value of version
> +#splitPattern <- paste("<td>|</td>",sep="")
> +#
> +#cranVersion <- stringSplit[[1]][length(stringSplit[[1]])]
> +## return version
> +#return(cranVersion)
> +
> }
>
> _______________________________________________
> Genabel-commits mailing list
> Genabel-commits at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/genabel-commits
>
--
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
L.C. Karssen
Utrecht
The Netherlands
lennart at karssen.org
http://blog.karssen.org
GPG key ID: A88F554A
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 213 bytes
Desc: OpenPGP digital signature
URL: <http://lists.r-forge.r-project.org/pipermail/genabel-devel/attachments/20140728/57e144ed/attachment.sig>
More information about the genabel-devel
mailing list