Skip to content
This repository was archived by the owner on Sep 15, 2022. It is now read-only.

Commit 968210c

Browse files
committed
Specify ngrok authtoken as param
1 parent 9dff4b4 commit 968210c

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ remocolab.setupVNC()
3030
```
3131

3232
3. (Optional) If you want to run OpenGL applications or any programs that use GPU,
33-
Click "Runtime" -> "Change runtime type" in top menu and change Hardware accelerator to GPU.
33+
Click "Runtime" -> "Change runtime type" in top menu and change Hardware accelerator to GPU.
3434
4. Run that cell
3535
5. Then the message that ask you to copy & paste tunnel authtoken of ngrok will appear.
3636
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.
37+
- You can also specify ngrok token to ``remocolab.setupSSHD()`` or ``remocolab.setupVNC()`` in the code like ``remocolab.setupSSHD(ngrok_token = NGROK_TOKEN_VALUE)``.
3738
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.
3839
- You can also specify ngrok region to ``remocolab.setupSSHD()`` or ``remocolab.setupVNC()`` in the code like ``remocolab.setupSSHD(ngrok_region = "jp")``.
3940
7. remocolab setup ngrok and SSH server. Please wait for it done (about 2 minutes)

remocolab.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,16 @@ def _setupSSHDImpl(ngrok_token, ngrok_region):
119119
print(f"ssh {ssh_common_options} -L 5901:localhost:5901 -p {port} {user_name}@{hostname}")
120120
print("✂️"*24)
121121

122-
def setupSSHD(ngrok_region = None, check_gpu_available = False):
122+
def setupSSHD(ngrok_token = None, ngrok_region = None, check_gpu_available = False):
123123
if check_gpu_available and not _check_gpu_available():
124124
return False
125125

126-
print("---")
127-
print("Copy&paste your tunnel authtoken from https://dashboard.ngrok.com/auth")
128-
print("(You need to sign up for ngrok and login,)")
129-
#Set your ngrok Authtoken.
130-
ngrok_token = getpass.getpass()
126+
if not ngrok_token:
127+
print("---")
128+
print("Copy&paste your tunnel authtoken from https://dashboard.ngrok.com/auth")
129+
print("(You need to sign up for ngrok and login,)")
130+
#Set your ngrok Authtoken.
131+
ngrok_token = getpass.getpass()
131132

132133
if not ngrok_region:
133134
print("Select your ngrok region:")
@@ -266,6 +267,6 @@ def _setupVNC():
266267
universal_newlines = True)
267268
print(r.stdout)
268269

269-
def setupVNC(ngrok_region = None):
270-
if setupSSHD(ngrok_region, True):
270+
def setupVNC(ngrok_token = None, ngrok_region = None):
271+
if setupSSHD(ngrok_token, ngrok_region, True):
271272
_setupVNC()

0 commit comments

Comments
 (0)