How to use build_package method in tox

Best Python code snippet using tox_python

tasks.py

Source:tasks.py Github

copy

Full Screen

...13import logging14import commonware.log15log = commonware.log.getLogger('celery')16@task(name='build_package')17def build_package(package_build_id=None):18 """19 Placeholder variable should_kill_mock20 Since I have implemented a timeout exception block21 I've not had to manually kill the mock environment.22 Should it become necessary to manually kill the mock,23 the variable will be the flag24 """25 should_kill_mock = False26 build_package = models.MozillaPackageBuild.objects.get(id=package_build_id)27 log.debug('Mozilla Package: %s' % build_package.mozilla_package)28 mock_environment = Mock(build_package)29 mock_environment.build_mock()30 mock_environment.install_packages()31 mock_environment.install_build_file()32 mock_environment.copyin_source_file()33 """34 Here we're copying in a new version of file.rb35 Pretty hacky, but works in the interim until36 the upstream version gets patched to function37 on ruby < 1.938 On line 187 of build_scripts/file.rb I have commented out39 #buffer.force_encoding("BINARY") 40 force_encoding is new in Ruby 1.941 """42 mock_environment.patch_arr_pm()43 """44 Set successful_build to false,45 only copy out the built package if46 this is true47 """48 successful_build = False49 build_status = 'Failed'50 try:51 mock_environment.compile_package()52 successful_build = True53 except TimeLimitExceeded:54 should_kill_mock = True55 print "TimeLimitExceeded Caught"56 except SoftTimeLimitExceeded:57 should_kill_mock = True58 print "SoftTimeLimitExceeded Caught"59 """60 Always capture and save the error_log61 """62 error_log = mock_environment.error_log63 build_package.add_log('ERROR', error_log)64 if successful_build:65 build_log = mock_environment.build_log66 path = mock_environment.build_path67 """68 When building .debs from pypi69 the path has a leading /70 remove it if path is not None71 """72 if path:73 path = path.lstrip('/')74 log.debug('Task: build_package. Path is %s' % path)75 if path != '' and path is not None:76 build_package.add_log('INFO', 'Built File %s' % path)77 build_status = 'Completed'78 build_package.add_log('INFO', build_log)79 mock_environment.copyout_built_package(path, BUILD_DIR)80 else:81 build_status = 'Failed'82 build_package.add_log('INFO', 'Build %s' % build_status)83 build_package.build_status = build_status84 build_package.build_package_name = path85 build_package.save()86@task(name='build_mock_environment')87def build_mock_environment(moz_package=None, task_id=None):88 should_kill_mock = False89 mp = MozPackager(moz_package)90 mp.build_mock()91 try:92 message, path, status = mp.build_package(source=moz_package.input_type,93 destination=moz_package.output_type,94 upload_package=moz_package.upload_package_file_name,95 package=moz_package.install_package_name,96 version=moz_package.package_version,97 dependencies=moz_package.dependencies,98 )99 except TimeLimitExceeded:100 should_kill_mock = True101 print "TimeLimitExceeded Caught"102 except SoftTimeLimitExceeded:103 should_kill_mock = True104 print "SoftTimeLimitExceeded Caught"105 if should_kill_mock:106 try:...

Full Screen

Full Screen

init.py

Source:init.py Github

copy

Full Screen

