def __init__(self): self.plugin_base = PluginBase(package='trackers') self.source = self.plugin_base.make_plugin_source( searchpath=['./trackers'], identifier='trackers') # Load all trackers logger.info("Loading trackers...") for tmp in self.source.list_plugins(): tracker = self.source.load_plugin(tmp) loaded = tracker.init() if loaded: logger.info("Initialized tracker: %s", tracker.name) self.loaded.append({ 'name': tracker.name.lower(), 'irc_host': tracker.irc_host, 'irc_port': tracker.irc_port, 'irc_channel': tracker.irc_channel, 'irc_tls': tracker.irc_tls, 'irc_tls_verify': tracker.irc_tls_verify, 'plugin': tracker }) else: logger.info("Problem initializing tracker: %s", tracker.name)
def load_plugins(self): self.plugins = {} # Setup a plugin base for "example.modules" and make sure to load # all the default built-in plugins from the builtin_plugins folder. self.plugin_base = PluginBase(package='test.plugins') # and a source which loads the plugins from the "app_name/plugins" # folder. We also pass the application name as identifier. This # is optional but by doing this out plugins have consistent # internal module names which allows pickle to work. self.source = self.plugin_base.make_plugin_source( searchpath=[get_path('./plugins')]) # Here we list all the plugins the source knows about, load them # and the use the "setup" function provided by the plugin to # initialize the plugin. for plugin_name in self.source.list_plugins(): plugin = self.source.load_plugin(plugin_name) #self.plugins.add (plugin.get_instance()) obj = plugin.get_instance(self.config) commands = obj.process_command('')
def __init__(self, name, params): self.logger = logging.getLogger(self.__class__.__name__) self.pluginParams = params self.name = name self.name_lower = name.lower() self.moduleName = self.name_lower.capitalize() self.subject_aggregated = False self.subject_aggregated_default = False self.paths = paths.paths_dict() self.plugin_base = PluginBase(package='AndroidRunner.plugins') # Check lower-cased plugin directory's sub-directories for the the requested plugin name runner_plugin_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), 'Plugins') if self.name_lower in self.list_subdir(runner_plugin_path): self.plugin_source = self.plugin_base.make_plugin_source( searchpath=[os.path.join(runner_plugin_path, self.name_lower)]) self.pluginModule = self.plugin_source.load_plugin(self.moduleName) self.currentProfiler = getattr(self.pluginModule, self.moduleName)(params, self.paths) self.name = self.name_lower else: config_plugin_path = os.path.join(paths.CONFIG_DIR, 'Plugins') if os.path.isdir(config_plugin_path): copyfile( os.path.join(paths.ROOT_DIR, 'AndroidRunner', 'Plugins', 'Profiler.py'), os.path.join(config_plugin_path, 'Profiler.py')) self.plugin_source = self.plugin_base.make_plugin_source( searchpath=[config_plugin_path]) self.pluginModule = self.plugin_source.load_plugin(self.name) self.currentProfiler = getattr(self.pluginModule, self.name)(params, self.paths) else: raise ImportError self.logger.debug('%s: Initialized' % self.name)
def __init__(self, name, params, full_config={}): self.logger = logging.getLogger(self.__class__.__name__) self.pluginParams = params self.name = name self.name_lower = name.lower() self.moduleName = self.name_lower.capitalize() self.subject_aggregated = False self.subject_aggregated_default = False self.paths = paths.paths_dict() self.plugin_base = PluginBase(package='ExperimentRunner.plugins') if self.name_lower == 'android' or self.name_lower == 'trepn' or self.name_lower == 'batterystats': plugin_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), 'Plugins') self.plugin_source = self.plugin_base.make_plugin_source( searchpath=[plugin_path]) self.pluginModule = self.plugin_source.load_plugin(self.moduleName) self.currentProfiler = getattr(self.pluginModule, self.moduleName)(params, self.paths, full_config) self.name = self.name_lower else: plugin_path = os.path.join(paths.CONFIG_DIR, 'Plugins') if os.path.isdir(plugin_path): copyfile( os.path.join(paths.ROOT_DIR, 'ExperimentRunner', 'Plugins', 'Profiler.py'), os.path.join(plugin_path, 'Profiler.py')) self.plugin_source = self.plugin_base.make_plugin_source( searchpath=[plugin_path]) self.pluginModule = self.plugin_source.load_plugin(self.name) self.currentProfiler = getattr(self.pluginModule, self.name)(params, self.paths, full_config) else: raise ImportError self.logger.debug('%s: Initialized' % self.name)
import objc import sys import os my_path = NSBundle.bundleForClass_( objc.lookUpClass("CSShapeCapture").class__()).resourcePath() + "/Python" sys.path.append(my_path) from pluginbase import PluginBase from Foundation import * from CSShapePathWrapper import * sys.dont_write_bytecode = True plugin_base = PluginBase(package='shapeplugins') library_dirs = NSSearchPathForDirectoriesInDomains( NSLibraryDirectory, NSAllDomainsMask - NSSystemDomainMask, YES) plugin_dirs = map( lambda x: x + "/Application Support/CocoaSplit/Plugins/Paths", library_dirs) plugin_dirs.append( NSBundle.bundleForClass_(objc.lookUpClass( "CSShapeCapture").class__()).builtInPlugInsPath() + "/Paths") plugin_source = plugin_base.make_plugin_source(searchpath=plugin_dirs) class CSShapePathLoader(NSObject): def init(self): self = objc.super(CSShapePathLoader, self).init() return self
import CPU.Core import MotherBoard.PROM as PROM import MotherBoard.RAM import time import sys from pluginbase import PluginBase import timeit Prom = PROM.PROM(size=(2**16) - 1) Ram = MotherBoard.RAM.RAM((2**16) - 1) plugin_base = PluginBase(package='devices') source = plugin_base.make_plugin_source(searchpath=['devices']) Prom.loadPromFromBin(sys.argv[1]) delay = 0 try: delay = float(sys.argv[2]) except: pass cpu = CPU.Core.CoreX(Prom, Ram) run = True devicesEnabled = ["Ports"] devices = [] for device_name in source.list_plugins():
import logging import os import json from optenum import Option from .consts import Schemas, SiteSchemaKey as SSK, Args, SchemaOtherKey as SOK, ArticleWeight from urllib.parse import urlparse, urljoin from collections import OrderedDict from scrapy.utils.project import get_project_settings from pluginbase import PluginBase settings = get_project_settings() plugin_base = PluginBase(package='moltspider.plugins') plugin_source = plugin_base.make_plugin_source(searchpath=[ os.path.join(os.path.dirname(__file__), 'plugins'), *settings.get('PROCESS_PLUGINS_SEARCH_PATH', []) ]) log = logging.getLogger(__file__) def load_site_schemas(): search_path = [ os.path.join(os.path.dirname(__file__), 'sites'), *settings.get('SUPPORTED_SITES_SEARCH_PATH', []) ] schemas = {} for path in search_path: if not os.path.exists(path):
Animation runner base """ import objc from Foundation import * #from CoreGraphics import * from Quartz import CACurrentMediaTime, CATransaction, CGPathRef, CGPathAddLines, CGPathCloseSubpath, CGPathRelease, CGPathCreateMutable from pluginbase import PluginBase import math import CSAnimationBlock from CSAnimation import * import sys import os sys.dont_write_bytecode = True plugin_base = PluginBase(package='animationplugins') library_dirs = NSSearchPathForDirectoriesInDomains( NSLibraryDirectory, NSAllDomainsMask - NSSystemDomainMask, YES) plugin_dirs = map( lambda x: x + "/Application Support/CocoaSplit/Plugins/Animations", library_dirs) plugin_dirs.append(NSBundle.mainBundle().resourcePath() + "/Animations") plugin_source = plugin_base.make_plugin_source(searchpath=plugin_dirs) class CSAnimationInput(object): def __init__(self, cs_input): self.__input__ = cs_input self.__layer__ = cs_input.layer() self.__animationLayer__ = cs_input.animationLayer()
from core import client import logging from pluginbase import PluginBase # Imports the main parts. logger = logging.getLogger("highlightpy.entrypoint") # Configures logging. plugin_base = PluginBase(package='__main__.plugins') plugin_source = plugin_base.make_plugin_source(searchpath=["./plugins"]) for plugin in plugin_source.list_plugins(): plugin_source.load_plugin(plugin) logger.info(f"Loaded {plugin}.") # Loads all of the plugins. client.run() # Starts the client.
import os from functools import partial from pluginbase import PluginBase from kuai.helpers import WeakCallback, Singleton, singleton_object here = os.path.abspath(os.path.dirname(__file__)) get_path = partial(os.path.join, here) plugin_base = PluginBase(package='kuai.plugins') # ------------------------------------ __all__ = [ 'Manager', 'set_backend', 'which_backend', 'WeakCallback', 'Singleton', 'singleton_object' ] @singleton_object class Manager(metaclass=Singleton): _backends = {} current_backend = None def __init__(self): self._source = plugin_base.make_plugin_source(searchpath=[here]) self.set_backend() @property def backend(self): return self._backend
Bruno Correia <*****@*****.**> .. obj:: CaseSchema """ # Standard Libraries import os from pathlib import Path # External Libraries from pluginbase import PluginBase # This Library from .core import core from . import case from . import utils # Plugin System # Load all present plugins tp_plugin_dirs = [str(Path(__file__).parent.joinpath('base_plugins')), str(Path.home().joinpath('.topobuilder'))] try: tp_plugin_dirs.append(os.environ['TOPOBULDERPLUGINS']) except KeyError: pass plugin_base = PluginBase(package='topobuilder.plugins') plugin_source = plugin_base.make_plugin_source(searchpath=tp_plugin_dirs) # This Library from . import interface
__author__ = 'avishai' import pkg_resources from pluginbase import PluginBase plugins_path = pkg_resources.resource_filename('wtf', 'plugins') plugin_base = PluginBase('wtf.plugins') plugin_source = plugin_base.make_plugin_source(searchpath=[plugins_path]) def load_plugin(name): return plugin_source.load_plugin(name)
from backbones.config import config from pluginbase import PluginBase from safeembeds import patch_discord import logging import pyximport # Imports go here. pyximport.install() # Allows *.pyx imports. logging.basicConfig(level=logging.INFO) # Sets up logging. patch_discord() # Patches the default Discord embed class to truncate embeds. create_tables() # Creates any tables needed. database.set_allow_sync(False) # Blocks non-async stuff. plugin_base = PluginBase("__main__.plugins") plugin_source = plugin_base.make_plugin_source(searchpath=["./plugins"]) for plugin in plugin_source.list_plugins(): plugin_source.load_plugin(plugin) # Loads all of the plugins. client.run(config['token']) # Runs the client.
import abc import os import logging from xml.dom import minidom from pluginbase import PluginBase import javalang from qark.utils import is_java_file from qark.plugins.manifest_helpers import get_min_sdk, get_target_sdk, get_package_from_manifest log = logging.getLogger(__name__) plugin_base = PluginBase(package="qark.custom_plugins") # plugin modules to blacklist, `helpers` should always be blacklisted as it is not a plugin BLACKLISTED_PLUGIN_MODULES = {"helpers"} def get_plugin_source(category=None): """ Returns a `PluginBase.PluginSource` based on the `category`. :param category: plugin category, subdirectory under `plugins/` :return: `PluginBase.PluginSource` """ path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "plugins") if category is not None: path = os.path.join(path, category) try: return plugin_base.make_plugin_source(searchpath=[path], persist=True)
#!/usr/bin/env python import os, sys from pluginbase import PluginBase plugin_base = PluginBase(package='plugins') plugin_source = plugin_base.make_plugin_source(searchpath=['./plugins']) plugin_names = plugin_source.list_plugins() print(plugin_names) for plugin_name in plugin_names: plugin = plugin_source.load_plugin(plugin_name) plugin_instance = plugin.Action({'cool': 'beans', 'text': 'hello world!'}) print(plugin_instance.response)
import os from functools import partial from pluginbase import PluginBase import upload_github # relative path here = os.path.abspath(os.path.dirname(__file__)) get_path = partial(os.path.join, here) # Setup a plugin base, and load builtin plugins plugin_base = PluginBase(package=os.path.basename(__file__).split('.')[0]+'.plugins', searchpath=[get_path('./builtin_plugins')]) class Application(object): """load plugins Class""" def __init__(self, name): self.name = name # functions provided by plugins self.functions = {} # load plugins of "{app_name}/plugins" self.source = plugin_base.make_plugin_source( searchpath=[get_path('./%s/plugins' % name)], identifier=self.name) # initialize plugins by setup for plugin_name in self.source.list_plugins(): plugin = self.source.load_plugin(plugin_name) plugin.setup(self)
__author__ = 'Konstantin Glazyrin' import os import time from functools import partial from pluginbase import PluginBase from app.common import * import threading import app.config as config here = os.path.abspath(os.path.dirname(__file__)) get_path = partial(os.path.join, here) plugin_base = PluginBase(package='app.daemon', searchpath=[get_path('./plugins')]) class Daemon(Tester): ID = "daemon" TICKTACK = config.DAEMON_TIME_TICK MAX_COUNTER = 10000. DIVIDER = config.DAEMON_TIME_DIVIDER BREAK = False def __init__(self, debug_level=None): Tester.__init__(self, def_file=self.ID, debug_level=debug_level) global plugin_base
from geeteventbus.subscriber import subscriber from utils import Logger, XEvent, Config from pluginbase import PluginBase from functools import partial import os here = os.path.abspath(os.path.dirname(__file__)) get_path = partial(os.path.join, here) plugin_base = PluginBase(package='plugins', searchpath=[ os.path.join(os.getcwd(), 'plugins', 'user'), os.path.join(os.getcwd(), 'plugins', 'system') ]) conf = Config() lg = Logger(__file__) class Core(subscriber): def __init__(self, eb): super().__init__() self.eb = eb self.plugins = plugin_base.make_plugin_source(searchpath=[ os.path.join(os.getcwd(), 'plugins', 'user'), os.path.join(os.getcwd(), 'plugins', 'system') ], identifier=__name__) for plugin_name in self.plugins.list_plugins():
amp = 1 generators = [] generatorsByName = {} generatorList = {} currentTime = time.time() print "==== PARTYLED ====\nSimulation: ", IsSimulated class wrapper_Application(object): def register_generator(self, name, generator): global generatorList generatorList[name] = generator wrapperApp = wrapper_Application() generatorBase = PluginBase(package='partyled.generatorplugins') generatorSource = generatorBase.make_plugin_source(searchpath=[get_path('./generators/')]) for plugin_name in generatorSource.list_plugins(): plugin = generatorSource.load_plugin(plugin_name) plugin.setup(wrapperApp, STRIPCOUNT) print "! Generator plugins: ", generatorList.items() def setupPWM(): pwm1 = PWM(0x40) # PCA9685 board one pwm2 = PWM(0x41) # PCA9685 board two pwm1.setPWMFreq(100) # Not too low, to keep responsiveness to signals high pwm2.setPWMFreq(100) # Also not too high, to prevent voltage rise to cut off and reduce brightness return (pwm1, pwm2)
class DataReaderManager: plugin_source = PluginBase( package='lib.plugins.dataReaders').make_plugin_source( searchpath=['lib/plugins/dataReaders'], identifier='inquisiteDataReaders') dataReaderPlugins = {} dataReaderPluginsByPriority = [] pluginsAreLoaded = False def __init__(self): pass # # # @classmethod def identify(cls, filepath): for n in DataReaderManager.getDataReaders(): #print "TRY " + n i = DataReaderManager.getDataReaderInstance(n) if i is None: continue if i.identify(filepath): return i return None # # # @classmethod def loadDataReaderPlugins(cls): byPriority = {} for n in cls.plugin_source.list_plugins(): if re.match("Base", n): continue c = getattr(cls.plugin_source.load_plugin(n), n) cls.dataReaderPlugins[n] = c byPriority[c.priority] = n for x in sorted(byPriority.iteritems()): cls.dataReaderPluginsByPriority.append(x[1]) cls.pluginsAreLoaded = True return True # # # @classmethod @memoized def getDataReaders(cls): if cls.pluginsAreLoaded is False: cls.loadDataReaderPlugins() return cls.dataReaderPluginsByPriority # # # @classmethod @memoized def getInfoForDataReaders(cls): if cls.pluginsAreLoaded is False: cls.loadDataReaderPlugins() types = {} for x in DataReaderManager.getDataReaders(): p = DataReaderManager.getDataReaderPlugin(x) types[x] = {"name": p.name, "description": p.description} return types # # Return plugin class # @classmethod @memoized def getDataReaderPlugin(cls, n): if cls.pluginsAreLoaded is False: cls.loadDataReaderPlugins() if n in cls.dataReaderPlugins: return cls.dataReaderPlugins[n] return None # # Returns plugin instance # @classmethod @memoized def getDataReaderInstance(cls, n): if cls.pluginsAreLoaded is False: cls.loadDataReaderPlugins() if n in cls.dataReaderPlugins: return cls.dataReaderPlugins[n]() return None
# Print success message. print("Plugin '{}' registered successfully.".format(plugin_info.name)) class FakeClient: def event(self): pass if __name__ == "__main__": from api import database database.init() # Log the time we started. Bot.startTime = time.time() # Get the source of plugins. plugin_base = PluginBase(package="plugins") plugin_source = plugin_base.make_plugin_source(searchpath=["./plugins"]) # Create the Discord client. client = discord.Client() Bot.client = client # Load each plugin. for plugin in plugin_source.list_plugins(): initPlugin(plugin) # Get our token to use. token = "" with open("token.txt") as m: token = m.read().strip() else:
def base(): return PluginBase(package='dummy.plugins')
def import_plugins(plugin_mount, plugin_base_dir): plugin_base = PluginBase(package=plugin_mount) plugin_src_dirs = _get_plugin_src_dirs(plugin_base_dir) return plugin_base.make_plugin_source(searchpath=plugin_src_dirs)
import boto3 import logging import os import json from pluginbase import PluginBase from cis.encryption import decrypt_payload from cis.settings import get_config plugin_base = PluginBase(package='cis.plugins.validation') plugin_source = plugin_base.make_plugin_source(searchpath=[ os.path.join(os.path.abspath(os.path.dirname(__file__)), 'plugins/validation/') ]) # List of plugins to load, in order plugin_load = ['json_schema_plugin', 'mozilliansorg_publisher_plugin'] dynamodb = boto3.resource('dynamodb') config = get_config() dynamodb_table = config('dynamodb_table', namespace='cis') table = dynamodb.Table(dynamodb_table) logger = logging.getLogger(__name__) def validate(publisher, **payload): """ Validates the payload passed to CIS. :payload: Encrypted payload based on the output of `cis.encryption.encrypt_payload` method
#!/usr/bin/env python # -*- coding:utf-8 -*- from __future__ import print_function, absolute_import import traceback from datetime import datetime from pluginbase import PluginBase from click_project.click_helpers import click_get_current_context_safe from click_project.config import config from click_project.log import get_logger plugin_base = PluginBase(package='click_project.plugins') plugins = None plugins_cache = set() LOGGER = get_logger(__name__) def on_command_loading_error(): LOGGER.develop(traceback.format_exc()) if config.debug_on_command_load_error_callback: import sys import ipdb ipdb.post_mortem(sys.exc_info()[2]) afterloads = []
await app.create_table_if_not_exists("installs") await app.create_index_if_not_exists("versions", "release_id") await app.create_index_if_not_exists("versions", "beta") await app.create_index_if_not_exists("installs", "device_id") WebSocketManager(app, loop) app.version_cache = VersionCache(app.conn, loop) app = RethinkSanic(__name__) # Defines the app. CORS(app) # Allows CORS. plugin_base = PluginBase(package="main.plugins") plugin_source = plugin_base.make_plugin_source(searchpath=["./plugins"]) for plugin in plugin_source.list_plugins(): loaded = plugin_source.load_plugin(plugin) loaded.setup(app) # Loads all of the plugins. sentry_sdk.init(dsn=os.environ.get("SENTRY_DSN"), integrations=[SanicIntegration()]) # Loads in Sentry. if __name__ == "__main__": app.run(port=8000, host="0.0.0.0", protocol=WebSocketProtocol) # Starts the app.
class AutoDl(object): """Main class.""" scrapers = {} myDB = "" config = configparser.ConfigParser() plugin_base = PluginBase(package='autodl.scraper') def __init__(self): """Init main class.""" doScrape = True self.load_config() self.init_config() self.myDB = DBManager(self.config["BASIC"]["DBLocation"]) self.plugin_source = self.plugin_base.make_plugin_source( searchpath=['./scrapers']) for plugin_name in self.plugin_source.list_plugins(): plugin = self.plugin_source.load_plugin(plugin_name) plugin.Scraper().setup(self) doScrape = "-noscrape" not in sys.argv doDl = "-nodl" not in sys.argv if "-add" in sys.argv: i = sys.argv.index("-add") newShow = sys.argv[i + 1] newLang = sys.argv[i + 2] self.myDB.orderShow(newShow, newLang) if doScrape: self.scrape() self.save_config() self.myDB.matchEpisodes() if doDl: self.myDL = Downloader(self) self.myDL.downloadQueue() def init_config(self): """Setup config if nor exist.""" basic_conf = { "DefaultLang": "de", "DefaultLocation": "de", "DBLocation": "./media.db", "MediaLocation": "./media" } network_conf = { "VPNStart": "windscribe connect {loc}", "VPNStop": "windscribe disconnect" } if "BASIC" not in self.config.sections(): self.config.add_section("BASIC") if "NETWORK" not in self.config.sections(): self.config.add_section("NETWORK") for element in basic_conf: if element not in self.config["BASIC"]: self.config.set("BASIC", element, basic_conf[element]) for element in network_conf: if element not in self.config["NETWORK"]: self.config.set("NETWORK", element, network_conf[element]) def load_config(self): """Load config from config.ini.""" if os.path.isfile('config.ini'): with open('config.ini', 'r') as configfile: self.config.read_file(configfile) def save_config(self): """Save config in config.ini.""" with open('config.ini', 'w') as configfile: self.config.write(configfile) def register_scraper(self, name, scraper): """Use to register a scraper plugin.""" self.scrapers[name] = scraper if "SCRAPER" not in self.config.sections(): self.config.add_section("SCRAPER") if name not in self.config["SCRAPER"]: self.config["SCRAPER"][name] = "True" def addConfigKey(self, section, key, default): """Allow scrapers to add config keys.""" if section not in self.config.sections(): self.config.add_section(section) self.save_config() if key not in self.config[section]: self.config.set(section, key, default) self.save_config() def scrape(self): """Execute all scrapers.""" for name, s in sorted(self.scrapers.items()): if self.config["SCRAPER"][name] == "True": print('{}: {}'.format(name, s())) print('')
def load_module(self): plugin_base = PluginBase(package='pipeline.modules') modules_home = plugin_base.make_plugin_source( searchpath=['./modules', ] )
import os from configparser import ConfigParser from functools import partial from pluginbase import PluginBase from pydle.async import EventLoop from tornado.ioloop import PeriodicCallback from ircbot.webserver import setup_webserver logger = logging.getLogger(__name__) here = os.path.abspath(os.path.dirname(__file__)) get_path = partial(os.path.join, here) plugin_base = PluginBase(package='ircbot.plugins') class BotBot(pydle.Client): def __init__(self, fallback_nicknames=[], username=None, realname=None, **kwargs): super(BotBot, self).__init__("botbot-defaultnickname", fallback_nicknames=fallback_nicknames, username=username, realname=realname, **kwargs) self.config = None self.join_channels = None self.trigger = None self.config_location = None self.plugin_mgr = None self.commands = {}
import sys import json from .tasks import * from .utils import * from pluginbase import PluginBase from jsonschema.exceptions import ValidationError ## Init plugins plugin_dirs = [ os.path.dirname(os.path.realpath(__file__)), os.path.join(os.path.dirname(os.path.realpath(__file__)), 'plugins'), os.path.realpath( os.path.join(os.path.dirname(os.path.realpath(__file__)), '../plugins')) ] plugin_base = PluginBase(package='lmaps.plugins') plugin_source = plugin_base.make_plugin_source(searchpath=plugin_dirs) class Handler(object): ''' Base class for handling /anything/ ''' context = None def __init__(self, **kwargs): ''' Constructor ''' self.context = kwargs['context']