KAIST 포털 사이트에서 캘린더를 확인합니다.
[
{
"id": 32,
"year": 2024,
"semester": 3,
"beginning": "2024-09-02 15:00:00",
"end": "2024-12-20 14:59:00",
"courseRegistrationPeriodStart": "2024-08-12 03:30:00",
"courseRegistrationPeriodEnd": "2024-08-16 14:59:00",
"courseAddDropPeriodEnd": "2024-09-09 14:59:00",
"courseDropDeadline": "2024-10-18 14:59:00",
"courseEvaluationDeadline": "2024-12-13 14:59:00",
"gradePosting": "2024-12-26 01:00:00",
"courseDesciptionSubmission": "2024-05-03 14:59:00"
}
]
Dart
복사
$ sudo docker exec -it otlplus-back /bin/bash
ubuntu-172-31-16-235:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
49c60a0de152 docker-back "gunicorn otlplus.ws…" 4 months ago Up 11 days 0.0.0.0:8022->22/tcp, :::8022->22/tcp, 0.0.0.0:58000->8000/tcp, :::58000->8000/tcp otlplus-back
dcdc44adf050 node:20 "docker-entrypoint.s…" 5 months ago Up 5 months otlplus-front
ubuntu-172-31-16-235:~$ sudo docker exec -it otlplus-back /bin/bash
root:/var/www/otlplus# screen -R otl
Dart
복사
# sh db_update_script.sh >>/root/a.log 2>&1
Ctrl+A,D
[detached from 5052.otl]
root:/var/www/otlplus# tail -f db_update_script.log
Creating new lecture ( AH)
Creating new lecture ( AI)
Creating new lecture ( AJ)
Creating new lecture ( AK)
Creating new lecture ( AL)
Creating new lecture ( AN)
Creating new lecture ( AO)
Creating new lecture ( AP)
Creating new lecture ( AQ)
......
Dart
복사
Importing scholardb for 2024-1
{정상 로그 생략}
Extracting exam time information...
{정상 로그 생략}
Extracting class time information...
{정상 로그 생략}
Importing scholardb for 2024-2
{정상 로그 생략}
Extracting exam time information...
...
Traceback (most recent call last):
File "/home/otlplus/db.py", line 31, in <module>
log(f"Sample Resp: {result[0]}")
IndexError: list index out of range
...
scp: /tmp/otl_db_dump_result: No such file or directory
...
rm: cannot remove '/tmp/otl_db_dump_result': No such file or directory
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/var/www/otlplus/apps/subject/management/commands/import-scholardb.py", line 74, in handle
self._import_scholardb(y, s, exclude_lecture, {
File "/var/www/otlplus/apps/subject/management/commands/import-scholardb.py", line 305, in _import_scholardb
exam_time_rows = execute(host, port, user, password, exam_time_query)
File "/var/www/otlplus/scholardb_access.py", line 11, in synced_func
return func(*args, **kws)
File "/var/www/otlplus/scholardb_access.py", line 27, in execute
result = pickle.load(open("/tmp/otl_db_dump_result", "rb"), encoding="bytes")
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/otl_db_dump_result'
start updating Professors' course_list
Professors' course_list changed
2024 1
Shell
복사
volumes/scripts/do_import_scholardb.py
import os
from datetime import datetime
'''
f = open("/otl.log", "a")
f.write("Update Scholar DB Start\n")
f.write(str(datetime.now()))
f.write("\n")
f.close()
'''
os.chdir('/var/www/otlplus')
os.system('python manage.py import-scholardb --user=**** --password=**** --host=**** --port=**** --use-default-semester --expand-semester-by=-2')
'''
f = open("/otl.log", "a")
f.write("Update Scholar DB Finish\n")
f.close()
'''
Python
복사
--use-default-semester --expand-semester-by=-2
--year=2024 --semester=3
apps/subject/management/commands/import-scholardb.py
300~328 라인 주석처리
print("Extracting exam time information...")
exam_time_query = "SELECT * FROM view_OTL_exam_time WHERE lecture_year = %d AND lecture_term = %d" % (
target_year,
target_semester,
)
exam_time_rows = execute(host, port, user, password, exam_time_query)
print("exam_times")
ExamTime.objects.filter(lecture__year__exact=target_year, lecture__semester=target_semester).delete()
for row in exam_time_rows:
print(row)
myrow = row[:]
lecture_key = {
"deleted": False,
"code": myrow[2],
"year": int(myrow[0]),
"semester": int(myrow[1]),
"department": Department.objects.filter(id=int(myrow[4]))[0],
"class_no": myrow[3].strip(),
}
try:
lecture = Lecture.objects.get(**lecture_key)
exam_time = ExamTime(lecture=lecture)
exam_time.day = int(myrow[5]) - 1
exam_time.begin = time(hour=myrow[6].hour, minute=myrow[6].minute)
exam_time.end = time(hour=myrow[7].hour, minute=myrow[7].minute)
print(f"Updating exam time for {lecture}")
exam_time.save()
except Lecture.DoesNotExist:
print(f"Exam-time for non-existing lecture {myrow[2]}; skip it...")
Python
복사
sudo docker compose -f ./docker/docker-compose.prod.yml down
sudo docker compose -f ./docker/docker-compose.prod.yml up -d --build
Shell
복사
Shell
복사
sudo docker exec -it otlplus-back /bin/bash
apt install screen
screen -R otl
sh /var/www/otlplus/db_update_script.sh >>/root/a.log 2>&1
Shell
복사
ctrl+A,D
tail -f db_update_script.log