1# Copyright 2013 The Chromium Authors. All rights reserved.2# Use of this source code is governed by a BSD-style license that can be3# found in the LICENSE file.4"""A module for the init command."""5import os6import cr7# The set of variables to store in the per output configuration.8OUT_CONFIG_VARS = [9 'CR_VERSION',10 cr.Platform.SELECTOR, cr.BuildType.SELECTOR, cr.Arch.SELECTOR,11 'CR_OUT_BASE', 'CR_OUT_FULL',12]13class InitCommand(cr.Command):14 """The implementation of the init command.15 The init command builds or updates an output directory.16 It then uses the Prepare and Select commands to get that directory17 ready to use.18 """19 def __init__(self):20 super(InitCommand, self).__init__()21 self.requires_build_dir = False22 self.help = 'Create and configure an output directory'23 self.description = ("""24 If the .cr directory is not present, build it and add25 the specified configuration.26 If the file already exists, update the configuration with any27 additional settings.28 """)29 self._settings = []30 def AddArguments(self, subparsers):31 """Overridden from cr.Command."""32 parser = super(InitCommand, self).AddArguments(subparsers)33 cr.Platform.AddArguments(parser)34 cr.BuildType.AddArguments(parser)35 cr.Arch.AddArguments(parser)36 cr.SelectCommand.AddPrepareArguments(parser)37 parser.add_argument(38 '-s', '--set', dest='_settings', metavar='settings',39 action='append',40 help='Configuration overrides.'41 )42 return parser43 def EarlyArgProcessing(self):44 base_settings = getattr(cr.context.args, '_settings', None)45 if base_settings:46 self._settings.extend(base_settings)47 # Do not call super early processing, we do not want to apply48 # the output arg...49 out = cr.base.client.GetOutArgument()50 if out:51 # Output directory is fully specified52 # We need to deduce other settings from it's name53 base, buildtype = os.path.split(out)54 if not (base and buildtype):55 print 'Specified output directory must be two levels'56 exit(1)57 if not cr.BuildType.FindPlugin(buildtype):58 print 'Specified build type', buildtype, 'is not valid'59 print 'Must be one of', ','.join(p.name for p in cr.BuildType.Plugins())60 exit(1)61 if (cr.context.args.CR_BUILDTYPE and62 cr.context.args.CR_BUILDTYPE != buildtype):63 print 'If --type and --out are both specified, they must match'64 print 'Got', cr.context.args.CR_BUILDTYPE, 'and', buildtype65 exit(1)66 platform = cr.context.args.CR_PLATFORM67 if not platform:68 # Try to guess platform based on output name69 platforms = [p.name for p in cr.Platform.AllPlugins()]70 matches = [p for p in platforms if p in base]71 if len(matches) != 1:72 print 'Platform is not set, and could not be guessed from', base73 print 'Should be one of', ','.join(platforms)74 if len(matches) > 1:75 print 'Matched all of', ','.join(matches)76 exit(1)77 platform = matches[0]78 cr.context.derived.Set(79 CR_OUT_FULL=out,80 CR_OUT_BASE=base,81 CR_PLATFORM=platform,82 CR_BUILDTYPE=buildtype,83 )84 if not 'CR_OUT_BASE' in cr.context:85 cr.context.derived['CR_OUT_BASE'] = 'out_{CR_PLATFORM}'86 if not 'CR_OUT_FULL' in cr.context:87 cr.context.derived['CR_OUT_FULL'] = os.path.join(88 '{CR_OUT_BASE}', '{CR_BUILDTYPE}')89 def Run(self):90 """Overridden from cr.Command."""91 src_path = cr.context.Get('CR_SRC')92 if not os.path.isdir(src_path):93 print cr.context.Substitute('Path {CR_SRC} is not a valid client')94 exit(1)95 # Ensure we have an output directory override ready to fill in96 # This will only be missing if we are creating a brand new output97 # directory98 build_package = cr.auto.build99 # Collect the old version (and float convert)100 old_version = cr.context.Find('CR_VERSION')101 try:102 old_version = float(old_version)103 except (ValueError, TypeError):104 old_version = 0.0105 is_new = not hasattr(build_package, 'config')106 if is_new:107 class FakeModule(object):108 OVERRIDES = cr.Config('OVERRIDES')109 def __init__(self):110 self.__name__ = 'config'111 old_version = None112 config = FakeModule()113 setattr(build_package, 'config', config)114 cr.plugin.ChainModuleConfigs(config)115 # Force override the version116 build_package.config.OVERRIDES.Set(CR_VERSION=cr.base.client.VERSION)117 # Add all the variables that we always want to have118 for name in OUT_CONFIG_VARS:119 value = cr.context.Find(name)120 build_package.config.OVERRIDES[name] = value121 # Apply the settings from the command line122 for setting in self._settings:123 name, separator, value = setting.partition('=')124 name = name.strip()125 if not separator:126 value = True127 else:128 value = cr.Config.ParseValue(value.strip())129 build_package.config.OVERRIDES[name] = value130 # Run all the output directory init hooks131 for hook in cr.InitHook.Plugins():132 hook.Run(old_version, build_package.config)133 # Redo activations, they might have changed134 cr.plugin.Activate()135 # Write out the new configuration, and select it as the default136 cr.base.client.WriteConfig(cr.context.Get('CR_BUILD_DIR'),137 build_package.config.OVERRIDES.exported)138 # Prepare the platform in here, using the updated config139 cr.Platform.Prepare()...

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