How to use build_dep method in avocado

Best Python code snippet using avocado_python

plugin.py

Source:plugin.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# =============================================================================3# module : utils/dependencies/plugin.py4# author : Matthieu Dartiailh5# license : MIT license6# =============================================================================7"""8"""9from atom.api import Typed, Dict10from enaml.workbench.api import Plugin11from collections import defaultdict12from inspect import cleandoc13import logging14from hqc_meas.tasks.tools.walks import flatten_walk15from hqc_meas.utils.configobj_ops import flatten_config16from .dependencies import BuildDependency, RuntimeDependency17BUILD_DEP_POINT = u'hqc_meas.dependencies.build'18RUNTIME_DEP_POINT = u'hqc_meas.dependencies.runtime'19class DependenciesManagerPlugin(Plugin):20 """ Build-dependencies manager for the TaskManager extension point.21 """22 # --- Public API ----------------------------------------------------------23 #: Dict holding all the build dependency collector indexed by id.24 build_collectors = Dict()25 #: List holding all the runtime dependency collector indexed by id.26 runtime_collectors = Dict()27 def start(self):28 """ Start the manager.29 """30 self._refresh_build_deps()31 self._refresh_runtime_deps()32 self._bind_observers()33 def stop(self):34 """ Stop the manager.35 """36 self._unbind_observers()37 self.build_collectors.clear()38 self.runtime_collectors.clear()39 self._build_extensions.clear()40 self._runtime_extensions.clear()41 def collect_dependencies(self, obj, dependencies=['build', 'runtime'],42 ids=[], caller=None):43 """ Build a dict of dependencies for a given obj.44 NB : This assumes the obj has a walk method similar to the one found45 in ComplexTask46 Parameters47 ----------48 obj : object with a walk method49 Obj for which dependencies should be computed.50 dependencies : {['build'], ['runtime'], ['build', 'runtime']}51 Kind of dependencies which should be gathered.52 ids : list, optional53 List of dependencies ids to use when collecting.54 caller : optional55 Calling plugin. Used for some runtime dependencies needing to know56 the ressource owner.57 Returns58 -------59 result : bool60 Flag indicating the success of the operation.61 dependencies : dict62 In case of success:63 - Dicts holding all the classes or other dependencies to build, run64 or build and run a task without any access to the workbench.65 If a single kind of dependencies is requested a single dict is66 returned otherwise two are returned one for the build ones and one67 for the runtime ones68 Otherwise:69 - dict holding the id of the dependencie and the asssociated70 error message.71 """72 # Use a set to avoid collecting several times the same entry, which73 # could happen if an entry is both a build and a runtime dependency.74 members = set()75 callables = {}76 if 'runtime' in dependencies and caller is None:77 raise RuntimeError(cleandoc('''Cannot collect runtime dependencies78 without knowing the caller plugin'''))79 if 'build' in dependencies:80 if ids:81 b = self.build_collectors82 build_deps = [dep for id, dep in b.iteritems()83 if id in ids]84 else:85 build_deps = self.build_collectors.values()86 for build_dep in build_deps:87 members.update(set(build_dep.walk_members))88 if 'runtime' in dependencies:89 if ids:90 r = self.runtime_collectors91 runtime_deps = [dep for id, dep in r.iteritems()92 if id in ids]93 else:94 runtime_deps = self.runtime_collectors.values()95 for runtime_dep in runtime_deps:96 members.update(set(runtime_dep.walk_members))97 callables.update(runtime_dep.walk_callables)98 walk = obj.walk(members, callables)99 flat_walk = flatten_walk(walk, list(members) + callables.keys())100 deps = ({}, {})101 errors = {}102 if 'build' in dependencies:103 for build_dep in self.build_collectors.values():104 try:105 deps[0].update(build_dep.collect(self.workbench,106 flat_walk))107 except ValueError as e:108 errors[build_dep.id] = e.message109 if 'runtime' in dependencies:110 for runtime_dep in self.runtime_collectors.values():111 try:112 deps[1].update(runtime_dep.collect(self.workbench,113 flat_walk, caller))114 except ValueError as e:115 errors[runtime_dep.id] = e.message116 if errors:117 return False, errors118 if 'build' in dependencies and 'runtime' in dependencies:119 return True, deps[0], deps[1]120 elif 'build' in dependencies:121 return True, deps[0]122 else:123 return True, deps[1]124 def collect_build_dep_from_config(self, config):125 """ Read a ConfigObj object to determine all the build dependencies of126 an object and get them in a dict.127 Parameters128 ----------129 manager : TaskManager130 Instance of the task manager.131 coonfig : Section132 Section representing the task hierarchy.133 Returns134 -------135 build_dep : nested dict or None136 Dictionary holding all the build dependencies of an obj.137 With this dict and the config the obj can be reconstructed without138 accessing the workbech.139 None is case of failure.140 """141 members = []142 for build_dep in self.build_collectors.values():143 members.extend(build_dep.walk_members)144 flat_config = flatten_config(config, members)145 build_deps = {}146 for build_dep in self.build_collectors.values():147 try:148 build_deps.update(build_dep.collect(self.workbench,149 flat_config))150 except ValueError as e:151 logger = logging.getLogger(__name__)152 logger.error(e.message)153 return None154 return build_deps155 def report(self):156 """ Give access to the failures which happened at startup.157 """158 return self._failed159 # --- Private API ---------------------------------------------------------160 #: Dict storing which extension declared which build dependency.161 _build_extensions = Typed(defaultdict, (list,))162 #: Dict storing which extension declared which runtime dependency.163 _runtime_extensions = Typed(defaultdict, (list,))164 def _refresh_build_deps(self):165 """ Refresh the list of known build dependency collectors.166 """167 workbench = self.workbench168 point = workbench.get_extension_point(BUILD_DEP_POINT)169 extensions = point.extensions170 if not extensions:171 self.build_collectors.clear()172 self._build_extensions.clear()173 return174 # Get the monitors declarations for all extensions.175 new_extensions = defaultdict(list)176 old_extensions = self._build_extensions177 for extension in extensions:178 if extensions in old_extensions:179 build_deps = old_extensions[extension]180 else:181 build_deps = self._load_build_deps(extension)182 new_extensions[extension].extend(build_deps)183 # Create mapping between monitor id and declaration.184 build_deps = {}185 for extension in extensions:186 for build_dep in new_extensions[extension]:187 if build_dep.id in build_deps:188 msg = "build_dep '%s' is already registered"189 raise ValueError(msg % build_dep.id)190 if not build_dep.walk_members:191 msg = "build_dep '%s' does not declare any dependencies"192 raise ValueError(msg % build_dep.id)193 if build_dep.collect is None:194 msg = "build_dep '%s' does not declare a collect function"195 raise ValueError(msg % build_dep.id)196 build_deps[build_dep.id] = build_dep197 self.build_collectors = build_deps198 self._build_extensions = new_extensions199 def _load_build_deps(self, extension):200 """ Load the Monitor object for the given extension.201 Parameters202 ----------203 extension : Extension204 The extension object of interest.205 Returns206 -------207 build_deps : list(BuildDependency)208 The list of BuildDependency declared by the extension.209 """210 workbench = self.workbench211 build_deps = extension.get_children(BuildDependency)212 if extension.factory is not None and not build_deps:213 for build_dep in extension.factory(workbench):214 if not isinstance(build_dep, BuildDependency):215 msg = "extension '%s' created non-Monitor."216 args = (extension.qualified_id)217 raise TypeError(msg % args)218 build_deps.append(build_dep)219 return build_deps220 def _refresh_runtime_deps(self):221 """ Refresh the list of known monitors.222 """223 workbench = self.workbench224 point = workbench.get_extension_point(RUNTIME_DEP_POINT)225 extensions = point.extensions226 if not extensions:227 self.runtime_collectors.clear()228 self._runtime_extensions.clear()229 return230 # Get the monitors declarations for all extensions.231 new_extensions = defaultdict(list)232 old_extensions = self._runtime_extensions233 for extension in extensions:234 if extensions in old_extensions:235 runtime_deps = old_extensions[extension]236 else:237 runtime_deps = self._load_runtime_deps(extension)238 new_extensions[extension].extend(runtime_deps)239 # Create mapping between monitor id and declaration.240 runtime_deps = {}241 for extension in extensions:242 for runtime_dep in new_extensions[extension]:243 if runtime_dep.id in runtime_deps:244 msg = "runtime_dep '%s' is already registered"245 raise ValueError(msg % runtime_dep.id)246 if not runtime_dep.walk_members\247 and not runtime_dep.walk_callables:248 msg = "build_dep '%s' does not declare any dependencies"249 raise ValueError(msg % runtime_dep.id)250 if runtime_dep.collect is None:251 msg = "build_dep '%s' does not declare a collect function"252 raise ValueError(msg % runtime_dep.id)253 runtime_deps[runtime_dep.id] = runtime_dep254 self.runtime_collectors = runtime_deps255 self._runtime_extensions = new_extensions256 def _load_runtime_deps(self, extension):257 """ Load the RuntimeDependency objects for the given extension.258 Parameters259 ----------260 extension : Extension261 The extension object of interest.262 Returns263 -------264 runtime_deps : list(RuntimeDependency)265 The list of RuntimeDependency declared by the extension.266 """267 workbench = self.workbench268 runtime_deps = extension.get_children(RuntimeDependency)269 if extension.factory is not None and not runtime_deps:270 for runtime_dep in extension.factory(workbench):271 if not isinstance(runtime_dep, RuntimeDependency):272 msg = "extension '%s' created non-RuntimeDependency."273 args = (extension.qualified_id)274 raise TypeError(msg % args)275 runtime_deps.append(runtime_dep)276 return runtime_deps277 def _update_runtime_deps(self, change):278 """279 """280 self._refresh_runtime_deps()281 def _update_build_deps(self, change):282 """283 """284 self._refresh_build_deps()285 def _bind_observers(self):286 """287 """288 point = self.workbench.get_extension_point(BUILD_DEP_POINT)289 point.observe('extensions', self._update_build_deps)290 point = self.workbench.get_extension_point(RUNTIME_DEP_POINT)291 point.observe('extensions', self._update_runtime_deps)292 def _unbind_observers(self):293 """294 """295 point = self.workbench.get_extension_point(BUILD_DEP_POINT)296 point.unobserve('extensions', self._update_build_deps)297 point = self.workbench.get_extension_point(RUNTIME_DEP_POINT)...

