def extract_plugin(self, sections): """ This method allows to extract all data related to the plugin which all sections are referred to. @param sections: All sections extracted from the considered manifest file. @type sections: dictionary @return: A Plugin object containing all data extracted from available sections @rtype: Plugin """ # detect if the plugin is supported by the ACTIVE core p = Plugin(**sections['PLUGIN']) if compare_version(p.active_version, settings.ACTIVE_VERSION) > 0 : print 'ERROR: plugin not supported by the current version of the ACTIVE core ', p.name return None # detect if the Plugin has already been stored or create a new one try: temp = Plugin.objects.get(name = sections['PLUGIN']['name']) # compare the plugin version and upload only the latest plugin if compare_version(temp.plugin_version, p.plugin_version) < 0 : temp.delete() p.save() else: p = temp except Plugin.DoesNotExist as ex: p.save() return p
def create_plugin(): """ Method used to create and return a simple Plugin object. """ plugin = Plugin() plugin.name = 'SamplePlugin' plugin.plugin_version = 1.0 plugin.save() return plugin
def setUp(self): """ Method used to setup the test database """ # create a new user user = User.objects.create_user('root', '*****@*****.**', 'root') user.is_superuser = True user.save() token = Token.objects.create(user=user) # create a new Plugin plugin = Plugin() plugin.title = 'My test plugin' plugin.description = '' plugin.active_version = '1.0.0' plugin.plugin_version = '1.0.0' plugin.url_info = 'http://active.crs4.it' plugin.authors = 'John Doe' plugin.save() # create a new Script script = Script() script.title = 'Test script for image items' script.details = '' script.path = 'mytestplugin.utils.script1' script.job_name = 'job_manager.job.job.PlainJob' script.plugin = plugin script.item_type = 'image' script.save()
def setUp(self): """ Method used to setup the test database """ # create a new user user = User.objects.create_user('root', '*****@*****.**', 'root') user.is_superuser = True user.save() token = Token.objects.create(user=user) # create a new Plugin plugin = Plugin() plugin.name = 'My test plugin' plugin.description = 'image' plugin.active_version = '1.0.0' plugin.plugin_version = '1.0.0' plugin.url_info = 'http://active.crs4.it' plugin.authors = 'John Doe' plugin.save()