def __init__(self, filename): """ Create the database and add the tables used to store the stats. """ self.filename = filename self.db = m5sql.create_database(self.filename) Session = sessionmaker(bind=self.db) m5sql.create_tables(self.db) self.session = Session()
def main(): create_tables() # start sniffing icmp_sniff = AsyncSniffer(iface=l_iface, prn=partial(logger, 'icmp-echo'), filter="icmp[icmptype] == icmp-echo", store=0) tcp_syn_sniff = AsyncSniffer(iface=l_iface, prn=partial(logger, 'tcp-syn'), filter="tcp[tcpflags] & tcp-syn != 0", store=0) tcp_fin_sniff = AsyncSniffer(iface=l_iface, prn=partial(logger, 'tcp-fin'), filter="tcp[tcpflags] & tcp-fin != 0", store=0) icmp_sniff.start() tcp_syn_sniff.start() tcp_fin_sniff.start() while True: pass
import sql sql.drop_tables() sql.create_tables() item = { "public_repos": 4, "name": "Linus Torvalds", "company": "Linux Foundation", "updated_at": "2017-04-12T15:12:19Z", "created_at": "2011-09-03T15:26:22Z", "following": 0, "location": "Portland, OR", "followers": 53085, "login": "******", "type": "User", "id": 1024025, } sql.insert('user', item) print "Init Done."
#!/usr/bin/env python # -*- coding: utf-8 -*- import os from app import app import sql if __name__ == '__main__': if not os.path.isfile(sql.dbfile): sql.create_tables() # import random, threading, webbrowser port = 8000 #5000 + random.randint(0, 999) # url = "http://127.0.0.1:{0}".format(port) # threading.Timer(1.25, lambda: webbrowser.open(url) ).start() app.run(port=port, debug=True)