Skip to content
Back to formatted view

Raw Message

Message-ID: <5032c7d1-a201-2931-83ec-133702759a1d@effectivedefense.org>
Date: 2020-02-03T19:30:11Z
From: Spencer Graves
Subject: [R-pkg-devel] finding "logo.jpg" [was: "try" malfunctions on Ubuntu Linux 16.04 LTS, R-release, GCC]
In-Reply-To: <CALEXWq1beDTxeUx0eQH2HqpuyOC8Ev0psw=2mLTjRFsuSGRG9w@mail.gmail.com>

????? Thanks to I?aki Ucar for identifying a second error that 
explained why I still got an error after wrapping one in "try".


 ????? That still leaves a question of how to find a file like 
"logo.jpg" in a platform independant way.


 ??? ? The following had worked for several years and now broke on rhub 
"Ubuntu Linux 16.04 LTS, R-release, GCC" but not on several other 
computers I tried:


 ??? ??????? logo.jpg <- paste(R.home(), "doc", "html", "logo.jpg", sep 
= .Platform$file.sep)


 ????? On that Ubuntu platform, "readJPEG(logo.jpg)" stopped with "Error 
in readJPEG(logo.jpg) : unable to open /usr/lib/R/doc/html/logo.jpg".


 ????? I replaced the above "paste" with the following:


RdocDir <- dir(R.home(), pattern='^doc$', full.names = TRUE)
RhtmlDir <- dir(RdocDir, pattern='^html$', full.names=TRUE)
JPGs <- dir(RhtmlDir, pattern='\\\\.jpg$', full.names=TRUE)
if(length(JPGs)>1){
 ? logoJPG <- paste0(.Platform$file.sep, 'logo.jpg$')
 ? logo.jpg <- grep(logoJPG, JPGs, value=TRUE)
 ? if(length(logo.jpg)>1)logo.jpg <- logo.jpg[1]
 ? if(length(logo.jpg)<1)logo.jpg <- JPGs[1]
} else logo.jpg <- JPGs
if(length(logo.jpg)<1){
 ? cat('logo.jpg not found.\n')
 ? print(R.home())
 ? print(dir(RdocDir))
 ? print(dir(RhtmlDir))
 ? if(!fda::CRAN())stop('logo.jpg not found')
} else {
# length(logo.jpg)==1 so continue:
 ? if(require(jpeg)){
##
## 1.? Shrink as required
##
 ??? Rlogo <- readJPEG(logo.jpg)

...


 ??? ? This gave me no error message, which I believe means that either 
length(logo.jpg) == 1 or fda::CRAN() returns TRUE.? Sadly, I could not 
find the standard test file to see which of these is the case.


 ????? I should proceed to submit the current Ecfun package to CRAN. 
Then I might modify this test sequence to force an error, so I can see 
more what is happening.


 ????? Suggestions?
 ????? Thanks,
 ????? Spencer


On 2020-02-03 03:06, I?aki Ucar wrote:
> On Mon, 3 Feb 2020 at 03:16, Spencer Graves
> <spencer.graves at effectivedefense.org> wrote:
>> Hello, All:
>>
>>
>>         devtools::check_rhub failed to trap an error wrapped in "try",
>> per the email below.  This came from running
>> devtools::check_rhub(Ecfun_dir), where Ecfun_dir = the path to a copy of
>> "https://github.com/sbgraves237/Ecfun".
> That's improbable.
>
>>         This is the development version of Ecfun, which I want to submit
>> to CRAN as soon as I can do so without offending the sensibilities of
>> the overworked CRAN maintainers.
>>
>>
>>         Suggestions?
>>         Thanks,
>>         Spencer Graves
>>
>>
>> -------- Forwarded Message --------
>> Subject:        Ecfun 0.2-2: ERROR
>> Date:   Sun, 02 Feb 2020 23:27:10 +0000
>> From:   R-hub builder <support at rhub.io>
>> To:     spencer.graves at effectivedefense.org
>>
> <snip>
>
>>> ## 2.9.  A more complicated example with elements to eval
>>> ##
>>> logo.jpg <- paste(R.home(), "doc", "html", "logo.jpg",
>> +                   sep = .Platform$file.sep)
>>> if(require(jpeg)){
>> +   Rlogo <- try(readJPEG(logo.jpg))
>> +   if(!inherits(Rlogo, 'try-error')){
>> + # argument list for a call to rasterImage or rasterImageAdj
>> +     RlogoLoc <- list(image=Rlogo,
>> +       xleft.0 = c(NZ=176.5,CH=172,US=171,
>> +                   CN=177,RU= 9.5,UK= 8),
>> +       xleft.1 = c(NZ=176.5,CH=  9,US=-73.5,
>> +                   CN=125,RU= 37, UK= 2),
>> +       ybottom.0=c(NZ=-37,  CH=-34,US=-34,
>> +                   CN=-33,RU= 48, UK=47),
>> +       ybottom.1=c(NZ=-37,  CH= 47,US= 46,
>> +                   CN= 32,RU=55.6,UK=55),
>> +       xright=quote(xleft+xinch(0.6)),
>> +       ytop = quote(ybottom+yinch(0.6)),
>> +       angle.0 =0,
>> +       angle.1 =c(NZ=0,CH=3*360,US=5*360,
>> +                  CN=2*360,RU=360,UK=360)
>> +     )
>> +
>> +     RlogoInterp <- interpPairs(RlogoLoc,
>> +             .proportion=rep(c(0, -1), c(2, 4)) )
>> + # check
>> + ## Don't show:
>> + stopifnot(
>> + ## End(Don't show)
>> + all.equal(names(RlogoInterp),
>> +    c('image', 'xright', 'ytop', 'xleft', 'ybottom', 'angle'))
>> + ## Don't show:
>> + )
>> + ## End(Don't show)
>> + }
>> + # NOTE:  'xleft', and 'ybottom' were created in interpPairs,
>> + # and therefore come after 'xright' and 'ytop', which were
>> + # already there.
>> +
>> + ##
>> + ## 2.10.  using envir
>> + ##
>> +   RlogoDiag <- list(x0=quote(Rlogo.$xleft),
>> +                   y0=quote(Rlogo.$ybottom),
>> +                   x1=quote(Rlogo.$xright),
>> +                   y1=quote(Rlogo.$ytop) )
>> +
>> +   RlogoD <- interpPairs(RlogoDiag, .p=1,
>> +                     envir=list(Rlogo.=RlogoInterp) )
>> + ## Don't show:
>> + stopifnot(
>> + ## End(Don't show)
>> + all.equal(RlogoD, RlogoDiag)
>> + ## Don't show:
>> + )
>> + ## End(Don't show)
>> + }
>> Loading required package: jpeg
>> Error in readJPEG(logo.jpg) : unable to open /usr/lib/R/doc/html/logo.jpg
>> Error in interpPairs.list(RlogoDiag, .p = 1, envir = list(Rlogo. = RlogoInterp)) :
>>     object 'RlogoInterp' not found
>> Calls: interpPairs -> interpPairs.list
>> Execution halted
> There it is: "Error in interpPairs.list [...] 'RlogoInterp' not
> found". That's the error, not the "try". You see the error message
> because you didn't specify "quiet=TRUE", but that doesn't mean that R
> is failing to catch the error. So the second error is the one that
> fails.
>
> I?aki