From 504f3b7eec95786d5b558b3db2280d1de862b0e6 Mon Sep 17 00:00:00 2001 From: Arun Pandian Date: Sat, 12 Sep 2020 11:57:08 +0530 Subject: [PATCH] Added User Data Config flag --- colabcode/code.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/colabcode/code.py b/colabcode/code.py index 6432b83..5362158 100644 --- a/colabcode/code.py +++ b/colabcode/code.py @@ -14,9 +14,10 @@ class ColabCode: - def __init__(self, port=10000, password=None, mount_drive=False): + def __init__(self, port=10000, password=None, user_data_dir=None, mount_drive=False): self.port = port self.password = password + self.user_data_dir = user_data_dir self._mount = mount_drive self._install_code() self._install_extensions() @@ -45,8 +46,12 @@ def _run_code(self): os.system(f"fuser -n tcp -k {self.port}") if self._mount and colab_env: drive.mount("/content/drive") - if self.password: + if self.password and self.user_data_dir: + code_cmd = f"PASSWORD={self.password} code-server --port {self.port} --user-data-dir {self.user_data_dir} --disable-telemetry" + elif self.password: code_cmd = f"PASSWORD={self.password} code-server --port {self.port} --disable-telemetry" + elif self.user_data_dir: + code_cmd = f"code-server --port {self.port} --auth none --user-data-dir {self.user_data_dir} --disable-telemetry" else: code_cmd = f"code-server --port {self.port} --auth none --disable-telemetry" with subprocess.Popen(