Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify extensions to add in init #39

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions colabcode/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@


class ColabCode:
def __init__(self, port=10000, password=None, authtoken=None, mount_drive=False):
def __init__(self, port=10000, password=None, authtoken=None, mount_drive=False,extensions=[]):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def __init__(self, port=10000, password=None, authtoken=None, mount_drive=False,extensions=[]):
def __init__(self, port=10000, password=None, authtoken=None, mount_drive=False, extensions=[]):

self.port = port
self.password = password
self.authtoken = authtoken
self._mount = mount_drive
self._install_code()
self._install_extensions()
self._install_extensions(extensions)
self._start_server()
self._run_code()

Expand All @@ -30,9 +30,11 @@ def _install_code(self):
)
subprocess.run(["sh", "install.sh"], stdout=subprocess.PIPE)

def _install_extensions(self):
def _install_extensions(self,extensions):
for ext in EXTENSIONS:
subprocess.run(["code-server", "--install-extension", f"{ext}"])
for ext in extensions:
subprocess.run(["code-server", "--install-extension", f"{ext}"])

def _start_server(self):
if self.authtoken:
Expand All @@ -49,9 +51,9 @@ def _run_code(self):
if self._mount and colab_env:
drive.mount("/content/drive")
if self.password:
code_cmd = f"PASSWORD={self.password} code-server --port {self.port} --disable-telemetry"
code_cmd = f"PASSWORD={self.password} code-server /content/drive/'My Drive' --port {self.port} --disable-telemetry"
else:
code_cmd = f"code-server --port {self.port} --auth none --disable-telemetry"
code_cmd = f"code-server /content/drive/'My Drive' --port {self.port} --auth none --disable-telemetry"
with subprocess.Popen(
[code_cmd],
shell=True,
Expand Down