-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
99 lines (92 loc) · 3.87 KB
/
test.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import os, json, io
import MealInfo, ClassInfo, EventInfo, Weather
import datetime, time, os, time, sys, traceback
data = io.open('config.json', mode='r', encoding='utf-8').read()
conf = json.loads(data)
mod_mealinfo = MealInfo.MealInfo(
conf['Open-NEIS-API']['KEY'],
conf['Open-NEIS-API']['SD_SCHUL_CODE'],
conf['Open-NEIS-API']['ATPT_OFCDC_SC_CODE']
)
mod_classinfo = ClassInfo.ClassInfo(
conf['Open-NEIS-API']['KEY'],
conf['Open-NEIS-API']['SD_SCHUL_CODE'],
conf['Open-NEIS-API']['ATPT_OFCDC_SC_CODE']
)
mod_eventinfo = EventInfo.EventInfo(
conf['Open-NEIS-API']['KEY'],
conf['Open-NEIS-API']['SD_SCHUL_CODE'],
conf['Open-NEIS-API']['ATPT_OFCDC_SC_CODE']
)
mod_weather = Weather.Weather(
conf['KMA-Weather-Api']['ZoneID']
)
while True:
print('1. get EventInfo')
print('2. get ClassInfo')
print('3. get WeatherInfo')
print('4. get MealInfo')
comm = input('')
if comm == '1':
#Event Info
print('=========EventInfo========')
try:
mod_eventinfo.load()
event_list = mod_eventinfo.get(2019, 12, 10, 3) # 2019년 12월 10일부터 최대 3개의 일정을 불러옴
for event in event_list:
print('일시: ',event['AA_YMD'])
print('내용: ',event['EVENT_NM'])
print('대상: ',event['TARGET'])
print('휴일여부: ',event['SBTR_DD_SC_NM'])
print('---------------------------------')
except Exception as e:
print('Faield to load EventInfo %s' % str(e))
elif comm == '2':
#Class Info
print('=========ClassInfo========')
try:
mod_classinfo.set_date(2019, 12, 10)# 2019년 12월 10일의 시간표를 불러옴
class_list = mod_classinfo.get(2, 3)# 그 중 2학년 3반의 시간표를 불러옴
for cls in class_list:
print('교시: ',cls['PERIO'])
print('이름: ',cls['ITRT_CNTNT'])
print('---------------------------------')
except Exception as e:
print('Faield to load ClassInfo %s' % str(e))
elif comm == '3':
#Weather Info
print('=========WeatherInfo========')
try:
mod_weather.get()
print(mod_weather.now)
for weather in mod_weather.data:
print('날짜:',weather['day'])#0:오늘 1:내일 2:모레
print('시간:',weather['hour'])#시간(24)
print('구름상태:',weather['sky'])#1:맑음 3:구름 많음 4: 흐림
print('기후상태:',weather['pty'])#0:맑음 1:비구름 2:구름 3:눈구름 4:소나기
print('강수확률:',weather['pop'])#강수확률
print('풍속:',weather['ws'])#풍속
print('---------------------------------')
except Exception as e:
print('Faield to load WeatherInfo %s' % str(e))
elif comm == '4':
#Meal Info
print('=========MealInfo========')
try:
mod_mealinfo.set_date(2019, 12)
meal_list = mod_mealinfo.get(19)
#print(meal_list.keys())
if len(meal_list) > 0:
print('........아침...........')
for meal in meal_list[0]['DDISH_NM'].split('<br/>'):
print(meal)
if len(meal_list) > 1:
print('........점심...........')
for meal in meal_list[1]['DDISH_NM'].split('<br/>'):
print(meal)
if len(meal_list) > 2:
print('........저녁...........')
for meal in meal_list[2]['DDISH_NM'].split('<br/>'):
print(meal)
except Exception as e:
print('Faield to load MealInfo %s' % str(e))