Пример #1
0
def setExportable(data):
    email = data.get('email', None)
    exportable = data.get('exportable', 'false')

    if not email:
        tangelo.content_type("application/json")
        stmt = (
            " UPDATE email SET exportable='false' "	
        )
        with newman_connector() as read_cnx:
            with execute_nonquery(read_cnx.conn(), stmt) as qry:
                return { "success" : "true" }
        #return tangelo.HTTPStatusCode(400, "invalid service call - missing id")
    
    tangelo.content_type("application/json")
    stmt = (
        " UPDATE email SET exportable= %s WHERE id = %s "	
    )
    with newman_connector() as read_cnx:
        with execute_nonquery(read_cnx.conn(), stmt, exportable, email ) as qry:
            return { "email" : queryEmail(email) }
Пример #2
0
def setExportMany(data):
    emails = data.get('emails', [])
    exportable= 'true' if data.get('exportable', True) else 'false'
    stmt = (
        " UPDATE email SET exportable=%s WHERE id = %s "	
    )
    with newman_connector() as cnx:
        for email in emails: 
            with execute_nonquery(cnx.conn(), stmt, exportable, email) as qry:
                pass
    tangelo.content_type("application/json")
    return { 'exported' : emails }
Пример #3
0
    def addEmail(self, id, threadid, dir, category, datetime, from_addr, tos, ccs, bccs, subject, body, tosize, ccsize, bccsize, attachsize, attach, bodysize, location, line_num):

        stmt = ("insert into email " 
                "(id, threadid, dir, category, datetime, from_addr, tos, "
                "ccs, bccs, subject, body, tosize, ccsize, bccsize, attachsize, "
                "attach, bodysize, location, line_num) " 
                "values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,"
                " %s, %s, %s, %s, %s, %s, %s, %s, %s)")
        
        with execute_nonquery(self.conn, stmt, id, threadid, dir, category, datetime, 
                              from_addr, tos, ccs, bccs, subject, body, tosize, ccsize, 
                              bccsize, attachsize, attach, bodysize, location, line_num) as insert:
            pass
Пример #4
0
    " and f.predicate = 'from'"
    " and f2.predicate in ('to', 'cc', 'bcc')"
)

if __name__ == "__main__":

    parser = argparse.ArgumentParser(description='Enrich Emails Communications')
    args= parser.parse_args()

    with newman_connector() as read_cnx, newman_connector() as write_cnx:
        txid = Tx(read_cnx.conn()).next()
        print "tx: %s" % txid
        print "enrich sent to recipient communications"
        facts = Fact(write_cnx.conn(), autocommit=False)
        
        with execute_nonquery(write_cnx.conn(), stmt_sent_to, txid) as qry:
            pass
        write_cnx.commit()
    
        txid = Tx(read_cnx.conn()).next()
        print "tx: %s" % txid
        print "enrich total sent to " 
        with execute_query(write_cnx.conn(), stmt_total_recipients, txid) as qry:
            pass
        write_cnx.commit()
    
        txid = Tx(read_cnx.conn()).next()
        print "tx: %s" % txid
        print "enrich total received "
        with execute_query(write_cnx.conn(), stmt_total_received, txid) as qry:
            pass
Пример #5
0
    def addText(self, subject, object, tx):
        stmt = ("insert into large_text (subject, obj, tx) values (%s, %s, %s)")

        with execute_nonquery(self.conn, stmt, subject.lower(), object, tx, **{ 'autocommit': self.autocommit }) as insert: 
            pass
Пример #6
0
 def addFact(self, subject, schema, predicate, object, tx):
     stmt = "insert into facts (subject, schema_name, predicate, obj, tx) values (%s, %s, %s, %s, %s)"
     with execute_nonquery(self.conn, stmt, subject.lower(), schema.lower(), predicate.lower(), object, tx, **{ 'autocommit': self.autocommit }) as insert: 
         pass
Пример #7
0
 def next(self):
     with execute_nonquery(self.conn, 'insert into tx () values ()') as qry:
         tx = qry.cursor().getlastrowid()
         return tx
Пример #8
0
stmt_xref_email_community = (
    " insert into xref_email_community (email_id, community_id) "
    " select distinct e.id, a.community_id "
    " from email e join xref_emailaddr_email x on e.id = x.email_id " 
    " join email_addr a on x.email_addr = a.email_addr "
)

if __name__ == "__main__":

    parser = argparse.ArgumentParser(description='Post Process')
    args= parser.parse_args()

    with newman_connector() as write_cnx:
        print "populate email_addr"
        with execute_nonquery(write_cnx.conn(), stmt_email_addr_insert) as qry:
            pass
        write_cnx.commit()

        print "populate xref_emailaddr_email"
        with execute_nonquery(write_cnx.conn(), stmt_xref_emailaddr_email) as qry:
            pass
        write_cnx.commit()

        print "populate xref_entity_email"
        with execute_nonquery(write_cnx.conn(), stmt_xref_entity_email) as qry:
            pass
        write_cnx.commit()
        
        print "populate xref_email_community"
        with execute_nonquery(write_cnx.conn(), stmt_xref_email_community) as qry:
Пример #9
0
def insert_topic_category(conn, category_id, idx, value, score, purity, docs):
    stmt = ("insert into topic_category (category_id, idx, value, score, purity, docs) "
            " values (%s, %s, %s, %s, %s, %s)")
    with execute_nonquery(conn, stmt, category_id, idx, value, score, purity, docs) as qry:
        pass