How to use default_env method in molecule

Best Python code snippet using molecule_python

SConstruct

Source:SConstruct Github

copy

Full Screen

1#Copyright (C) 2011 by Francois Coulombe2# Permission is hereby granted, free of charge, to any person obtaining a copy3# of this software and associated documentation files (the "Software"), to deal4# in the Software without restriction, including without limitation the rights5# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell6# copies of the Software, and to permit persons to whom the Software is7# furnished to do so, subject to the following conditions:8# The above copyright notice and this permission notice shall be included in9# all copies or substantial portions of the Software.10# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR11# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,12# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE13# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER14# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,15# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN16# THE SOFTWARE.17# 18import os19import os.path20import atexit21import sys22import platform23import subprocess24#################################################################25#26# adding custom commandline argument27#28#################################################################29AddOption('--verbose', action="store_true", 30 dest="verbose",31 default=False,32 help='make the build verbose')33AddOption('--use-valgrind', action="store_true", 34 dest="useValgrind",35 default=False,36 help='run the unit tests with valgrind')37AddOption('--print-component-dependencies', action="store_true", 38 dest="print-component-dependencies",39 default=False,40 help='prints the component dependnecies for the programs')41AddOption('--gen-valgrind-suppressions', action="store_true", 42 dest="genValgrindSuppressions",43 default=False,44 help='generate valgrind suppression files')45AddOption('--compiler', action="store",46 type='string', 47 dest="compiler",48 default='gcc',49 help='specify the compiler')50AddOption('--configuration', action="store",51 type='string', 52 dest="configuration",53 default='debug',54 help='specify whether we are compiling in (debug, opt) mode')55########################################################################56#57# fetching some other packages from github if they don't seem to be there58# usually on used on very first build59#60########################################################################61targetList = COMMAND_LINE_TARGETS62default_env = Environment()63default_env.SConsignFile(default_env.File("#build/.sconsign.dblite").abspath) 64#detect if we have the build script installed (hopefully its gonna be the right one)65##############################################66#67# SELECT COMPILER68#69##############################################70compiler = GetOption('compiler')71lflags = [] 72cflags = [ ]73if default_env['PLATFORM']=='darwin':74 cflags.append("-DOS_MACOSX")75elif default_env['PLATFORM']=='win32':76 cflags.append("-DOS_WIN32")77else:78 cflags.append("-DOS_LINUX") 79 80if platform.architecture()[0] == "32bit":81 cflags.append('-DUSE_64BIT_PLATFORM=0')82elif platform.architecture()[0] == "64bit":83 cflags.append('-DUSE_64BIT_PLATFORM=1')84else:85 print "unsupported architecture: %s" % platform.architecture()[0] 86configuration = GetOption('configuration')87if compiler == 'gcc':88 extracflags = [ "-g", "-Wall", '-fexceptions', '-ftrapv', '-DFBXSDK_NEW_API'] #, '-fvisibility=hidden'] 89 cflags.extend(extracflags)90 cflags.append("-Werror")91 cflags.append("-Wextra")92 default_env['CXX'] = 'g++'93 default_env['CC'] = 'gcc'94 #default_env['CXX'] = 'scan-build g++'95 #default_env['CC'] = 'scan-build gcc'96 cflags.append("-std=c++0x");97 #cflags.append("-pedantic")98 lflags.append("-L/usr/lib/")99 lflags.append("-rdynamic");100 if configuration == 'debug':101 cflags.append("-O0")102 elif configuration == 'opt':103 cflags.append("-O3")104elif compiler == 'clang':105 extracflags = [ "-g", "-Wall", '-fexceptions', '-ftrapv', '-DFBXSDK_NEW_API'] #, '-fvisibility=hidden'] 106 cflags = cflags+extracflags107 108 if default_env['PLATFORM']=='darwin':109 default_env['CXX'] = '/Developer//usr/bin/clang++'110 default_env['CC'] = '/Developer//usr/bin/clang'111 else:112 default_env['CXX'] = 'clang++'113 default_env['CC'] = 'clang'114 cflags.append("-std=c++0x");115 cflags.append("-pedantic")116 cflags.append("-Wextra" )117 #cflags.append("-Werror" )118 lflags.append("-L/usr/lib/")119 if configuration == 'debug':120 cflags.append("-O0")121 elif configuration == 'opt':122 cflags.append("-O3")123elif compiler == 'vc':124 default_env['CXX'] = 'cl.exe'125 default_env['CC'] = 'cl.exe'126 cflags.append("/WX")127 cflags.append("/EHsc")128 cflags.append("/ZI")129 if configuration == 'debug':130 cflags.append("-Od")131 elif configuration == 'opt':132 cflags.append("-O3")133 #lflags.append("/NODEFAULTLIB:library")134 lflags.append("/DEBUG")135 cflags.append("/MDd")136else:137 print "this isn't good"138default_env.Append(CPPPATH=[default_env.Dir("#3rdParty/include")])139#default_env['CXX'] = 'scan-build -k'140#default_env['CC'] = 'scan-build -k'141default_env.AppendUnique(CPPFLAGS=cflags )142default_env.AppendUnique(CFLAGS=cflags)143#default_env.AppendUnique(CXXFLAGS=cflags)144default_env.AppendUnique(LINKFLAGS=lflags)145variant ="%s-%s-%s-%s" % (default_env['CC'], platform.machine(), platform.architecture()[0], configuration) 146print variant147if not GetOption('verbose'):148 default_env['RANLIBCOMSTR'] = "[ranlib] $TARGET" 149 default_env['ARCOMSTR'] = "[ar] $TARGET"150 default_env['CCCOMSTR'] = "[cc] $SOURCE"151 default_env['CXXCOMSTR'] = "[cxx] $SOURCE"152 default_env['LINKCOMSTR'] = "[link] $TARGET"153 default_env['INSTALLSTR'] = '[install] $TARGET'154default_env['INSTALL_DIR'] = '#/bin/' + variant 155default_env['BUILD_VARIANT'] = variant156 157##############################################158##############################################159default_env.Tool('Profiler', toolpath=['site_scons/site_tools'])160default_env.Tool('Catalog', toolpath=['site_scons/site_tools'])161default_env.Tool('SConsWalk', toolpath=['site_scons/site_tools'])162default_env.Tool('Wrappers', toolpath=['site_scons/site_tools'])163default_env.Tool('RSync', toolpath=['site_scons/site_tools'])164default_env.Tool('Data', toolpath=['site_scons/site_tools'])165default_env.Tool('UnitTest', toolpath=['site_scons/site_tools'])166if default_env['PLATFORM']=='win32':167 #default_env['ENV']['PATH'] += "C:\Program Files/Microsoft Visual Studio 10.0/VC/bin/"168 print "1"169 os.system("\"c:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat\"")170 print "2"171else:172 default_env['ENV']['PATH'] = '/usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/Developer/usr/bin' 173 default_env['ENV']['PKG_CONFIG_PATH'] = '/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig'174 print default_env['ENV']['PATH']175sconsFilesList = [176#third party177"./3rdParty/freetype/SConscript",178"./3rdParty/il/SConscript",179"./3rdParty/libfreenect/SConscript",180"./3rdParty/zlib/SConscript",181"./3rdParty/libpng/SConscript",182"./3rdParty/opencv/SConscript",183"./3rdParty/opengl/SConscript",184"./3rdParty/openal/SConscript",185"./3rdParty/ogg/SConscript",186"./3rdParty/ogre/SConscript",187"./3rdParty/ois/SConscript",188"./3rdParty/vorbis/SConscript",189"./3rdParty/glew/SConscript",190"./3rdParty/sdl/SConscript",191"./3rdParty/pthread/SConscript",192#libs193"./lib/gcl/gcl/SConscript",194"./lib/tanklib/SConscript",195#tools196"./program/tools/common/SConscript",197"./program/tools/common/unittest/SConscript",198"./program/tools/meshconverter/SConscript",199#tools unittest200"./lib/gcl/gcl/unittest/SConscript",201"./lib/tanklib/unittest/SConscript",202#unittest203#programs204"./program/tank/SConscript",205]206if GetOption('genValgrindSuppressions'):207 sconsFilesList.append("./tools/valgrindgen/SConscript") #this tool generates some rules for valgrind so that it ignores certain pattern of memory errors that we don't care about208#default_env.StampTime("start SConscript Parse...")209default_env.SConsWalkList(sconsFilesList, './SConscript', variant)210default_env.StampTime("Parsing Time")211if "@aliases" in targetList:212 default_env.displayAliases()213 sys.exit()214def OnExit():215 default_env.StampTime("exit")...

