2017-02-23 11:00:48 +00:00
|
|
|
#!/usr/bin/python
|
2017-03-05 17:34:36 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import requests
|
|
|
|
import re
|
|
|
|
import json
|
|
|
|
import os
|
|
|
|
import imp
|
|
|
|
|
|
|
|
from wordpress import *
|
|
|
|
|
|
|
|
class Load_Plugins:
|
|
|
|
plugin_folder = "./plugins"
|
|
|
|
|
|
|
|
def __init__(self, wordpress):
|
|
|
|
available_plugins = os.listdir(self.plugin_folder)
|
|
|
|
for plugins in available_plugins:
|
|
|
|
if not ".pyc" in plugins and not "__init__" in plugins:
|
|
|
|
|
|
|
|
# Find and load the package
|
|
|
|
name = plugins.replace('.py','')
|
|
|
|
f, file, desc = imp.find_module('plugins', ['.'])
|
|
|
|
pkg = imp.load_module('plugins', f, file, desc)
|
2017-06-11 15:11:41 +00:00
|
|
|
|
2017-03-05 17:34:36 +00:00
|
|
|
# Find and load the plugin
|
|
|
|
f, file, desc = imp.find_module(name, pkg.__path__)
|
|
|
|
loaded = imp.load_module('plugins.' + name, f, file, desc)
|
2017-06-11 15:11:41 +00:00
|
|
|
|
2017-03-05 17:34:36 +00:00
|
|
|
# Run the __init__
|
|
|
|
print notice('Plugin %s loaded.' % loaded.name)
|
2017-06-11 15:11:41 +00:00
|
|
|
loaded.__init__(wordpress)
|