def __init__(self, **kwargs): super().__init__(**kwargs) self.camera = None self.clip_size = None self.ndarray_available.connect(self.clip_array) self.ndarray_available.connect(self.convert_to_grayscale) self.plugin_loader = PluginLoader() self.plugins = self.plugin_loader.plugins for plugin in self.plugins: try: plugin.message.connect(self.message) except: qDebug("Cannot connect to messages from {}".format(plugin.getName())) self.ndarray_available.connect(self.plugin_loader.ndarray_available) self.ndarray_bw_available.connect(self.plugin_loader.ndarray_bw_available) self.clipped_ndarray_available.connect(self.plugin_loader.clipped_ndarray_available) self.clipped_ndarray_bw_available.connect(self.plugin_loader.clipped_ndarray_bw_available) self.data_saver = DataSaver() self.ndarray_bw_available.connect(self.data_saver.set_array) self.save_file.connect(self.data_saver.save_image) self.data_saver.message.connect(self.message) # this limits the global frame rate in this program: self.last_frame_time = time.time() self.frame_interval = 0.1
def main(): logger.info("Starting {0}".format(version_string)) try: gem.runite.context = gem.runite.Context() gem.runite.context.unpack(config.game_data['data_file'], config.game_data['index_files']) plugin_loader = PluginLoader(plugin_path) plugin_loader.load() # init service listeners # inserts an engine.Start hook to launch listeners listeners = ServiceListeners() # start the engine engine = gem.engine.Engine() engine.start() signal_handler.setup_exit_handler(engine.stop) logger.notice("Finished engine initialization") except Exception as e: logger.error("Startup failed: {0}".format(e)) if args.no_console: logger.notice("Press Control-D to toggle the interactive console") while True: line = sys.stdin.readline() if not line: # readline will return "" on EOF interactive_console() else: while True: pass
def produce(self): plugin_loader = PluginLoader() try: router_module, server, realm, vendor = plugin_loader.load_plugin(self.router_info['addr'], self.router_info['port'], self.session) except ErrorTimeout, e: self.print_with_lock(self.addr + ': fail, connect timeout at module identification') self.router_info['status'] = 'offline' return self.router_info
def __init__(self, conf): api_token = conf['general']['api_token'] name = conf['general']['bot_name'] self.hipster = HipChat(token=api_token) try: self.available_rooms = dict( map(lambda x: [x['name'], x['room_id']], self.hipster.list_rooms()['rooms'])) except HTTPError: print('Error! API token not specified or invalid') exit() if name: self.name = name pl = PluginLoader(conf, '/plugins') self.plugins = pl.get_plugins() self.__set_actions()
def __init__(self, plugin_dir, results_dir, logfile='/var/log/bidmap/bid_scraper_engine.log'): self.plugin_dir = plugin_dir self.results_dir = results_dir self.logfile = logfile self.plugins = [] self.pldr = PluginLoader() self.logger = logging.getLogger('bidmap') self.logger.setLevel(logging.DEBUG) fh = logging.FileHandler(filename=logfile, mode='w') fh.setLevel(logging.DEBUG) formatter = logging.Formatter( '%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setFormatter(formatter) self.logger.addHandler(fh) super(BidScraperEngine, self).__init__()
#! venv3/bin/python from plugin_loader import PluginLoader import discord import asyncio import configparser import traceback import json import sys import logging import twitter config = configparser.RawConfigParser() plugins = PluginLoader() client = discord.Client() @client.async_event def on_ready(): print('Logged in as: ', client.user.name, 'with ID:', client.user.id) @client.async_event def on_message(message): selfname = config.get("BotSettings", "self_name") permitted_channels = json.loads(config.get('BotSettings', 'permitted_channels')) server_id = config.get("BotSettings", "server_id") if message.channel.is_private: if not message.author.name == selfname:
f.close() except Exception, e: sys.stderr.write("Exception: %s\n" % e) sys.exc_clear() num_bids = org.bid_set.count() self.logger.info('Saved %d bids for org %s to file %s' % (num_bids, org.name, path)) def make_plugin_filename(self): """ Return the filename we'll use to store results for a given plugin. """ netloc = urlparse(self.plugin.GOVINFO['home_page_url']).netloc tld = netloc.rsplit('.', 1)[1] filename = tld + '-' + self.plugin.__name__ return filename if __name__ == '__main__': if len(sys.argv) != 2: sys.stderr.write('usage: %s <plugin>\n' % sys.argv[0]) sys.exit(1) pldr = PluginLoader() plug = pldr.load_plugin(sys.argv[1]) plugin_runner = PluginRunner(plugin=plug, results_dir='results/') plugin_runner.run()