Full Screen

Full Screen

build-hb.py

Source:build-hb.py Github

copy

Full Screen

...122 hb.set_toolchain(builder.toolchain_path, builder.TOOLCHAIN)123 hb.configure(PackageTypes.HANDBRAKE, hb.dirname, builder.toolchain_path, builder.TOOLCHAIN)124 hb.script(['patch_handbrake.sh'], builder.dir_scripts)125 for dep_data in build_deps:126 builder.build_dep(dep_data)127 hb.build('build')128 hb.script(['bundle-hb.sh'], builder.dir_scripts, 'build')129 sys.exit(0)130 # builder.build_dep('https://datapacket.dl.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz', PackageTypes.CROSSHOST)131 # builder.build_dep('https://archive.mozilla.org/pub/opus/opus-1.2.1.tar.gz', PackageTypes.CROSSHOST)132 # builder.build_dep('http://downloads.us.xiph.org/releases/speex/speex-1.2.0.tar.gz', PackageTypes.CROSSHOST)133 # builder.build_dep('https://github.com/madler/zlib.git', PackageTypes.CROSSENV,134 # install_args=['install', 'prefix={0}'.format(builder.dir_dest)])135 # builder.build_dep('https://git.tukaani.org/xz.git', PackageTypes.CROSSHOST)136 # builder.build_dep('http://xmlsoft.org/sources/libxml2-2.9.8.tar.gz', PackageTypes.CROSSHOST, config_args = ['--without-python','--without-lzma'])137 # # builder.build_dep('https://github.com/akheron/jansson.git', PackageTypes.AUTORECONF)138 # # builder.build_dep('https://github.com/xiph/ogg.git', PackageTypes.CROSSHOST)139 # # builder.build_dep('http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.6.tar.gz', PackageTypes.CROSSHOST)140 # # builder.build_dep('https://github.com/erikd/libsamplerate.git', PackageTypes.CROSSHOST)141 # builder.build_dep('git://git.sv.nongnu.org/freetype/freetype2.git', PackageTypes.CROSSHOST,142 # force_autogen=True)143 # # builder.build_dep('https://github.com/fribidi/fribidi.git', PackageTypes.CROSSHOST)144 # # builder.build_dep('https://github.com/libass/libass.git', PackageTypes.CROSSHOST,145 # # config_args = ['--disable-require-system-font-provider'])146 # # builder.build_dep('http://git.videolan.org/git/x264.git', PackageTypes.CROSSHOST,147 # # config_args=['--enable-shared'], config_post = ['patch_x264.sh'], build_args = [], install_args = [])148 # # config_args=['--enable-shared'], config_post = ['patch_x264.sh'], build_args = ['lib-shared', 'SONAME=libx264.so'], install_args = ['install-lib-dev', 'install-lib-shared'])149 # builder.build_dep('https://github.com/libexpat/libexpat.git', PackageTypes.LIBEXPAT,150 # config_args=['--without-xmlwf'], build_dir='expat')151 # # builder.build_dep('https://git.xiph.org/theora.git', PackageTypes.CROSSHOST,152 # # config_args=['--with-ogg={0}'.format(builder.dir_dest)])153 # # builder.build_dep('https://github.com/harfbuzz/harfbuzz.git', PackageTypes.CROSSHOST)154 # builder.build_dep('https://vorboss.dl.sourceforge.net/project/libuuid/libuuid-1.0.3.tar.gz', PackageTypes.CROSSHOST)155 # builder.build_dep('http://ftp.gnu.org/pub/gnu/gperf/gperf-3.1.tar.gz', PackageTypes.CROSSHOST)156 # builder.build_dep('https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.13.0.tar.bz2', PackageTypes.CROSSHOST)157 # builder.build_dep('https://github.com/enthought/bzip2-1.0.6.git', PackageTypes.PLAINENV,158 # build_flags=[BuildFlags.SETENV], install_args=['install', 'PREFIX={0}'.format(builder.dir_dest)])159except Exception as e:160 print(e)...

