<commit_before>from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from PluginManager import PluginManager
import os
import sys


class HoneypotBase:
    def __init__(self):
        self._plugin_directory = './plugins/'
        self._threads = []
        self._engine = create_engine('sqlite:///sqliteDB/test.db', echo=True)
        self._Session = sessionmaker(bind=self._engine)

    def load_plugins(self):
        sys.path.insert(0, self._plugin_directory)
        for i in os.listdir(self._plugin_directory):
            filename, ext = os.path.splitext(i)
            if ext == '.py':
                print "Loading File: " + filename
                try:
                    mod = __import__(filename)
                    HoneypotBase._start_manager_thread(self, mod.Plugin())
                    print "Plugin loaded: " + filename
                except AttributeError:
                    print("Invalid plugin: " + filename)
                except IndentationError:
                    print("Plugin in wrong format: " + filename)
        sys.path.pop(0)

    def _start_manager_thread(self, plugin):
        thread = PluginManager(plugin, self._Session)
        thread.start()
        self._threads.append(thread)

HoneypotBase().load_plugins()<commit_msg>Make HoneypotBase modular instead of a class<commit_after>from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from PluginManager import PluginManager
import os
import sys


def _load_plugins():
    sys.path.insert(0, plugin_directory)
    for i in os.listdir(plugin_directory):
        filename, ext = os.path.splitext(i)
        if ext == '.py':
            print "Loading File: " + filename
            try:
                mod = __import__(filename)
                _start_manager_thread(mod.Plugin())
                plugins.append(mod.Plugin)
                print "Plugin loaded: " + filename
            except AttributeError:
                print("Invalid plugin: " + filename)
            except IndentationError:
                print("Plugin in wrong format: " + filename)
    sys.path.pop(0)


def _start_manager_thread(plugin):
    thread = PluginManager(plugin, Session)
    thread.start()
    threads.append(thread)


def _stop_hp():
    for thread in threads:
        thread.stop()
    raise SystemExit(0)


def start():
    try:
        _load_plugins()
        while True:
            continue
    except KeyboardInterrupt:
        _stop_hp()


plugin_directory = './plugins/'
threads = []
plugins = []
engine = create_engine('sqlite:///sqliteDB/test.db', echo=True)
Base = declarative_base()
Base.metadata.create_all(engine)
Session = sessionmaker(bind=engine)
start()
{'fraction_non_alphanumeric': 0.09492753623188406, 'fraction_numerical': 0.0018115942028985507, 'mean_word_length': 2.3877300613496932, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3897144', 'n_tokens_mistral': 778, 'n_tokens_neox': 734, 'n_words': 181}