How to use plugins method in yandex-tank

Best Python code snippet using yandex-tank

PluginComponent.py

Source:PluginComponent.py Github

copy

Full Screen

1import os2from bisect import insort3from Tools.Directories import fileExists, resolveFilename, SCOPE_PLUGINS4from Tools.Import import my_import5from Tools.Profile import profile6from Plugins.Plugin import PluginDescriptor7import keymapparser8class PluginComponent:9 firstRun = True10 restartRequired = False11 def __init__(self):12 self.plugins = {}13 self.pluginList = [ ]14 self.installedPluginList = [ ]15 self.setPluginPrefix("Plugins.")16 self.resetWarnings()17 def setPluginPrefix(self, prefix):18 self.prefix = prefix19 def addPlugin(self, plugin):20 if self.firstRun or not plugin.needsRestart:21 self.pluginList.append(plugin)22 for x in plugin.where:23 insort(self.plugins.setdefault(x, []), plugin)24 if x == PluginDescriptor.WHERE_AUTOSTART:25 plugin(reason=0)26 else:27 self.restartRequired = True28 def removePlugin(self, plugin):29 self.pluginList.remove(plugin)30 for x in plugin.where:31 self.plugins[x].remove(plugin)32 if x == PluginDescriptor.WHERE_AUTOSTART:33 plugin(reason=1)34 def readPluginList(self, directory):35 """enumerates plugins"""36 new_plugins = []37 for c in os.listdir(directory):38 directory_category = os.path.join(directory, c)39 if not os.path.isdir(directory_category):40 continue41 for pluginname in os.listdir(directory_category):42 path = os.path.join(directory_category, pluginname)43 if os.path.isdir(path):44 profile('plugin '+pluginname)45 try:46 plugin = my_import('.'.join(["Plugins", c, pluginname, "plugin"]))47 plugins = plugin.Plugins(path=path)48 except Exception, exc:49 print "Plugin ", c + "/" + pluginname, "failed to load:", exc50 # supress errors due to missing plugin.py* files (badly removed plugin)51 for fn in ('plugin.py', 'plugin.pyo'):52 if os.path.exists(os.path.join(path, fn)):53 self.warnings.append( (c + "/" + pluginname, str(exc)) )54 from traceback import print_exc55 print_exc()56 break57 else:58 print "Plugin probably removed, but not cleanly in", path59 try:60 os.rmdir(path)61 except:62 pass63 continue64 # allow single entry not to be a list65 if not isinstance(plugins, list):66 plugins = [ plugins ]67 for p in plugins:68 p.path = path69 p.updateIcon(path)70 new_plugins.append(p)71 keymap = os.path.join(path, "keymap.xml")72 if fileExists(keymap):73 try:74 keymapparser.readKeymap(keymap)75 except Exception, exc:76 print "keymap for plugin %s/%s failed to load: " % (c, pluginname), exc77 self.warnings.append( (c + "/" + pluginname, str(exc)) )78 # build a diff between the old list of plugins and the new one79 # internally, the "fnc" argument will be compared with __eq__80 plugins_added = [p for p in new_plugins if p not in self.pluginList]81 plugins_removed = [p for p in self.pluginList if not p.internal and p not in new_plugins]82 #ignore already installed but reloaded plugins83 for p in plugins_removed:84 for pa in plugins_added:85 if pa.path == p.path and pa.where == p.where:86 pa.needsRestart = False87 for p in plugins_removed:88 self.removePlugin(p)89 for p in plugins_added:90 if self.firstRun or p.needsRestart is False:91 self.addPlugin(p)92 else:93 for installed_plugin in self.installedPluginList:94 if installed_plugin.path == p.path:95 if installed_plugin.where == p.where:96 p.needsRestart = False97 self.addPlugin(p)98 if self.firstRun:99 self.firstRun = False100 self.installedPluginList = self.pluginList101 def getPlugins(self, where):102 """Get list of plugins in a specific category"""103 if not isinstance(where, list):104 # if not a list, we're done quickly, because the105 # lists are already sorted106 return self.plugins.get(where, [])107 res = []108 # Efficiently merge two sorted lists together, though this109 # appears to never be used in code anywhere...110 for x in where:111 for p in self.plugins.get(x, []):112 insort(res, p)113 return res114 def getPluginsForMenu(self, menuid):115 res = [ ]116 for p in self.getPlugins(PluginDescriptor.WHERE_MENU):117 res += p(menuid)118 return res119 def clearPluginList(self):120 self.pluginList = []121 self.plugins = {}122 def reloadPlugins(self, dummy=False):123 self.clearPluginList()124 self.readPluginList(resolveFilename(SCOPE_PLUGINS))125 def shutdown(self):126 for p in self.pluginList[:]:127 self.removePlugin(p)128 def resetWarnings(self):129 self.warnings = [ ]130 def getNextWakeupTime(self):131 wakeup = -1132 for p in self.pluginList:133 current = p.getWakeupTime()134 if current > -1 and (wakeup > current or wakeup == -1):135 wakeup = current136 return int(wakeup)...

