import logging from ReportParser import ReportParser from Contants import Contants from LoggingUtil import getLogger import sys default_encoding = 'utf-8' if sys.getdefaultencoding() != default_encoding: reload(sys) sys.setdefaultencoding(default_encoding) # TODO (robin): contition filter # TODO (robin): add realtime report # TODO (robin): design function and params log = getLogger('Report') log.setLevel(logging.DEBUG) class Report(): def __init__(self,userid): self.userid = userid apiSDKSoapClient = ApiSDKSoapClient('sms','v3','ReportService',userid) newClient = apiSDKSoapClient.newSoapClient() self.client = newClient self.requestParams={} self.request = None self.reportTypeDesc = None self.__init_requestParams() def __init_requestParams(self):
#!/usr/bin/python #encoding=utf-8 from GetReport import Report from ReportParser import ReportParser from datetime import datetime from datetime import date, timedelta import sys, os from optparse import OptionParser from MongoUtil import save_report from Contants import Contants from LoggingUtil import getLogger log = getLogger('Pipeline') def fetchReport(userid, reportType, startDate, endDate, fileDirPath, device, unitOfTime): report = Report(userid) report.getReport(reportType, startDate, endDate, fileDirPath, device, unitOfTime) ####parse csv device = report.requestParams['device'] unitOfTime = report.requestParams['unitOfTime'] parseReport = ReportParser(report) ##import into db for rowDict in parseReport.parseCsvFileBody(): rowDict['deviceName'] = Contants.deviceName[device] rowDict['deviceId'] = device rowDict['reportType'] = reportType
from MongoUtil import save_report from LoggingUtil import getLogger from datetime import datetime,date,timedelta import sys default_encoding = 'utf-8' if sys.getdefaultencoding() != default_encoding: reload(sys) sys.setdefaultencoding(default_encoding) # TODO (robin): contition filter # TODO (robin): add realtime report # TODO (robin): design function and params log = getLogger() class Report(): def __init__(self): # init client stub baiduApiSoap = BaiduNmsApiClient('ReportService') client = baiduApiSoap.client self.client = client self.requestParams={} self.request = None self.reportTypeDesc = None self.__init_requestParams() def __init_requestParams(self):
#!/usr/bin/python #encoding=utf-8 from GetReport import Report from ReportParser import ReportParser from datetime import datetime from datetime import date, timedelta import sys,os from optparse import OptionParser from MongoUtil import save_report from Contants import Contants from LoggingUtil import getLogger log = getLogger('Pipeline') def fetchReport(userid,reportType,startDate,endDate,fileDirPath,device,unitOfTime): report = Report(userid) report.getReport(reportType,startDate,endDate,fileDirPath,device,unitOfTime) ####parse csv device = report.requestParams['device'] unitOfTime = report.requestParams['unitOfTime'] parseReport = ReportParser(report) ##import into db for rowDict in parseReport.parseCsvFileBody(): rowDict['deviceName']= Contants.deviceName[device] rowDict['deviceId']= device rowDict['reportType']=reportType rowDict['unitOfTimeName']= Contants.unitOfTimeName[unitOfTime] rowDict['unitOfTimeId']=unitOfTime rowDict['createDate']=datetime.today().strftime('%Y-%m-%d %H:%M:%S')
from ReportParser import ReportParser from Contants import Contants from LoggingUtil import getLogger import sys default_encoding = 'utf-8' if sys.getdefaultencoding() != default_encoding: reload(sys) sys.setdefaultencoding(default_encoding) # TODO (robin): contition filter # TODO (robin): add realtime report # TODO (robin): design function and params log = getLogger('Report') log.setLevel(logging.DEBUG) class Report(): def __init__(self, userid): self.userid = userid apiSDKSoapClient = ApiSDKSoapClient('sms', 'v3', 'ReportService', userid) newClient = apiSDKSoapClient.newSoapClient() self.client = newClient self.requestParams = {} self.request = None self.reportTypeDesc = None self.__init_requestParams()
#coding=utf-8 import suds import sys import ConfigParser import traceback as tb from Contants import Contants from LoggingUtil import getLogger log = getLogger('Client') ''' webservice client ''' class ApiSDKSoapClient(): #client params __productline=None __version=None __service=None __url=None __username=None __password=None __token=None __target=None __accessToken=None __action=None __client=None #conf params urlconf=None usernameconf=None passwordconf=None tokenconf=None
#!/usr/bin/python #encoding=utf-8 from GetReport import Report from ReportParser import ReportParser from datetime import datetime from datetime import date, timedelta import sys,os from optparse import OptionParser from MongoUtil import save_report from LoggingUtil import getLogger log = getLogger() def fetchReport(reportType,startDate,endDate,fileDirPath): report = Report() report.getReport(reportType,startDate,endDate,fileDirPath) ####parse csv parseReport = ReportParser(report) ##import into db for rowDict in parseReport.parseCsvFileBody(): rowDict['reportType']=reportType rowDict['createDate']=datetime.today().strftime('%Y-%m-%d %H:%M:%S') save_report(rowDict) log.info('save data into mongodb successful.') def test(): yesterdayStr = (date.today()-timedelta(1)).strftime('%Y-%m-%d')
#coding=utf-8 import suds import sys import ConfigParser import traceback as tb from Contants import Contants from LoggingUtil import getLogger log = getLogger('Client') ''' webservice client ''' class ApiSDKSoapClient(): #client params __productline = None __version = None __service = None __url = None __username = None __password = None __token = None __target = None __accessToken = None __action = None __client = None #conf params urlconf = None usernameconf = None