Best Python code snippet using avocado_python
setup.py
Source:setup.py
...101 return "DEVELOP UNLINK"102 else:103 return "DEVELOP LINK"104 @property105 def external_plugins_path(self):106 try:107 d = os.getenv("AVOCADO_EXTERNAL_PLUGINS_PATH")108 if not os.path.exists(d):109 return None110 return os.path.abspath(d)111 except TypeError:112 return None113 def initialize_options(self):114 super().initialize_options()115 self.external = 0 # pylint: disable=W0201116 self.skip_optional_plugins = 0 # pylint: disable=W0201117 def handle_uninstall(self):118 """When uninstalling, we remove the plugins before Avocado."""119 self._walk_develop_plugins()...
_install_or_update_configured_plugins.py
Source:_install_or_update_configured_plugins.py
1#!/usr/bin/env python2import os3import glob4import sys5import logging6from mfutil.cli import echo_running, echo_ok7from mfutil.plugins import get_plugin_hash, get_plugin_info, install_plugin, \8 uninstall_plugin9MFMODULE = os.environ['MFMODULE']10MFMODULE_RUNTIME_HOME = os.environ['MFMODULE_RUNTIME_HOME']11MFMODULE_HOME = os.environ['MFMODULE_HOME']12EXTERNAL_PLUGINS_PATH = \13 "/etc/metwork.config.d/%s/external_plugins" % MFMODULE.lower()14def i_plugin(typ, name, fil):15 echo_running("- Installing %s plugin: %s..." % (typ, name))16 install_plugin(fil)17 echo_ok()18def u_plugin(typ, name, fil):19 echo_running("- Updating %s plugin: %s..." % (typ, name))20 uninstall_plugin(name)21 install_plugin(fil)22 echo_ok()23internal_plugins_to_check = []24for key, value in os.environ.items():25 begin = "%s_INTERNAL_PLUGINS_INSTALL_" % MFMODULE26 if key.startswith(begin):27 if value.strip() == "1":28 internal_plugins_to_check.append(key.replace(begin, "").lower())29external_plugins_to_check = []30for fil in glob.glob("%s/*.plugin" % EXTERNAL_PLUGINS_PATH):31 h = get_plugin_hash(fil, mode="file")32 if h:33 external_plugins_to_check.append(fil)34for plugin in internal_plugins_to_check:35 installed_hash = get_plugin_hash(plugin, mode="name")36 candidates = sorted(glob.glob("%s/share/plugins/%s-*.plugin" %37 (MFMODULE_HOME, plugin)),38 key=os.path.getmtime)39 if len(candidates) == 0:40 logging.critical("can't find an installation file for plugin %s "41 "in %s/share/plugins/" % (plugin, MFMODULE_HOME))42 sys.exit(1)43 selected_file = candidates[-1]44 selected_hash = get_plugin_hash(selected_file, mode="file")45 if not selected_hash:46 logging.critical("the selected file: %s for the plugin %s is not "47 "correct" % (selected_file, plugin))48 sys.exit(1)49 if installed_hash is None:50 # not installed51 i_plugin("internal", plugin, selected_file)52 else:53 if selected_hash != installed_hash:54 installed_infos = get_plugin_info(plugin, mode="name")55 if installed_infos['metadatas']['release'] == "dev_link":56 continue57 # to update58 u_plugin("internal", plugin, selected_file)59for selected_file in external_plugins_to_check:60 infos = get_plugin_info(selected_file, mode="file")61 if not infos:62 continue63 name = infos['metadatas']['name']64 selected_hash = get_plugin_hash(selected_file, mode="file")65 installed_hash = get_plugin_hash(name, mode="name")66 if installed_hash is None:67 # not installed68 i_plugin("external", name, selected_file)69 pass70 else:71 if installed_hash != selected_hash:72 installed_infos = get_plugin_info(name, mode="name")73 if installed_infos['metadatas']['release'] == "dev_link":74 continue75 # to update...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!