예제 #1
0
def get_re_jobid(jobid):
    conn = MySQLdb.connect(host='20.0.2.15',
                           user='******',
                           db='JOB',
                           passwd='123456',
                           port=3306)
    print 'connect succeed'
    resu = []
    #    print "shshshhhhhhhhhhhhhhhhhhhhhhhhhhh"
    try:
        cursor = conn.cursor()
        if int(jobid) <= 10000000:
            database = "JOB_log_all"
        elif int(jobid) <= 40500000:
            database = "JOB_log_4050"
        elif int(jobid) <= 41000000:
            database = "JOB_log_4100"
        elif int(jobid) <= 41500000:
            database = "JOB_log_4150"
        elif int(jobid) <= 42000000:
            database = "JOB_log_4200"
        else:
            database = "JOB_log"


#Modified by tyzhang. To maintain all the trace in mysql.
        sql1 = "select JOBID,JOB_NAME,PROGRAM_NAME,STARTTIME,ENDTIME,RUNTIME,CNC,CORE,NODELIST from " + database + " where jobid=" + str(
            jobid) + " and RUNTIME<>0 order by PROGRAM_NAME"
        #sql1="select JOBID,USER,STATE,QUEUE,CNC,STARTTIME,ENDTIME,RUNTIME,PROGRAM_NAME,NODELIST from JOB_log where "+ite+" and "+item3+" order by PROGRAM_NAME"
        #print sql1
        cursor.execute(sql1)
        result1 = cursor.fetchall()
        conn.commit()
        cursor.close()
        #print result1
        re = []
        for date in result1:
            re.append(date)
        re.sort()
        #print re
        if len(re) < 1:
            print "NONE"
        else:
            for val in re:
                id = val[0]
                jname = val[1]
                pname = val[2]
                stime = str(val[3])
                etime = str(val[4])
                atime = val[5]
                cnc = val[6]
                core = val[7]
                node = val[8]
                node = node.split(",")
                resu.append(
                    [id, jname, pname, stime, etime, atime, cnc, core, node])
    except Exception as e:
        print e
        conn.rollback()
    return resu
예제 #2
0
파일: dbschema.py 프로젝트: mtvessel/FDTool
def abh2str(li, re):
    attrsep = '' if upcsplit else ';'
    li = list(li)
    re = list(re)
    if shouldsort:
        li.sort()
        re.sort()
    return string.join(li, attrsep) + '->' + string.join(re, attrsep)
예제 #3
0
def searchjob(time1, time2):  #ENDTIME between time1 and time2
    conn = MySQLdb.connect(host='20.0.2.12',
                           user='******',
                           db='JOB',
                           passwd='',
                           port=3306)
    print 'connect succeed'
    try:
        cursor = conn.cursor()
        item1 = "STARTTIME <= '" + time2 + "' and ENDTIME > '" + time2 + "'"
        item2 = "ENDTIME > '" + time1 + "' and ENDTIME <= '" + time2 + "'"
        item3 = "ENDTIME = '0000-00-00 00:00:00'" + " and STARTTIME < '" + time2 + "'"
        ite = "NODELIST <> '-' and RUNTIME <> 0"
        ite1 = "QUEUE not like '%x86%'"
        sql1 = "select JOBID,JOB_NAME,PROGRAM_NAME,STARTTIME,ENDTIME,RUNTIME,CNC,CORE,NODELIST from JOB_log_all where " + ite + " and " + ite1 + " and " + item2 + " order by PROGRAM_NAME"
        #sql1="select JOBID,USER,STATE,QUEUE,CNC,STARTTIME,ENDTIME,RUNTIME,PROGRAM_NAME,NODELIST from JOB_log where "+ite+" and "+item3+" order by PROGRAM_NAME"
        #print sql1
        cursor.execute(sql1)
        result1 = cursor.fetchall()
        conn.commit()
        cursor.close()
        re = []
        for date in result1:
            re.append(date)
        re.sort()
        resu = []
        if len(re) < 1:
            print "NONE"
        else:
            for val in re:
                id = val[0]
                jname = val[1]
                pname = val[2]
                stime = str(val[3])
                etime = str(val[4])
                atime = val[5]
                cnc = val[6]
                core = val[7]
                node = val[8]
                node = node.split(",")
                resu.append(
                    [id, jname, pname, stime, etime, atime, cnc, core, node])
    except Exception as e:
        print e
        conn.rollback()
    return resu
예제 #4
0
def scorehim(him):
    
    sample1=him
    tsample1=nltk.sent_tokenize(sample1)
    #print(tsample1)
    stopwrds=set(stopwords.words('english'))

    tsample=nltk.word_tokenize(sample1)



    #Refine Data
    ntsample2=[w for w in tsample if not w in stopwrds]
    ntsample=[]
    for i in ntsample2:
        ntsample.append(i.lower())
    ntsampler=[i for i in ntsample if i.isalpha()]

    

    ntsampler = list(filter(None, ntsampler)) 
    ntsampler.sort()
    #for i in ntsampler:
        #print(i)    
        
    #print(ntsample,"\n")
    #print(ntsampler)




    #Word Count
    countsam=[]
    count=0
    for i in range(len(ntsampler)):
        if ntsampler[i] not in countsam:
            countsam.append(ntsampler[i])

    countsam.sort()
    b=[]
    for i in countsam:
        c=ntsampler.count(i)
        b.append(c)
    #print(countsam)
    #print(b)






    #Scoring
    exps = [np.exp(i) for i in b]
    sum_of_exps = sum(exps)
    f = [j/sum_of_exps for j in exps]

    g=dict(zip(countsam,f))
    li=g.items()


    #Ranking Sentences
    senval=[]
    for i in tsample1:
            
            val=0
            senword=nltk.word_tokenize(i)
            for j in senword:
                if j in countsam:
                    pl=countsam.index(j)
                    val+=f[pl]
            senval.append(val)

    d=[]
    re=[]
    d=senval
    d.sort()
    if len(d)<5:
        for i in d:
            re.append(i)
    else:
        for i in range(1,6):
            re.append(d[i])
    re.sort()
    fs=dict(zip(tsample1,senval))
    fs2=fs.items()


        
    #Selecting Sentence
    summary=[]
    for i in re:
        v=senval.index(i)
        summary.append(tsample1[v])
        
        
    return(summary)