Пример #1
0
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):
Пример #2
0
#!/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
Пример #3
0
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):
Пример #4
0
#!/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')
Пример #5
0
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()
Пример #6
0
#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
Пример #7
0
#!/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')
Пример #8
0
#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