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

Add a post proxy.R clean up function #56

Open
cjrace opened this issue Feb 10, 2024 · 2 comments · May be fixed by #98
Open

Add a post proxy.R clean up function #56

cjrace opened this issue Feb 10, 2024 · 2 comments · May be fixed by #98
Assignees
Labels
enhancement New feature or request

Comments

@cjrace
Copy link
Contributor

cjrace commented Feb 10, 2024

We often see analysts struggle now who've ran proxy.R in the past (or new starts that have unwittingly ran it). The aim would be to have something is an equivalent function we can point to now that wipes the slate clean for them.

Not 100% on the way to do this, but it would be neat to have a semi-nuclear, wipe out any old settings that might be causing gremlins and errors now. Specifically making sure we unset anything that was previously set in proxy.R.

@cjrace cjrace added the enhancement New feature or request label Feb 10, 2024
@cjrace
Copy link
Contributor Author

cjrace commented Feb 18, 2024

Here is the last version of proxy.R before we removed it:

setup_proxy <- function(){

  # Ask the user for their password
  password <- rstudioapi::askForPassword("Please provide your Windows Password to authenticate.")

  # Construct proxy url using username and password
  proxy_encoded_url <- URLencode(
    paste0(
      "http://ad\\",
      Sys.getenv("USERNAME"),
      ":",
      password,
      "@mwg.proxy.ad.hq.dept:9090"
    ))

  # Construct commands to create environment variables
  http_proxy_cmd <-  paste0("setx http_proxy ", proxy_encoded_url)
  https_proxy_cmd <-  paste0("setx https_proxy ", proxy_encoded_url)

  # Create system environment variables
  system(http_proxy_cmd)
  system(https_proxy_cmd)

  # Set download file method for renv
  system("setx RENV_DOWNLOAD_FILE_METHOD wininet")

  # Pip folder variable
  pip_folder <- file.path(Sys.getenv("APPDATA"), "pip")

  # Create pip.ini file with trusted website for python
  if (!dir.exists(pip_folder)) dir.create(pip_folder)
  
  # SSL verify false (to make Azure Devops work internally). Analyst should only pull from trusted repos.
  system("git config --global http.sslVerify false")

  write("[global]
trusted-host = pypi.python.org
               pypi.org
               files.pythonhosted.org",
        file = file.path(pip_folder, "pip.ini"))

}

@rmbielby rmbielby self-assigned this Mar 25, 2024
@rmbielby
Copy link
Contributor

Thinking this would be a network diagnostics tool, rather than setting any system variables itself. So gives a readout of what settings could be causing any issues.

@rmbielby rmbielby linked a pull request Nov 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants