コード例 #1
0
ファイル: identity.py プロジェクト: AlertProject/STARDOM
def people_mapping_init():

    user_to_identity_dict={}

    alert_conn = db.get_alert_connection()

    cvsanaly_conn = db.get_cvsanaly_connection()

    # Apparently this is a compound statement and
    # we should close and reopen the cursor
    alert_cursor=alert_conn.cursor ()
    alert_cursor.execute (QRY_DROP_TABLE)
    alert_cursor.execute (QRY_CREATE_TABLE)
    alert_cursor.close()

    csv_cursor = cvsanaly_conn.cursor ()
    all_cvsanaly_people = csv_cursor.execute (QRY_SELECT_ALL_PEOPLE)

    counter = 0
    for x in range(all_cvsanaly_people):
        row=csv_cursor.fetchone ()
        user_id=row[0]
        name=row[1]
        email = row[2]
        repl=' '
        email = re.sub(r"[-_\+\.@]", repl, email)
        name = re.sub(r"[\']", repl, name)

        print "Processing %s => %s " % (user_id,email,)

        alert_cursor=alert_conn.cursor ()
        alert_cursor.execute (QRY_SELECT_IDENTITY, (email,))
        alert_row=alert_cursor.fetchone ()


        if alert_row is None:
            print '%s NOT FOUND!!! ' % email
            continue
        identity_id=alert_row[0]
        print "Identity id %s found for %s " % (identity_id,email,)

        alert_cursor.close();
        alert_cursor = alert_conn.cursor();
        rows = alert_cursor.execute (u"""insert into identity_csvid VALUES(%s,%s,%s,%s) ;""", (identity_id,user_id,name,email,))

        print "Created %s rows " % rows
        user_to_identity_dict[user_id]=identity_id
        alert_cursor.close ()

    csv_cursor.close()
    alert_conn.commit()
    alert_conn.close()
    cvsanaly_conn.close()


    return user_to_identity_dict
コード例 #2
0
ファイル: fix_bt_file.py プロジェクト: pombredanne/STARDOM
def fix_file():
    people_map_dict={}
    people_map_dict = identity.people_mapping_init()

    spamReader = csv.reader(open(config.io_betweenness_file, 'rb'),delimiter='\t', quotechar='|')
    spamWriter = csv.writer(open(config.io_betweeness_output, 'w'),delimiter=',', quotechar='"')

    conn = db.get_alert_connection()
    cursor=conn.cursor()

    first = False

    for row in spamReader:
#
#        if not first:
#            first = True
#            continue

        edge_identity_id=people_map_dict[int(row[0])]
        no_edge_identity_id=people_map_dict[int(row[2])]

        edge_btness=row[1]
        no_edge_btness=row[3]


        cursor.execute("SELECT * FROM identity_csvid WHERE identity_id=%s",edge_identity_id)
        edge_row = cursor.fetchone()

        cursor.execute("SELECT * FROM identity_csvid WHERE identity_id=%s",no_edge_identity_id)
        no_edge_row = cursor.fetchone()

        spamWriter.writerow([
            edge_row[0],
            edge_row[1],
            edge_btness,
            edge_row[2],
            edge_row[3],
            no_edge_row[0],
            no_edge_row[1],
            no_edge_btness,
            no_edge_row[2],
            no_edge_row[3]
            ])

    cursor.close()
    conn.close()
コード例 #3
0
    for metric_name, values in metrics.iteritems():

        if values[0] >= 1:
            bugAWriter.writelines("@ATTRIBUTE %s NUMERIC\n" % metric_name)



    bugAWriter.writelines("@ATTRIBUTE betweeness NUMERIC\n")
    bugAWriter.writelines("\n@DATA\n")



    people_map_dict={}
    people_map_dict = identity.people_mapping_init()

    alert_conn = db.get_alert_connection()
    spamReader = csv.reader(open(config.io_betweenness_file, 'rb'),delimiter='\t', quotechar='|')

    for row in spamReader:

        identity_id=people_map_dict[int(row[0])]
        btness=row[1]

        #tdesc = "select m.id,quantity,m.identity_id,created_at from scm_activity_metric as scm inner join metric_quantitative as mq on scm.id=mq.id inner join metric as m on scm.id=m.id where m.identity_id='"+str(identity_id)+"' order by quantity desc limit 1;"

        result =[]
        result.append(identity_id)

        for metric_name, values in metrics.iteritems():

            if values[0] >= 1:
コード例 #4
0
def people_mapping_init():

    user_to_identity_dict = {}

    alert_conn = db.get_alert_connection()

    cvsanaly_conn = db.get_cvsanaly_connection()

    # Apparently this is a compound statement and
    # we should close and reopen the cursor
    alert_cursor = alert_conn.cursor()
    alert_cursor.execute(QRY_DROP_TABLE)
    alert_cursor.execute(QRY_CREATE_TABLE)
    alert_cursor.close()

    csv_cursor = cvsanaly_conn.cursor()
    all_cvsanaly_people = csv_cursor.execute(QRY_SELECT_ALL_PEOPLE)

    counter = 0
    for x in range(all_cvsanaly_people):
        row = csv_cursor.fetchone()
        user_id = row[0]
        name = row[1]
        email = row[2]
        repl = ' '
        email = re.sub(r"[-_\+\.@]", repl, email)
        name = re.sub(r"[\']", repl, name)

        print "Processing %s => %s " % (
            user_id,
            email,
        )

        alert_cursor = alert_conn.cursor()
        alert_cursor.execute(QRY_SELECT_IDENTITY, (email, ))
        alert_row = alert_cursor.fetchone()

        if alert_row is None:
            print '%s NOT FOUND!!! ' % email
            continue
        identity_id = alert_row[0]
        print "Identity id %s found for %s " % (
            identity_id,
            email,
        )

        alert_cursor.close()
        alert_cursor = alert_conn.cursor()
        rows = alert_cursor.execute(
            u"""insert into identity_csvid VALUES(%s,%s,%s,%s) ;""", (
                identity_id,
                user_id,
                name,
                email,
            ))

        print "Created %s rows " % rows
        user_to_identity_dict[user_id] = identity_id
        alert_cursor.close()

    csv_cursor.close()
    alert_conn.commit()
    alert_conn.close()
    cvsanaly_conn.close()

    return user_to_identity_dict
コード例 #5
0
    for metric_name, values in metrics.iteritems():

        if values[0] >= 1:
            bugAWriter.writelines("@ATTRIBUTE %s NUMERIC\n" % metric_name)



    bugAWriter.writelines("@ATTRIBUTE betweeness NUMERIC\n")
    bugAWriter.writelines("\n@DATA\n")



    people_map_dict={}
    people_map_dict = identity.people_mapping_init()

    alert_conn = db.get_alert_connection()
    spamReader = csv.reader(open(config.io_betweenness_file, 'rb'),delimiter='\t', quotechar='|')

    for row in spamReader:

        identity_id=people_map_dict[int(row[0])]
        btness=row[1]

        #tdesc = "select m.id,quantity,m.identity_id,created_at from scm_activity_metric as scm inner join metric_quantitative as mq on scm.id=mq.id inner join metric as m on scm.id=m.id where m.identity_id='"+str(identity_id)+"' order by quantity desc limit 1;"

        result =[]
        result.append(identity_id)

        for metric_name, values in metrics.iteritems():

            if values[0] >= 1: