Skip to content

Commit

Permalink
feat: update upload py and scrollbar in terminal
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Lauber <jan.lauber@protonmail.ch>
  • Loading branch information
janlauber committed Jun 18, 2023
1 parent c693638 commit 3d99323
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
51 changes: 43 additions & 8 deletions kubelab-fill/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def post_request(url, data):
try:
headers = {'Content-type': 'application/json'}
response = requests.post(url, data=json.dumps(data), headers=headers)
print(response.text)
return response
except requests.exceptions.RequestException as e:
print(e)

Expand All @@ -51,7 +51,34 @@ def main():
'description': lab.description,
'docs': prefix + lab.docs
}
post_request(labs_upload_url, data)
response = post_request(labs_upload_url, data)
if response.status_code == 200:
print("Lab {} uploaded successfully".format(lab.title))
# convert response.content bytes to json
labId = json.loads(response.text)['id']
print("Lab {} id: {}".format(lab.title, labId))
for exercise in exercises:
if exercise.lab == lab.title:
data = {
'title': exercise.title,
'description': exercise.description,
'docs': prefix + exercise.docs,
'hint': prefix + exercise.hint,
'solution': prefix + exercise.solution,
'check': prefix + exercise.check,
'bootstrap': prefix + exercise.bootstrap,
'lab': labId
}
response = post_request(exercises_upload_url, data)
if response.status_code == 200:
print("Exercise {} uploaded successfully".format(exercise.title))
else:
print("Exercise {} upload failed".format(exercise.title))


else:
print("Lab {} upload failed".format(lab.title))



def get_labs_from_dir(path):
Expand Down Expand Up @@ -88,17 +115,25 @@ def get_exercises_from_dir(path, level=1, parent=None):
Exercise(
title=name,
description=name,
docs=prename+"/docs.md",
hint=prename+"/hint.md",
solution=prename+"/solution.md",
check=prename+"/check.sh",
bootstrap=prename+"/bootstrap.sh",
lab=parent
docs=parent+"/"+prename+"/docs.md",
hint=parent+"/"+prename+"/hint.md",
solution=parent+"/"+prename+"/solution.md",
check=parent+"/"+prename+"/check.sh",
bootstrap=parent+"/"+prename+"/bootstrap.sh",
lab=parse_name(parent)
)
)
exercises.extend(get_exercises_from_dir(full_path, level + 1, parent=name))
return exercises

def parse_name(name):
name = name.split("_")
number = name[0]
name = name[1:]
name = " ".join(name)
name = number+" "+name.title()
return name


if __name__ == '__main__':
main()
6 changes: 0 additions & 6 deletions kubelab-ui/src/lib/components/Console.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,4 @@
height: 100%;
}
/* style scrollbar */
div :global(.xterm-viewport) {
overflow-y: hidden !important;
overflow-x: hidden !important;
}
</style>

0 comments on commit 3d99323

Please sign in to comment.