Full Screen

Full Screen

plugin_pool.py

Source:plugin_pool.py Github

copy

Full Screen

...10class PluginPool(object):11 def __init__(self):12 self.plugins = {}13 self.discovered = False14 def discover_plugins(self):15 if self.discovered:16 return17 self.discovered = True18 load('cms_plugins')19 def register_plugin(self, plugin):20 """21 Registers the given plugin(s).22 If a plugin is already registered, this will raise PluginAlreadyRegistered.23 """24 if hasattr(plugin,'__iter__'):25 warnings.warn("Registering more than one plugin at once will be deprecated in 2.3", DeprecationWarning)26 for single_plugin in plugin:27 self.register_plugin(single_plugin)28 return29 if not issubclass(plugin, CMSPluginBase):30 raise ImproperlyConfigured(31 "CMS Plugins must be subclasses of CMSPluginBase, %r is not."32 % plugin33 )34 plugin_name = plugin.__name__35 if plugin_name in self.plugins:36 raise PluginAlreadyRegistered(37 "Cannot register %r, a plugin with this name (%r) is already "38 "registered." % (plugin, plugin_name)39 )40 plugin.value = plugin_name41 self.plugins[plugin_name] = plugin42 if 'reversion' in settings.INSTALLED_APPS:43 try:44 from reversion.registration import RegistrationError45 except ImportError:46 from reversion.revisions import RegistrationError47 try:48 reversion_register(plugin.model)49 except RegistrationError:50 pass51 def unregister_plugin(self, plugin):52 """53 Unregisters the given plugin(s).54 If a plugin isn't already registered, this will raise PluginNotRegistered.55 """56 if hasattr(plugin,'__iter__'):57 warnings.warn("Unregistering more than one plugin at once will be deprecated in 2.3", DeprecationWarning)58 for single_plugin in plugin:59 self.unregister_plugin(single_plugin)60 return 61 plugin_name = plugin.__name__62 if plugin_name not in self.plugins:63 raise PluginNotRegistered(64 'The plugin %r is not registered' % plugin65 )66 del self.plugins[plugin_name]67 def get_all_plugins(self, placeholder=None, page=None, setting_key="plugins", include_page_only=True):68 self.discover_plugins()69 plugins = self.plugins.values()[:]70 plugins.sort(key=lambda obj: unicode(obj.name))71 final_plugins = []72 if page:73 template = page.get_template()74 else:75 template = None76 allowed_plugins = get_placeholder_conf(77 setting_key,78 placeholder,79 template,80 )81 for plugin in plugins:82 include_plugin = False83 if placeholder:84 if allowed_plugins:85 if plugin.__name__ in allowed_plugins:86 include_plugin = True87 elif setting_key == "plugins":88 include_plugin = True89 if plugin.page_only and not include_page_only:90 include_plugin = False91 if include_plugin:92 final_plugins.append(plugin)93 94 if final_plugins:95 plugins = final_plugins96 # plugins sorted by modules97 plugins = sorted(plugins, key=lambda obj: unicode(obj.module))98 return plugins99 def get_text_enabled_plugins(self, placeholder, page):100 plugins = self.get_all_plugins(placeholder, page)101 plugins +=self.get_all_plugins(placeholder, page, 'text_only_plugins')102 final = []103 for plugin in plugins:104 if plugin.text_enabled:105 if plugin not in final:106 final.append(plugin)107 return final108 def get_plugin(self, name):109 """110 Retrieve a plugin from the cache.111 """112 self.discover_plugins()113 return self.plugins[name]...

