-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstart.py
executable file
·40 lines (33 loc) · 1.12 KB
/
start.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/python
import os
import subprocess
#use first part of email address as username
hub_user = os.environ['JUPYTERHUB_USER']
username = hub_user.split('@')[0]
# create shared folder for user
my_shared_folder = f'/shared/users/{username}'
if not os.path.exists(my_shared_folder):
os.makedirs(my_shared_folder)
print(f'{my_shared_folder} created!')
else:
print(f'{my_shared_folder} exists!')
# change directory to shared folder
os.chdir(my_shared_folder)
# clone training material
try:
subprocess.run(["git", "clone", "https://github.com/hytest-org/training-2023-CSDMS.git"])
print('cloned workshop repository!')
except:
print('failed to clone workshop repository')
# copy kerchunk tutorial (and any other repos in /shared/users/repos)
try:
subprocess.run(["cp", "-R", "/shared/users/repos", "."])
print(f'copied repos to {my_shared_folder}')
except:
print(f'failed to copy repos to {my_shared_folder}')
# copy bucket credentials
try:
subprocess.run(["cp", "-R", "/shared/users/.aws", f'/home/{hub_user}/'])
print('copied cloud credentials')
except:
print('failed to copy cloud credentials')