Skip to content

Commit

Permalink
Merge pull request #100 from MoaRoom/feat/#97
Browse files Browse the repository at this point in the history
Fix extension support
  • Loading branch information
NayeonKeum committed Sep 29, 2023
2 parents a0f8381 + 8aed9a4 commit 8fb6d66
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions resources/images/professor-ubuntu/server/getValueAndTime_c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
start=`date +%s.%N`

/usr/bin/gcc $1 -o $2/test.out
$2/test.out > values.txt
$2/test.out > $2/values.txt

finish=`date +%s.%N`


diff=$( echo "$finish - $start" | bc -l )
/usr/bin/echo $diff > time.txt
/usr/bin/echo $diff > $2/time.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
start=`date +%s.%N`

/usr/bin/g++ -o $2/test $1
$2/test > values.txt
$2/test > $2/values.txt

finish=`date +%s.%N`


diff=$( echo "$finish - $start" | bc -l )
/usr/bin/echo $diff > time.txt
/usr/bin/echo $diff > $2/time.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

start=`date +%s.%N`

/usr/bin/python3 $1 > values.txt
/usr/bin/python3 $1 > $2/values.txt

finish=`date +%s.%N`


diff=$( echo "$finish - $start" | bc -l )
/usr/bin/echo $diff > time.txt
/usr/bin/echo $diff > $2/time.txt
6 changes: 3 additions & 3 deletions resources/images/professor-ubuntu/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ async def get_assignment(id: str, assignment_id: str):
# Complie differs by extension
if file_path.split(".")[-1] == "py":
os.system(
f"/bin/bash {curr_path}/getValueAndTime_python.sh {file_path}")
f"/bin/bash {curr_path}/getValueAndTime_python.sh {file_path} {dir_path}")
elif file_path.split(".")[-1] == "c":
os.system(
f"/bin/bash {curr_path}/getValueAndTime_c.sh {file_path}")
f"/bin/bash {curr_path}/getValueAndTime_c.sh {file_path} {dir_path}")
elif file_path.split(".")[-1] == "cpp":
os.system(
f"/bin/bash {curr_path}/getValueAndTime_cpp.sh {file_path}")
f"/bin/bash {curr_path}/getValueAndTime_cpp.sh {file_path} {dir_path}")
else:
print("지원되지 않는 파일 형식입니다.")
f = open(f"{curr_path}/values.txt", "r")
Expand Down
9 changes: 5 additions & 4 deletions resources/images/student-ubuntu/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ async def read_files_from_dir(dir_path: str = None):
returnDict = {}
file_list = os.listdir(decoded_dir_path)
for file in file_list:
f = open(f"{decoded_dir_path}/{file}", "r")
content = f.read()
returnDict[file] = content
f.close()
if file.split('.')[-1] in {"py", "c", "cpp"}:
f = open(f"{decoded_dir_path}/{file}", "r")
content = f.read()
returnDict[file] = content
f.close()
return json.dumps(returnDict)

0 comments on commit 8fb6d66

Please sign in to comment.