Full Screen

Full Screen

module.js

Source:module.js Github

copy

Full Screen

1angular.module('ngCordova.plugins', [2 'ngCordova.plugins.actionSheet',3 'ngCordova.plugins.adMob',4 'ngCordova.plugins.appAvailability',5 'ngCordova.plugins.appRate',6 'ngCordova.plugins.appVersion',7 'ngCordova.plugins.backgroundGeolocation',8 'ngCordova.plugins.badge',9 'ngCordova.plugins.barcodeScanner',10 'ngCordova.plugins.batteryStatus',11 'ngCordova.plugins.beacon',12 'ngCordova.plugins.ble',13 'ngCordova.plugins.bluetoothSerial',14 'ngCordova.plugins.brightness',15 'ngCordova.plugins.calendar',16 'ngCordova.plugins.camera',17 'ngCordova.plugins.capture',18 'ngCordova.plugins.clipboard',19 'ngCordova.plugins.contacts',20 'ngCordova.plugins.datePicker',21 'ngCordova.plugins.device',22 'ngCordova.plugins.deviceMotion',23 'ngCordova.plugins.deviceOrientation',24 'ngCordova.plugins.dialogs',25 'ngCordova.plugins.emailComposer',26 'ngCordova.plugins.facebook',27 'ngCordova.plugins.facebookAds',28 'ngCordova.plugins.file',29 'ngCordova.plugins.fileTransfer',30 'ngCordova.plugins.fileOpener2',31 'ngCordova.plugins.flashlight',32 'ngCordova.plugins.flurryAds',33 'ngCordova.plugins.ga',34 'ngCordova.plugins.geolocation',35 'ngCordova.plugins.globalization',36 'ngCordova.plugins.googleAds',37 'ngCordova.plugins.googleAnalytics',38 'ngCordova.plugins.googleMap',39 'ngCordova.plugins.googlePlayGame',40 'ngCordova.plugins.googlePlus',41 'ngCordova.plugins.healthKit',42 'ngCordova.plugins.httpd',43 'ngCordova.plugins.iAd',44 'ngCordova.plugins.imagePicker',45 'ngCordova.plugins.inAppBrowser',46 'ngCordova.plugins.instagram',47 'ngCordova.plugins.keyboard',48 'ngCordova.plugins.keychain',49 'ngCordova.plugins.launchNavigator',50 'ngCordova.plugins.localNotification',51 'ngCordova.plugins.media',52 'ngCordova.plugins.mMediaAds',53 'ngCordova.plugins.mobfoxAds',54 'ngCordova.plugins.mopubAds',55 'ngCordova.plugins.nativeAudio',56 'ngCordova.plugins.network',57 'ngCordovaOauth',58 'ngCordova.plugins.pinDialog',59 'ngCordova.plugins.preferences',60 'ngCordova.plugins.printer',61 'ngCordova.plugins.progressIndicator',62 'ngCordova.plugins.push',63 'ngCordova.plugins.push_v5',64 'ngCordova.plugins.sms',65 'ngCordova.plugins.socialSharing',66 'ngCordova.plugins.spinnerDialog',67 'ngCordova.plugins.splashscreen',68 'ngCordova.plugins.sqlite',69 'ngCordova.plugins.statusbar',70 'ngCordova.plugins.toast',71 'ngCordova.plugins.touchid',72 'ngCordova.plugins.vibration',73 'ngCordova.plugins.videoCapturePlus',74 'ngCordova.plugins.zip',75 'ngCordova.plugins.insomnia'...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run yandex-tank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful