Esempio n. 1
0
 def querySer(self):
     self.log.info(types.BuiltinMethodType.__name__)
     # property 가져오기
     j_list = []
     section = 'WRI_14'
     config = configparser.ConfigParser(interpolation=None)
     config.read('..\conf\openApi.properties')
     url = config.get(section, 'WRI_14_URL')
     serviceKey = config.get(section, 'WRI_14_SERVICEKEY')
     # 인자 순서 : url,ServiceKey,date,damcode,wal
     # 실제 던질 쿼리
     query = WRI_14(url, serviceKey, self.date, self.damcode, self.walcode, self.pageNo).setUrl()
     try :
         re = Request(query)
         res = re.doReq()
     except Exception as ex :
         self.log.error('쿼리 전송중 에러발생')
         return False
     else :
         self.log.info(res)
         j_list.append(res)
     # page숫자를 파악하기 위한 단계
     if str(res['response']['header']['resultCode']) == '00':
         self.log.info(str(res['response']['body']['totalCount']))
         if type(res['response']['body']['items']) is dict :
             if type(res['response']['body']['items']['item']) is list :
                 # 현재 페이지 * 설정한 row수가 전체 카운트 보다 낮다면
                 pageNo = int(res['response']['body']['pageNo'])
                 totalCount = int(res['response']['body']['totalCount'])
                 numOfRows = int(res['response']['body']['numOfRows'])
                 pageCount = int((totalCount/numOfRows) + 1)
                 if  pageCount > 1 :
                     for i in range(2,pageCount) :
                         self.log.info('페이지 다수 작업 실시')
                         pageNo += 1
                         query = WRI_14(url, serviceKey, self.date, self.damcode, self.walcode, pageNo).setUrl()
                         try :
                             re = Request(query)
                             res = re.doReq()
                         except Exception as ex :
                             self.log.error('쿼리 전송중 에러발생')
                             continue 
                         else : 
                             self.log.info(res)       
                             j_list.append(res)
         else : 
             self.log.info('빈값 재시도')
             self.log.info(str(j_list))
             return False                    
     self.log.info('json 반환 시작') 
     return j_list
Esempio n. 2
0
 def querySer(self):
     j_list = []
     # property 가져오는 공통 클래스
     cfig = config('PRI',
                   'PRI_WaterQualityService_getSgisDrinkWaterList_url',
                   'PRI_SERVICEKEY')
     #query 조합하는 클래스
     query = PRI_02(cfig.reUrl(), cfig.reSerKey(), self.yyyy,
                    self.pageNo).setUrl()
     try:
         re = Request(query)
         res = re.doReq()
     except Exception as ex:
         self.log.error('쿼리 전송중 에러발생')
         return False
     else:
         j_list.append(res)
     if str(res['getSgisDrinkWaterList']['header']['code']) == '00':
         # 현재 페이지 * 설정한 row수가 전체 카운트 보다 낮다면
         pageNo = int(res['getSgisDrinkWaterList']['pageNo'])
         totalCount = int(res['getSgisDrinkWaterList']['totalCount'])
         numOfRows = int(res['getSgisDrinkWaterList']['numOfRows'])
         if totalCount > (pageNo * numOfRows):
             self.pageNo = pageNo + 1
         else:
             self.pageNo = 0
         return j_list
     else:
         self.log.info('서버 비정상 응답 재시도 ')
         return False
Esempio n. 3
0
 def querySer(self):
     j_list = []
     # property 가져오는 공통 클래스
     cfig = config('PRI', 'PRI_05_URL', 'PRI_SERVICEKEY')
     #query 조합하는 클래스
     query = PRI_05(cfig.reUrl(), cfig.reSerKey(), self.ptNoList,
                    self.wmyrList, self.wmodList, self.pageNo).setUrl()
     try:
         re = Request(query)
         res = re.doReq()
     except Exception as ex:
         self.log.error('쿼리 전송중 에러발생')
         return False
     else:
         j_list.append(res)
     if str(res['getWaterMeasuringListMavg']['header']['code']) == '00':
         # 현재 페이지 * 설정한 row수가 전체 카운트 보다 낮다면
         pageNo = int(res['getWaterMeasuringListMavg']['pageNo'])
         totalCount = int(res['getWaterMeasuringListMavg']['totalCount'])
         numOfRows = int(res['getWaterMeasuringListMavg']['numOfRows'])
         pageCount = int((totalCount / numOfRows) + 1)
         if pageCount > 1:
             for i in range(2, pageCount):
                 self.log.info('페이지 다수 작업 실시')
                 pageNo += 1
                 query = PRI_05(cfig.reUrl(), cfig.reSerKey(),
                                self.ptNoList, self.wmyrList, self.wmodList,
                                pageNo).setUrl()
                 try:
                     re = Request(query)
                     res = re.doReq()
                 except Exception as ex:
                     self.log.error('쿼리 전송중 에러발생')
                     continue
                 else:
                     self.log.info(res)
                     j_list.append(res)
         else:
             print('단일 페이지 ')
             return j_list
     else:
         self.log.info('서버 비정상 응답 재시도 ')
         return False
Esempio n. 4
0
 def querySer(self):
     logs().method('querySer 메소드')
     # property 가져오기
     section = 'WALCODE'
     config = configparser.ConfigParser(interpolation=None)
     config.read('..\conf\openApi.properties')
     url = config.get(section, 'WALCODE_URL')
     serviceKey = config.get(section, 'WALCODE_SERVICEKEY')
     # 인자 순서 : url,ServiceKey,date,damcode,wal
     # 실제 던질 쿼리
     query = WALCODE_URL(url, serviceKey, self.damcode).setUrl()
     re = Request(query)
     logs().info('json 반환 시작')
     return re.doReq()
Esempio n. 5
0
 def querySer(self):
     j_list = []
     # property 가져오는 공통 클래스
     cfig = config('WRS_02','waterFlux_fcltyList_url', 'waterFlux_service_key')
     #query 조합하는 클래스
     query = WRS_02(cfig.reUrl(), cfig.reSerKey(), self.divCode).setUrl()
     print('쿼리날리기')
     try :
         re = Request(query)
         res = re.doReq()
     except Exception as ex :
         self.log.error('쿼리 전송중 에러발생')
         return False
     else :
         print(json.dumps(res,indent=4))
         j_list.append(res)
         return j_list