diff --git a/README.md b/README.md index a7e1c4a..efe13fa 100644 --- a/README.md +++ b/README.md @@ -30,10 +30,11 @@ remocolab.setupVNC() ``` 3. (Optional) If you want to run OpenGL applications or any programs that use GPU, -Click "Runtime" -> "Change runtime type" in top menu and change Hardware accelerator to GPU. +Click "Runtime" -> "Change runtime type" in top menu and change Hardware accelerator to GPU. 4. Run that cell 5. Then the message that ask you to copy & paste tunnel authtoken of ngrok will appear. Login to ngrok, click Auth on left side menu, click Copy, return to Google Colaboratory, paste it to the text box under the message and push enter key. + - You can also specify ngrok token to ``remocolab.setupSSHD()`` or ``remocolab.setupVNC()`` in the code like ``remocolab.setupSSHD(ngrok_token = NGROK_TOKEN_VALUE)``. 6. Select your ngrok region. Select the one closest to your location. For example, if you were in Japan, type jp and push enter key. - You can also specify ngrok region to ``remocolab.setupSSHD()`` or ``remocolab.setupVNC()`` in the code like ``remocolab.setupSSHD(ngrok_region = "jp")``. 7. remocolab setup ngrok and SSH server. Please wait for it done (about 2 minutes) diff --git a/remocolab.py b/remocolab.py index cd4ba0d..c90db56 100644 --- a/remocolab.py +++ b/remocolab.py @@ -119,15 +119,16 @@ def _setupSSHDImpl(ngrok_token, ngrok_region): print(f"ssh {ssh_common_options} -L 5901:localhost:5901 -p {port} {user_name}@{hostname}") print("✂️"*24) -def setupSSHD(ngrok_region = None, check_gpu_available = False): +def setupSSHD(ngrok_token = None, ngrok_region = None, check_gpu_available = False): if check_gpu_available and not _check_gpu_available(): return False - print("---") - print("Copy&paste your tunnel authtoken from https://dashboard.ngrok.com/auth") - print("(You need to sign up for ngrok and login,)") - #Set your ngrok Authtoken. - ngrok_token = getpass.getpass() + if not ngrok_token: + print("---") + print("Copy&paste your tunnel authtoken from https://dashboard.ngrok.com/auth") + print("(You need to sign up for ngrok and login,)") + #Set your ngrok Authtoken. + ngrok_token = getpass.getpass() if not ngrok_region: print("Select your ngrok region:") @@ -266,6 +267,6 @@ def _setupVNC(): universal_newlines = True) print(r.stdout) -def setupVNC(ngrok_region = None): - if setupSSHD(ngrok_region, True): +def setupVNC(ngrok_token = None, ngrok_region = None): + if setupSSHD(ngrok_token, ngrok_region, True): _setupVNC()