Full Screen

Full Screen

test_evaluate.py

Source:test_evaluate.py Github

copy

Full Screen

...7@pytest.fixture(autouse=True)8def clear_mode(monkeypatch):9 monkeypatch.setenv("CLRENV_MODE", "")10@pytest.fixture()11def default_env(tmp_path):12 env_path = tmp_path / "env"13 env_path.write_text(14 yaml.dump({"base": {"a": "b", "aa": {"bb": "cc", "bbb": "ccc"}}})15 )16 return clrenv.evaluate.RootClrEnv([env_path])17def test_make_env_var_name():18 fn = functools.partial(clrenv.evaluate.SubClrEnv._make_env_var_name, None)19 assert fn(("a",)) == "CLRENV__A"20 assert fn(("a", "b", "c")) == "CLRENV__A__B__C"21 assert fn(("a", "b", "c_d")) == "CLRENV__A__B__C_D"22 assert fn(tuple(), as_prefix=True) == "CLRENV__"23 assert fn(("a", "b"), as_prefix=True) == "CLRENV__A__B__"24def test_base(default_env):25 assert default_env.a == "b"...

Full Screen

Full Screen

mc_env.py

Source:mc_env.py Github

copy

Full Screen

1#!/usr/bin/env python2# -*- coding: utf-8 -*-3'''4.. _module_mc_env:5mc_env / env registry6============================================7If you alter this module and want to test it, do not forget8to deploy it on minion using::9 salt '*' saltutil.sync_modules10Documentation of this module is available with::11 salt '*' sys.doc mc_env12'''13# Import python libs14import logging15import os16import mc_states.api17from mc_states.modules.mc_pillar import PILLAR_TTL18__name = 'env'19log = logging.getLogger(__name__)20RVM_URL = (21 'https://raw.github.com/wayneeseguin/env/master/binscripts/env-installer')22def is_reverse_proxied():23 return __salt__['mc_cloud.is_vm']()24def settings():25 '''26 env registry27 default_env28 Environment defaults (one of: dev/prod/preprod)29 '''30 @mc_states.api.lazy_subregistry_get(__salt__, __name)31 def _settings():32 _s = __salt__33 default_env = _s['mc_utils.get']('default_env', None)34 # ATTENTION: DO NOT USE 'env' to detect when we configure35 # over when we inherit between salt modes36 local_conf = __salt__['mc_macros.get_local_registry'](37 'default_env', registry_format='pack')38 # in makina-states, only salt mode,39 if default_env is None:40 default_env = local_conf.get('default_env', None)41 mid = __opts__['id']42 if default_env is None:43 for pattern in ['prod', 'staging', 'dev']:44 if pattern in mid:45 default_env = pattern46 if default_env is None:47 default_env = 'dev'48 # rely mainly on pillar:49 # - makina-states.localsettings.env.env50 # but retro compat and shortcut on pillar51 # - default_env52 data = _s['mc_utils.defaults'](53 'makina-states.localsettings.env', {54 'env': None})55 save = False56 # detect when we configure over default value57 if data['env'] is None:58 data['env'] = default_env59 else:60 save = True61 # retro compat62 data['default_env'] = data['env']63 if save:64 local_conf['default_env'] = data['env']65 __salt__['mc_macros.update_registry_params'](66 'default_env', local_conf, registry_format='pack')67 return data68 return _settings()69def env():70 return settings()['env']71def ext_pillar(id_, ttl=PILLAR_TTL, *args, **kw):72 def _do(id_, args, kw):73 rdata = {}74 conf = __salt__['mc_pillar.get_configuration'](id_)75 rdata['default_env'] = rdata['env'] = conf['default_env']76 return rdata77 cache_key = '{0}.{1}.{2}'.format(__name, 'ext_pillar', id_)78 return __salt__['mc_utils.memoize_cache'](79 _do, [id_, args, kw], {}, cache_key, ttl)...

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