code-server-liek

This commit is contained in:
Cai
2025-09-17 07:46:38 +00:00
parent 50a570eccf
commit 025c8c1a20
12 changed files with 797 additions and 1511 deletions

View File

@@ -33,6 +33,29 @@ def desktop(user_uuid, course_id, chapter_name, lesson_name):
except subprocess.CalledProcessError as e:
print(f"Error creating directory {path_dir} details {str(e)}")
try:#使用sudo创建shared_group
subprocess.run(["sudo", "groupadd", f"shared_group_{user_id}"], check=True)
except subprocess.CalledProcessError as e:
print(f"Error creating shared_group: {e}")
try:#使用sudo将user_id加入shared_group
subprocess.run(["sudo", "usermod", "-a", "-G", f"shared_group_{user_id}", user_id], check=True)
# 自己也加入
subprocess.run(["sudo", "usermod", "-a", "-G", f"shared_group_{user_id}", 'flask'], check=True)
except subprocess.CalledProcessError as e:
print(f"Error adding user {user_id} to shared_group: {e}")
try:#将文件
subprocess.run(["sudo", "chown", "-R", f"flask:shared_group_{user_id}", user_home], check=True)
subprocess.run(["sudo", "chmod", "-R", "770", path_dir], check=True)
except subprocess.CalledProcessError as e:
print(f"Error changing directory {path_dir} to shared_group_{user_id}: {e}")
try:#继承目录
subprocess.run(["sudo", "chmod", "g+s", path_dir], check=True)
except subprocess.CalledProcessError as e:
print(f"Error changing directory {path_dir} to shared_group_{user_id}: {e}")
chatmanager = ChatManager()
current_app.extensions["user_uuid2chatmanager"][user_uuid] = chatmanager
code_server_port = 10000 + int(uuid.uuid4().int % 10000)
@@ -52,6 +75,8 @@ def desktop(user_uuid, course_id, chapter_name, lesson_name):
r'handle_path\s+/vsc' + re.escape(user_id) + r'/\* {.*?reverse_proxy.*?}',
re.DOTALL
)
for i in range(len(lines)):
if (lines[i].strip()==''): lines[i]=''
content = "".join(lines)
if pattern.search(content):
new_content = pattern.sub('', content)