def __load_config(path=None): #Strategy: # 1) Load the default config # 2) Load the plugins # 3) Load the site filters and controllers # 4) Load the user's config. # This will ensure that we have good default values if the user's # config is missing something. exec(default_config) plugin.load_plugins() filter.preload_filters() controller.load_controllers(namespace=bf.config.controllers) if path: execfile(path) #config is now in locals() but needs to be in globals() for k, v in locals().items(): globals()[k] = v #Override any options (from unit tests) for k, v in override_options.items(): if "." in k: parts = k.split(".") cache_object = ".".join(parts[:-1]) setting = parts[-1] cache_object = eval(cache_object) cache_object[setting] = v else: globals()[k] = v recompile() __loaded = True
def __init__(self, radiologger): self.radiologger = radiologger self.loop = gobject.MainLoop() self.prefs = preferences.Prefs() self.default_client_id = "android-generic" self.default_one_client_id = "pandora-one" self.default_album_art = None self.song_thumbnail = None self.songChanged = False #global launchpad_available #if False and launchpad_available: # Disable this # see https://wiki.ubuntu.com/UbuntuDevelopment/Internationalisation/Coding for more information # about LaunchpadIntegration # helpmenu = self.builder.get_object('menu_options') # if helpmenu: # LaunchpadIntegration.set_sourcepackagename('pithos') # LaunchpadIntegration.add_items(helpmenu, 0, False, True) # else: # launchpad_available = False self.init_core() self.beaglebone = Beaglebone(self, self.radiologger, self.player) self.beaglebone.greenOn() self.plugins = {} load_plugins() self.stations_model = [] self.songs_model = [] self.pandora = make_pandora(self.radiologger) self.set_proxy() self.set_audio_quality() self.pandora_connect()
def load_plugins(self, reload_plugins=False): """Load plugins and their commands respectively.""" if reload_plugins: plugin.reload_plugins(irc=self) else: plugin.load_plugins(irc=self) self.log.info("Loaded Plugins: %s" % active_plugins())
def __init__(self): args = _parse_args() if not args.port: print("ERROR: Please use -p option to specify device midi port.") sys.exit(1) # connect with the launchpad print("Connecting with launchpad") self.launchpad = Launchpad(args.port, self.process_midi_event) # load the plugins print("Loading plugins using config file: %s" % args.configfile) load_plugins(self.launchpad, args.configfile) # start reading midi events self.launchpad.read_midi_event()
def __init__(self, settings): db.setup_connection_factory(create_connection, close_connection) self.settings = settings self.connection = connection.Connection(self.settings["host"], self.settings["port"]) self.connection.handshake(self.settings["nick"]) self.plugins = [core.Core(self.connection, self.settings)] self.plugins.extend(plugin.load_plugins(self.connection))
def applicationDidFinishLaunching_(self, notification): self.configuration = Configuration(config_path) settings = self.configuration.settings from plugin import load_plugins load_plugins(self.configuration) self.set_up_ui() self.the_db = open_db(self.configuration) for account_config in settings['accounts']: account = Account(account_config, self.the_db) self.accounts[account.name] = account account.perform_update() auto_sync_interval = settings.get('auto_sync', None) if auto_sync_interval is not None: from async_cocoa import timer_with_callback timer_with_callback(auto_sync_interval * 60, True, self.auto_sync)
async def event_gm(app: Mirai, member: Member, message: MessageChain): plains = message.getAllofComponent(Plain) if len(plains) == 0: return msg = '' for plain in plains: msg += plain.toString().strip() + ' ' msg = msg.strip() if msg == '': return if member.id == 623697643 and '更新插件' == msg: plugin_set = load_plugins(reload=True) print(len(plugin_set)) if plugin_set: return await app.sendGroupMessage(member.group.id, [Plain(text='更新插件成功!')]) else: return await app.sendGroupMessage(member.group.id, [Plain(text='更新插件失败!')]) await handle_group_msg(app, member, message)
def OnInit(self): if USE_INSPECTOR: self.Init() # Check version if wx.VERSION[:3] < MinWxVersion: wx.LogWarning('''\ This version of XRCed may not work correctly on your version of wxWidgets. \ Please upgrade wxWidgets to %d.%d.%d or higher.''' % MinWxVersion) g.undoMan = undo.UndoManager() Manager.init() parser = OptionParser(prog=progname, version='%s version %s' % (ProgName, version), usage='%prog [options] [XRC file]') parser.add_option('-d', '--debug', action='store_true', help='add Debug command to Help menu') parser.add_option('-m', '--meta', action='store_true', dest='meta', help='activate meta-components') parser.add_option('-v', '--verbose', action='store_true', help='verbose messages') # Process command-line arguments options, args = parser.parse_args() if options.debug: set_debug(True) if options.verbose: set_verbose(True) if options.meta: g.useMeta = True import meta Manager.register(meta.Component) Manager.setMenu(meta.Component, 'TOP_LEVEL', 'component', 'component plugin') self.SetAppName(progname) self.ReadConfig() # Add handlers wx.FileSystem.AddHandler(wx.MemoryFSHandler()) self.toolArtProvider = view.ToolArtProvider() wx.ArtProvider.Push(self.toolArtProvider) # Load standard plugins first plugin.load_plugins(os.path.join(g.basePath, 'plugins')) # ... and then from user-defined dirs plugin.load_plugins_from_dirs() # Setup MVP view.create_view() Presenter.init() Listener.Install(view.frame, view.tree, view.panel, view.toolFrame, view.testWin) if args: path = args[0] # Change current directory dir = os.path.dirname(path) if dir: os.chdir(dir) path = os.path.basename(path) if os.path.isfile(path): Presenter.open(path) else: # Future name Presenter.path = path # Force update title Presenter.setModified(False) view.frame.Show() if not g.useAUI: if not g.conf.embedPanel: view.frame.miniFrame.Show() if g.conf.showToolPanel: Listener.toolFrame.Show() return True
def OnInit(self): # Check version if wx.VERSION[:3] < MinWxVersion: wx.LogWarning('''\ This version of XRCed may not work correctly on your version of wxWidgets. \ Please upgrade wxWidgets to %d.%d.%d or higher.''' % MinWxVersion) g.undoMan = undo.UndoManager() Manager.init() parser = OptionParser(prog=progname, version='%s version %s' % (ProgName, version), usage='%prog [options] [XRC file]') parser.add_option('-d', '--debug', action='store_true', help='add Debug command to Help menu') parser.add_option('-m', '--meta', action='store_true', dest = 'meta', help='activate meta-components') parser.add_option('-v', '--verbose', action='store_true', help='verbose messages') # Process command-line arguments options, args = parser.parse_args() if options.debug: set_debug(True) if options.verbose: set_verbose(True) if options.meta: g.useMeta = True import meta Manager.register(meta.Component) Manager.setMenu(meta.Component, 'TOP_LEVEL', 'component', 'component plugin') self.SetAppName(progname) self.ReadConfig() # Add handlers wx.FileSystem.AddHandler(wx.MemoryFSHandler()) self.toolArtProvider = view.ToolArtProvider() wx.ArtProvider.Push(self.toolArtProvider) # Load standard plugins first plugin.load_plugins(os.path.join(g.basePath, 'plugins')) # ... and then from user-defined dirs plugin.load_plugins_from_dirs() # Setup MVP view.create_view() Presenter.init() Listener.Install(view.frame, view.tree, view.panel, view.toolFrame, view.testWin) if args: path = args[0] # Change current directory dir = os.path.dirname(path) if dir: os.chdir(dir) path = os.path.basename(path) if os.path.isfile(path): Presenter.open(path) else: # Future name Presenter.path = path # Force update title Presenter.setModified(False) view.frame.Show() if not g.useAUI: if not g.conf.embedPanel: view.frame.miniFrame.Show() if g.conf.showToolPanel: Listener.toolFrame.Show() return True
import datetime import json import os from ledger import Amount from alchemyjsonschema.dictify import jsonify from flask import Flask, request, current_app from flask.ext.cors import CORS from flask.ext.login import login_required, current_user from flask_bitjws import FlaskBitjws, load_jws_from_request from sqlalchemy_models import jsonify2 import plugin from desw import CFG, wm, um, ses, create_user_and_key ps = plugin.load_plugins() # get the swagger spec for this server iml = os.path.dirname(os.path.realpath(__file__)) SWAGGER_SPEC = json.loads(open(iml + '/static/swagger.json').read()) __all__ = ['app', ] def get_last_nonce(app, key, nonce): """ Get the last_nonce used by the given key from the SQLAlchemy database. Update the last_nonce to nonce at the same time. :param str key: the public key the nonce belongs to
import logging import os import sys import sqlalchemy as sa import sqlalchemy.orm as orm from alchemyjsonschema.dictify import jsonify from flask import Flask, request, current_app, make_response from flask.ext.cors import CORS from flask.ext.login import login_required, current_user from flask_bitjws import FlaskBitjws, load_jws_from_request, FlaskUser from jsonschema import validate, ValidationError from sqlalchemy_login_models.model import UserKey, User as SLM_User import plugin from desw import CFG, models, ses, eng ps = plugin.load_plugins() # get the swagger spec for this server iml = os.path.dirname(os.path.realpath(__file__)) SWAGGER_SPEC = json.loads(open(iml + '/static/swagger.json').read()) # invert definitions def jsonify2(obj, name): #TODO replace this with a cached definitions patch #this is inefficient to do each time... spec = copy.copy(SWAGGER_SPEC['definitions'][name]) spec['definitions'] = SWAGGER_SPEC['definitions'] return jsonify(obj, spec)
@bot.receiver("GroupMessage") async def event_gm(app: Mirai, member: Member, message: MessageChain): plains = message.getAllofComponent(Plain) if len(plains) == 0: return msg = '' for plain in plains: msg += plain.toString().strip() + ' ' msg = msg.strip() if msg == '': return if member.id == 623697643 and '更新插件' == msg: plugin_set = load_plugins(reload=True) print(len(plugin_set)) if plugin_set: return await app.sendGroupMessage(member.group.id, [Plain(text='更新插件成功!')]) else: return await app.sendGroupMessage(member.group.id, [Plain(text='更新插件失败!')]) await handle_group_msg(app, member, message) if __name__ == "__main__": plugin_set = load_plugins() print(len(plugin_set)) bot.run()
from flask import Flask import api_control as api import db_control as db from env import get_env_host, get_env_port import common.oauth as oauth app = Flask(__name__) db.init(app) api.init(app) oauth.init(app) if __name__ == '__main__': import plugin import app_view as view import common.user as user plugin.load_plugins('common', app) plugin.load_plugins('plugins', app) user.init() view.init(app) app.run(host=get_env_host(), port=get_env_port())
from log import Logger from os import path #app = FastAPI() app = FastAPI(docs_url="/mingdocs", redoc_url=None) """ @app.get("/",response_class=ORJSONResponse) async def read_root(): return {"Hello": "World"} """ logger = Logger(filename=config.logfilename, when='D', backCount=config.backCount, fmt='[%(asctime)s %(name)s] %(levelname)s: %(message)s') plugin.load_plugins(path.join(path.dirname(__file__), 'awesome'), 'awesome') @app.get("/", response_class=ORJSONResponse) async def read(asin: str, c: str = None): header = await config.getrandHeader() proxy = await config.getrandProxy() country = config.getMarketplace(c) url = country.format(asin) logger.info( orjson.dumps({ "url": url, "header": header.get("User-Agent"), "proxy": proxy
from __future__ import unicode_literals, print_function from Cocoa import NSBundle, NSTimer, NSRunLoop, NSDefaultRunLoopMode, NSApp from objc import lookUpClass, YES, NO, signature import os import sys import traceback import cStringIO # load the root classes sys.path.append(NSBundle.mainBundle().resourcePath()) from plugin import load_plugins, Plugin, Formatter # load any python plugins in the users directory load_plugins() sys.path.append(NSBundle.mainBundle().builtInPlugInsPath()) sys.path.append( '/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/Python' ) import lldb # == Enhancements == # 'process interrupt' to break in # stdin support # different core modules? # menu items # draw anywhere 'terminal' view