Full Screen

Full Screen

reprocess_symbols.py

Source:reprocess_symbols.py Github

copy

Full Screen

1# This Source Code Form is subject to the terms of the Mozilla Public2# License, v. 2.0. If a copy of the MPL was not distributed with this3# file, You can obtain one at http://mozilla.org/MPL/2.0/.4"""5Transform the reprocess-symbols task description template,6taskcluster/ci/reprocess-symbols/job-template.yml into an actual task description.7"""8import logging9from taskgraph.transforms.base import TransformSequence10from taskgraph.util.treeherder import inherit_treeherder_from_dep, join_symbol11from gecko_taskgraph.util.attributes import (12 copy_attributes_from_dependent_job,13)14logger = logging.getLogger(__name__)15transforms = TransformSequence()16@transforms.add17def fill_template(config, tasks):18 for task in tasks:19 assert len(task["dependent-tasks"]) == 220 build_dep = task["primary-dependency"]21 upload_dep = None22 for dep_idx in task["dependent-tasks"]:23 dep = task["dependent-tasks"][dep_idx]24 if dep_idx != build_dep:25 upload_dep = dep26 task.pop("dependent-tasks", None)27 # Fill out the dynamic fields in the task description28 task["label"] = build_dep.label + "-reprocess-symbols"29 task["dependencies"] = {"build": build_dep.label, "upload": upload_dep.label}30 task["worker"]["env"]["GECKO_HEAD_REPOSITORY"] = config.params[31 "head_repository"32 ]33 task["worker"]["env"]["GECKO_HEAD_REV"] = config.params["head_rev"]34 task["worker"]["env"]["CRASHSTATS_SECRET"] = task["worker"]["env"][35 "CRASHSTATS_SECRET"36 ].format(level=config.params["level"])37 attributes = copy_attributes_from_dependent_job(build_dep)38 attributes.update(task.get("attributes", {}))39 task["attributes"] = attributes40 treeherder = inherit_treeherder_from_dep(task, build_dep)41 th = build_dep.task.get("extra")["treeherder"]42 th_symbol = th.get("symbol")43 th_groupsymbol = th.get("groupSymbol", "?")44 # Disambiguate the treeherder symbol.45 sym = "Rep" + (th_symbol[1:] if th_symbol.startswith("B") else th_symbol)46 treeherder.setdefault("symbol", join_symbol(th_groupsymbol, sym))47 task["treeherder"] = treeherder48 task["run-on-projects"] = build_dep.attributes.get("run_on_projects")49 task["optimization"] = {"reprocess-symbols": None}50 task["if-dependencies"] = ["build"]51 del task["primary-dependency"]...

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 avocado 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