r-spatial / rgee

Google Earth Engine for R
https://r-spatial.github.io/rgee/
Other
668 stars 146 forks source link

ee_check_gcloud() works only for linux #351

Open rohan-pink opened 9 months ago

rohan-pink commented 9 months ago

At submit an issue, please attached the following information of your rgee session:

library(rgee)

# Initialize the Earth Engine module.
ee_Initialize()

# Print metadata for a DEM dataset.
print(ee$Image('USGS/SRTMGL1_003')$getInfo())

Attach your Python (reticulate) configuration:

library(reticulate)
py_config()

3.11.5

Description

ee_check_gcloud() currently works only for linux systems, not Windows.

What I Did

suggested changes to function

ee_check_gcloud <- function() {
  sysinf <- Sys.info()

  if (sysinf[["sysname"]] == "Windows") {
    return <- system("gcloud --help", intern = FALSE, ignore.stdout = TRUE)
    if (return != 0) {
      stop("gcloud failed [os.system('gcloud --help')]. Please check\n for any errors above and install gcloud if needed ", 
           "(https://cloud.google.com/sdk/docs/install).")
    } else {
      cat("gcloud installed and accessible on the comand line.\n")
    }  
  } else {  #Linux
    os <- reticulate::import("os")
    return <- os$system(
      "gcloud --help > /dev/null 2>&1"
    )
    if (return != 0) {
      stop(
        "gcloud failed [os.system('gcloud --help')]. Please check
      for any errors above and install gcloud if needed ",
      "(https://cloud.google.com/sdk/docs/install)."
      )
    } else {
      cat("gcloud installed and accessible on the comand line.\n")
    } 
  }
}