Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maxent_versions not working properly and get_maxent unable to unpack latest version (3.4.4) #18

Open
LocoDelAssembly opened this issue Jul 13, 2024 · 0 comments

Comments

@LocoDelAssembly
Copy link

maxent_versions function is not currently parsing archived releases list from GitHub properly because the page layout changed. I'm afraid I cannot spend more time on this now so I'll share what I have (still not great because it returns duplicated versions but otherwise seems to work):

maxent_versions <- function(include_beta=FALSE) {
  u <- 'https://github.com/mrmaxent/Maxent/tree/master/ArchivedReleases'
  v <- xml2::read_html(u) %>%
    rvest::html_nodes(xpath = '//a[@href[contains(.,"/tree/master/ArchivedReleases")]]') %>% # Changed xpath here
    rvest::html_text()
  v <- v[-1] # Likely no longer needed
  cfg <- httr::set_config(httr::config(ssl_verifypeer = 0L))
  on.exit(httr::set_config(httr::config(cfg)))
  u2 <- 'https://biodiversityinformatics.amnh.org/open_source/maxent/index.html'
  v2 <- httr::GET(u2) %>% 
    httr::content(encoding='UTF-8') %>% 
    rvest::html_nodes(xpath='//*[@id="Form"]/h3[1]') %>% 
    rvest::html_text()
  v2 <- gsub('^\\s*Current\\s+version\\s*|\\s*$', '', v2)
  v <- c(v, v2)
  v <- sort(v[v!=''])
  if(!include_beta) grep('beta', v, invert=TRUE, value=TRUE) else v
}

With get_maxent given above issue the function downloads from biodiversityinformatics.amnh.org and the problem is that the jar file is not at the root of the ZIP file anymore (if ever), so in:

utils::unzip(f, exdir=d, files='maxent.jar', junkpaths=TRUE)

fails because the files param should be files='maxent/maxent.jar' (in reality the code should attempt locating the file recursively instead but I don't know how to do that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant