Skip to content

Commit ee38106

Browse files
committed
Add pause-on-exit option in config.ini
1 parent 1efa3b5 commit ee38106

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

config.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@
1616
11: 18:00-18:45
1717
12: 18:50-19:35
1818
13: 19:40-20:25
19+
20+
[on-exit]
21+
pause-on-exit = true

main.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
from course import Config, EAMS
2+
from configparser import ConfigParser
23
import sys
34

5+
cfg = ConfigParser()
6+
cfg.read('config.ini')
7+
pause_cfg = cfg.get('on-exit', 'pause-on-exit').strip().lower()
8+
pause_on_exit = False
9+
if pause_cfg == 'true':
10+
pause_on_exit = True
11+
12+
13+
def pause() -> None:
14+
if not pause_on_exit:
15+
return
16+
sys.stdin.flush()
17+
input('按回车键退出...')
18+
19+
420
print('==== CourseTable2ICS for SSPU by ReekyStive ====')
521
username = input('请输入学号: ').strip()
622
password = input('请输入密码: ')
@@ -24,6 +40,7 @@
2440
print('成功')
2541
except:
2642
print('失败')
43+
pause()
2744
sys.exit(1)
2845
print()
2946

@@ -62,6 +79,7 @@
6279

6380
if len(courses) == 0:
6481
print('未找到任何课程')
82+
pause()
6583
sys.exit(1)
6684

6785
print('找到课程:')
@@ -90,5 +108,7 @@
90108
e.generate_ics(courses, date)
91109
except:
92110
print('失败')
111+
pause()
93112
sys.exit(1)
94113
print('已保存: courses.ics')
114+
pause()

0 commit comments

Comments
 (0)