Ejemplo n.º 1
0
def get_stored_username(storageDir):
    ec = ExcelClient(storageDir, sourceIndex = (0,1,2))
    r = {}
    while 1:
        userInfo = ec.getData()
        if userInfo is None: break
        r[userInfo[0]] = [userInfo[1], userInfo[2]]
    return r
Ejemplo n.º 2
0
def get_stored_username(storageDir):
    ec = ExcelClient(storageDir, sourceIndex=(0, 1, 2))
    r = {}
    while 1:
        userInfo = ec.getData()
        if userInfo is None: break
        r[userInfo[0]] = [userInfo[1], userInfo[2]]
    return r
Ejemplo n.º 3
0
def get_stored_cases(storageDir):
    # case_num, case_id, project
    ec = ExcelClient(storageDir, sourceIndex=(0, 2, 3))
    r = {}
    while 1:
        userInfo = ec.getData()
        if userInfo is None: break
        r[userInfo[1]] = [userInfo[0], userInfo[1]]
    return r
Ejemplo n.º 4
0
def get_stored_cases(storageDir):
    # case_num, case_id, project
    ec = ExcelClient(storageDir, sourceIndex=(0, 2, 3))
    r = {}
    while 1:
        userInfo = ec.getData()
        if userInfo is None:
            break
        r[userInfo[1]] = [userInfo[0], userInfo[1]]
    return r
Ejemplo n.º 5
0
def producexml():
    header = ['to', 'to_email', 'from', 'from_email', 'filename', 'created_on', 'subject']
    ec = ExcelClient(outputDir = config.metaStorage, outputHeader = sum([header, ['case_id']], []))
    print 'Please wait for about half a minute'
    nameList = get_stored_username(config.userNameStorage)
    for info in xml_solve(config.xmlInput):
        infoList = [info[key] for key in header]
        if nameList.has_key(infoList[1].split(',')[0]):
            infoList[0] = nameList[infoList[1].split(',')[0]][0]
            infoList.append(nameList[infoList[1].split(',')[0]][1])
        if nameList.has_key(infoList[3]): infoList[2] = nameList[infoList[3]][0]
        ec.storeData(infoList)
    print 'Output succeeded!'
    print 'Please check %s before run the makeuploadfile.py'%config.metaStorage
    print 'You need to fill in the blank case_id'
Ejemplo n.º 6
0
def uploadlog():
    iec = ExcelClient(config.uploadFile, sourceIndex = (0,1,2,4,3))
    oec = ExcelClient(outputDir = config.debugFile, outputHeader = ['case_num', 'case_id', 'date', 'time', 'description'])
    lc = LogClient(config.userID, config.password, config.baseUrl)
    lineNum = 2

    while raw_input('Ready to upload? [y]:') != 'y': pass

    while 1:
        mailInfo = iec.getData()
        if mailInfo is None: break
        if not lc.upload_log(*mailInfo):
            print 'Line %s: upload failed'%lineNum
            oec.storeData(mailInfo[:3] + [mailInfo[4], mailInfo[3]])
        lineNum += 1

    print 'Upload succeeded! Please check %s if you see something failed'%config.debugFile
Ejemplo n.º 7
0
def makeuploadfile():
    print "Getting the %s file." % config.metaStorage
    caseDict = get_stored_cases(config.caseStorage)
    unfoundList = []

    print "Please wait for about half a minute"
    oec = ExcelClient(outputDir=config.uploadFile, outputHeader=["case_num", "case_id", "date", "time", "description"])
    # to, filename, created_on, case_id, subject
    iec = ExcelClient(config.metaStorage, sourceIndex=(0, 4, 5, 7, 6))
    while 1:
        mailInfo = iec.getData()
        if mailInfo is None:
            break
        outputList = []
        for key, value in caseDict.items():
            if "" != mailInfo[3] == key:

                def clear_colon(s):
                    return s.encode("utf8").split(":")[-1].split(":")[-1].replace(" ", "").decode("utf8")

                outputList = sum(
                    [
                        outputList,
                        [
                            value[0],
                            value[1],
                            mailInfo[2].replace("/", "-").split(" ")[0],
                            str(random.randint(4, 7) / 10.0),
                            u"与{0}就{2}进行沟通,并发送{1}给{0}。".format(
                                mailInfo[0], clear_colon(mailInfo[1]), clear_colon(mailInfo[4])
                            ),
                        ],
                    ],
                    [],
                )
        if not outputList:
            unfoundList.append(str(mailInfo[3]))  # print('Case on {} not found'.format(mailInfo[2]))
        oec.storeData(outputList)
    if unfoundList:
        print "Cases not found: " + ", ".join(list(set(unfoundList)))
    print "Output succeeded! Please check %s before run the upload.py" % config.uploadFile
Ejemplo n.º 8
0
def uploadlog():
    iec = ExcelClient(config.uploadFile, sourceIndex = (0,1,2,4,3))
    oec = ExcelClient(outputDir = config.debugFile, outputHeader = ['case_num', 'case_id', 'date', 'time', 'description'])
    lc = LogClient(config.userID, config.password, config.baseUrl)
    lineNum = 2

    while raw_input('Ready to upload? [y]:') != 'y': pass

    while 1:
        mailInfo = iec.getData()
        if mailInfo is None: break
        if not lc.upload_log(*mailInfo):
            print 'Line %s: upload failed'%lineNum
            oec.storeData(mailInfo[:3] + [mailInfo[4], mailInfo[3]])
        lineNum += 1

    print 'Upload succeeded! Please check %s if you see something failed'%config.debugFile
Ejemplo n.º 9
0
def makeuploadfile():
    print 'Getting the %s file.' % config.metaStorage
    caseDict = get_stored_cases(config.caseStorage)
    unfoundList = []

    print 'Please wait for about half a minute'
    oec = ExcelClient(
        outputDir=config.uploadFile,
        outputHeader=['case_num', 'case_id', 'date', 'time', 'description'])
    # to, filename, created_on, case_id, subject
    iec = ExcelClient(config.metaStorage, sourceIndex=(0, 4, 5, 7, 6))
    while 1:
        mailInfo = iec.getData()
        if mailInfo is None: break
        outputList = []
        for key, value in caseDict.items():
            if '' != mailInfo[3] == key:

                def clear_colon(s):
                    return s.encode('utf8').split(':')[-1].split(
                        ':')[-1].replace(' ', '').decode('utf8')

                outputList = sum([
                    outputList,
                    [
                        value[0], value[1], mailInfo[2].replace(
                            '/', '-').split(' ')[0],
                        str(random.randint(4, 7) / 10.0),
                        u'与{0}就{2}进行沟通,并发送{1}给{0}。'.format(
                            mailInfo[0], clear_colon(mailInfo[1]),
                            clear_colon(mailInfo[4]))
                    ]
                ], [])
        if not outputList:
            unfoundList.append(
                str(mailInfo[3]
                    ))  #print('Case on {} not found'.format(mailInfo[2]))
        oec.storeData(outputList)
    if unfoundList:
        print 'Cases not found: ' + ', '.join(list(set(unfoundList)))
    print 'Output succeeded! Please check %s before run the upload.py' % config.uploadFile