File tree Expand file tree Collapse file tree 1 file changed +26
-5
lines changed
Expand file tree Collapse file tree 1 file changed +26
-5
lines changed Original file line number Diff line number Diff line change 22import tempfile
33import subprocess
44import getpass
5+ import shutil
56from textwrap import dedent
67
78def setup_shiny ():
@@ -56,16 +57,36 @@ def _get_rsession_env(port):
5657 'RSTUDIO_DEFAULT_R_VERSION' : version ,
5758 }
5859
59- return {
60- 'command' : [
61- 'rsession' ,
60+ def _get_rsession_cmd (port ):
61+ # Other paths rsession maybe in
62+ other_paths = [
63+ # When rstudio-server deb is installed
64+ '/usr/lib/rstudio-server/bin/rsession' ,
65+ # When just rstudio deb is installed
66+ '/usr/lib/rstudio/bin/rsession' ,
67+ ]
68+ if shutil .which ('rsession' ):
69+ executable = 'rsession'
70+ else :
71+ for op in other_paths :
72+ if os .path .exists (op ):
73+ executable = op
74+ break
75+ else :
76+ raise FileNotFoundError ('Can not find rsession in PATH' )
77+
78+ return [
79+ executable ,
6280 '--standalone=1' ,
6381 '--program-mode=server' ,
6482 '--log-stderr=1' ,
6583 '--session-timeout-minutes=0' ,
6684 '--user-identity=' + getpass .getuser (),
67- '--www-port={port}'
68- ],
85+ '--www-port=' + str (port )
86+ ]
87+
88+ return {
89+ 'command' : _get_rsession_cmd ,
6990 'environment' : _get_rsession_env ,
7091 'title' : 'RStudio' ,
7192 'icon' : os .path .join (os .path .dirname (os .path .abspath (__file__ )), 'icons' , 'rstudio.svg' )
You can’t perform that action at this time.
0 commit comments