class PluginMgrTests(BaubleTestCase): def test_install(self): """ Test importing default data from plugin """ # this emulates the PlantsPlugin install() method but only # imports the family.txt file...if PlantsPlugin.install() # changes we should change this method as well class Dummy(pluginmgr.Plugin): @classmethod def init(cls): pass @classmethod def install(cls, import_defaults=True): import bauble.paths as paths if not import_defaults: return path = os.path.join(paths.lib_dir(), "plugins", "plants", "default") filenames = os.path.join(path, 'family.txt') from bauble.plugins.imex.csv_ import CSVImporter csv = CSVImporter() try: csv.start([filenames], metadata=db.metadata, force=True) except Exception, e: logger.error(e) raise from bauble.plugins.plants import Family self.assert_(self.session.query(Family).count() == 511) pluginmgr.plugins[Dummy.__name__] = Dummy pluginmgr.install([Dummy])
logger.warning('bauble.db.create(): %s' % utils.utf8(e)) transaction.rollback() raise except Exception, e: logger.warning('bauble.db.create(): %s' % utils.utf8(e)) transaction.rollback() raise else: transaction.commit() finally: connection.close() connection = engine.connect() transaction = connection.begin() try: pluginmgr.install('all', import_defaults, force=True) except GeneratorExit, e: # this is here in case the main windows is closed in the middle # of a task # UPDATE 2009.06.18: i'm not sure if this is still relevant since we # switched the task system to use fibra...but it doesn't hurt # having it here until we can make sure logger.warning('bauble.db.create(): %s' % utils.utf8(e)) transaction.rollback() raise except Exception, e: logger.warning('bauble.db.create(): %s' % utils.utf8(e)) transaction.rollback() raise else: transaction.commit()
logger.warning("bauble.db.create(): %s" % utils.utf8(e)) transaction.rollback() raise except Exception, e: logger.warning("bauble.db.create(): %s" % utils.utf8(e)) transaction.rollback() raise else: transaction.commit() finally: connection.close() connection = engine.connect() transaction = connection.begin() try: pluginmgr.install("all", import_defaults, force=True) except GeneratorExit, e: # this is here in case the main windows is closed in the middle # of a task # UPDATE 2009.06.18: i'm not sure if this is still relevant since we # switched the task system to use fibra...but it doesn't hurt # having it here until we can make sure logger.warning("bauble.db.create(): %s" % utils.utf8(e)) transaction.rollback() raise except Exception, e: logger.warning("bauble.db.create(): %s" % utils.utf8(e)) transaction.rollback() raise else: transaction.commit()