isCSVwrite = True isLogDown = True # Log configureation servertype = 's3' frameSize = -1 # get appkey information appKeyFilename = APPKEY_FILENAME appKeyfile = open(appKeyFilename, 'r') appKey = appKeyfile.readlines().pop() # logdate='20170422' logdate = '20170331' logtype = 'core' # 'core','active','schedule','beacon'가능 logDownWorker = downlog.LogDownloader() logDownWorker.setLogInfo(logdate, logtype, servertype) #logDownWorker.downLogRecord() # 이 주석을 풀면 로그 다운로드 기능을 포함한다 # dailyDataFrameWorker = genDataFrame.DailyLogWorker() dailyDataFrameWorker.init(logtype, logdate, appKey) # logtype logdate appkey로 원하는 로그 정보를 초기화 dailyDataFrameWorker.makeDailyLogfileList( ) # 해당 날짜의 로그폴더에 다운로드된 로그 파일의 리스트를 생성 linenum = 0 while dailyDataFrameWorker.nextDailyLogFile(): # 로그파일을 하나씩 브라우징 하는 루프 dailyDataFrameWorker.loadDailyLog( 'grep') # grep을 이용해서 로그 추출 (json load방식보다 매우 빠름 currDataFrame = dailyDataFrameWorker.getDailyDataFrame( -1) # 로그로 부터 데이터 프레임 생성
servertype = 's3' frameSize = -1 # get appkey information appKeyFilename = APPKEY_FILENAME appKeyfile = open(appKeyFilename, 'r') appKey = appKeyfile.readlines().pop() logdate = '20170330' device_amount = 500000 # the number of device period = 13 # the number of rcvd trials # beacon 로그 처리 logtype = 'beacon' loadingType = 'json' if isLogDown: downBeaconLogDownWorker = downlog.LogDownloader() downBeaconLogDownWorker.setLogInfo(logdate, logtype, servertype) downBeaconLogDownWorker.downLogRecord() # Beacon Log in json format to dataframe format dailybeaconlogworker = genDataFrame.DailyLogWorker() dailybeaconlogworker.init(logtype, logdate, appKey) dailybeaconlogworker.get_log_files(loadingType) #data frame generation if len(dailybeaconlogworker.mFileNameList) > 0: beaconLogDailyDataFrame = dailybeaconlogworker.getDailyDataFrame(-1) beaconLogDailyDataFrame.sort_values(by='deviceTime') if isCSVwrite: if not (beaconLogDailyDataFrame.empty):
# log profiles if IsCashSlide: # 캐시 슬라이드 appname = '캐시슬라이드' appkey = '5e228d8d-c869-437c-ae70-8dd87b089f64' currdate = '20170326' elif IsCLiP: # CLiP appname = 'CLiP' appkey = '6227368d-7a59-4805-a110-24b23e8c87b3' currdate = '20170309' # core 로그 처리 if IsCoreLog == True: logtype = 'core' downCoreLogWorker = downlog.LogDownloader() downCoreLogWorker.setLogInfo(currdate, logtype, servertype) # downCoreLogWorker.downLogRecord() dailycorelogworker = genDataFrame.DailyLogWorker() dailycorelogworker.init(logtype, currdate, appkey) dailycorelogworker.makeDailyLogfileList() dailycorelogworker.nextDailyLogFile() # Data loading t = time.time() dailycorelogworker.loadDailyLog('grep') elapsed = time.time() - t print '# [runDailyLogAnalysis] Data loading time = %s' % elapsed # data framing