2017-09-03 17 views
1

最新のRStudioバージョンの番号をhttps://www.rstudio.com/products/rstudio/download/に何らかの形で刻んでダウンロードしてインストールするスクリプトを書くのには苦労しています。最新のRStudioバージョンの取得方法

私はRのプログラマーなので、rvestパッケージを使用してRスクリプトを作成しました。私はRStudioサーバーのダウンロードリンクを掻き集めることができましたが、まだRStudio自体を入手することはできません。

ここでは、Ubuntu用の64ビットRStudioサーバーのダウンロードリンクを取得するためのRコードを示します。

if(!require('stringr')) install.packages('stringr', Ncpus=8, repos='http://cran.us.r-project.org') 
if(!require('rvest')) install.packages('rvest', Ncpus=8, repos='http://cran.us.r-project.org') 

xpath<-'//code[(((count(preceding-sibling::*) + 1) = 3) and parent::*)]' 
url<-'https://www.rstudio.com/products/rstudio/download-server/' 
thepage<-xml2::read_html(url) 
the_links_html <- rvest::html_nodes(thepage,xpath=xpath) 
the_links <- rvest::html_text(the_links_html) 
the_link <- the_links[stringr::str_detect(the_links, '-amd64\\\\.deb')] 
the_r_uri<-stringr::str_match(the_link, 'https://.*$') 
cat(the_r_uri) 

残念ながら、RStudioのデスクトップダウンロードページは完全に異なるレイアウトであり、私はここでも同じアプローチを使用していません。

誰かがこれを手伝ってくれますか?世界のすべてのデータ科学者が手動でRStudioをアップグレードするとは信じられません!


さらに簡単なバージョンのスクリプトがあり、RStudio-serverのバージョンを読み取ります。 Bashのバージョン:

RSTUDIO_LATEST=$(wget --no-check-certificate -qO- https://s3.amazonaws.com/rstudio-server/current.ver) 

またはRバージョン:

scan('https://s3.amazonaws.com/rstudio-server/current.ver', what = character(0)) 

しかしRStudio-デスクトップのバージョンはまだ私を見逃さ。

+0

R Studioは、実行時に更新の有無を確認しませんか? – Spacedman

+0

はい、これは設定可能なオプションですが、ここでは求められていることではありません。 – mdsumner

+0

@mdsumnerはい、しかしRStudioはオープンソースなので、解決策はそこにあります。 – Spacedman

答えて

1

あなたが返されますバージョン文字列でRStudioのcheck_for_updateを照会した場合(しかし、あなたは、これは、毎日のビルドのUbuntu用RStudio Serverです。あなたがとにかく欲しいビルドの種類をターゲットにそれを変更することができます)更新バージョンからそれを取得する場所のURL:

https://www.rstudio.org/links/check_for_update?version=1.0.0

更新バージョン1.0.153 = &更新URL = httpsの%3A%2F%2Fwww.rstudio.com%2Fproducts% 2Frstudio%2Fdownload%2F & up date-message = RStudio%201.0.153%20is%20now%20 available%20%28you%27re%20using%201.0。0%29 &更新-緊急= 0

こちらをご覧ください:

https://github.com/rstudio/rstudio/blob/54cd3abcfc58837b433464c793fe9b03a87f0bb4/src/cpp/session/modules/SessionUpdates.R

をあなたは本当に、私は<a>hrefで取得したいのダウンロードページから、それをこすりしたい場合最初に<td>の最初の<table>がダウンロードされ、「RStudio-」と「.exe」の間の3つのドット区切り数を解析します。 RStudioはすべてのプラットフォームでリリースされているので、Windowsからのダウンロードは十分です。

> url = "https://www.rstudio.com/products/rstudio/download/" 
> thepage<-xml2::read_html(url) 
> html_node(thepage, ".downloads td a") %>% html_attr("href") 
[1] "https://download1.rstudio.org/RStudio-1.0.153.exe" 
+0

これは私が解決した1つのライナーです: 'stringr :: str_match(scan(" https://www.rstudio.org/links/check_for_update?version=1.0.0 "、what = character(0))、 '^ [^ =] + =([^ \\&] +)\\&。*')[[2]] ' –

0

ほぼ-ソリューションはここにあります:

https://raw.githubusercontent.com/rocker-org/rstudio-daily/master/latest.R

あなたがあることをそのスクリプトを変更したいと思う:最新のビルドのために擦るこのスクリプトでは、

https://hub.docker.com/r/rocker/rstudio-daily/~/dockerfile/

それが受け入れるものについてより厳密に、すなわち私はrstudio-server-1.1.355-amd64.debであり、stretchではありません。

+0

ありがとうございます。あなたが置くイミデートリンクはRStudio(サーバー)の毎日のビルド用ですが、簡単に修正できます。安定したRStudio(サーバー)の場合は、 'RSTUDIO_LATEST = $(wget --no-check-certificate -qO- https://s3.amazonaws.com/rstudio-server/current.ver)'を使用します。 –

+0

あなたの本当の問題提案されているのは、 'rocker'はドッキング・コンテナーを使用し、GUIアプリケーションをカプセル化することがないため、RStudioサーバーのみを処理するということです。そして、私はすでに、現在のRStudioサーバのバージョンを読むためのWebスクレイピングスクリプトを持っています。 –

0

誰もが興味を持っている場合は、ここで私の究極のリアルサーバ・デスクトップ・オン・Ubuntuのアップデートスクリプトです。 RStudio-desktop 64bitをインストールし、Fira Consoleフォントを使用できる場合は、https://github.com/tonsky/FiraCode/wiki/RStudio-instructionsのパッチをRStudioに適用して、合字が機能し始めます。

#!/bin/bash 
if dpkg -s rstudio >/dev/null 2>/dev/null; then 
    ver=$(apt show rstudio | grep Version) 
    pattern='^Version: ([0-9.]+)\s*$' 
    if [[ $ver =~ $pattern ]]; then 
     ourversion=${BASH_REMATCH[1]} 
     netversion=$(Rscript -e 'cat(stringr::str_match(scan("https://www.rstudio.org/links/check_for_update?version=1.0.0", what = character(0), quiet=TRUE), "^[^=]+=([^\\&]+)\\&.*")[[2]])') 
     if [[ $ourversion != $netversion ]]; then 
      RSTUDIO_URI=$(Rscript /tmp/get_rstudio_uri.R) 
     fi 
     tee /tmp/get_rstudio_uri.R <<EOF 
if(!require('rvest')) install.packages('rvest', repos='http://cran.us.r-project.org') 
xpath='.downloads:nth-child(2) tr:nth-child(5) a' 
url = "https://www.rstudio.com/products/rstudio/download/" 
thepage<-xml2::read_html(url) 
cat(html_node(thepage, xpath) %>% html_attr("href")) 
EOF 
     RSTUDIO_URI=$(Rscript /tmp/get_rstudio_uri.R) 

     wget -c --output-document /tmp/rstudio.deb $RSTUDIO_URI 
     sudo dpkg -i /tmp/rstudio.deb 
     rm /tmp/rstudio.deb 
     rm /tmp/get_rstudio_uri.R 

     if fc-list |grep -q FiraCode; then 
      if !grep -q "text-rendering:" /usr/lib/rstudio/www/index.htm; then 
       sudo sed -i '/<head>/a<style>*{text-rendering: optimizeLegibility;}<\/style>' /usr/lib/rstudio/www/index.htm 
      fi 
     fi 
    fi 
fi 
関連する問題