Best Python code snippet using fMBT_python
osenv-tool
Source: osenv-tool
1#!/usr/bin/env python32# -*- coding: utf-8 -*-3# pylint: disable=C01034"""CLI Main for OSENV Tool.5Links:6 https://realpython.com/command-line-interfaces-python-argparse/7Later:8 bash-completion9 https://debian-administration.org/article/317/An_introduction_to_bash_completion_part_210 11 https://github.com/kislyuk/argcomplete/12"""13import argparse14import signal15import sys16import os17from lib import __version__, _program, _description18from lib.osenv_controller import OSEnvController19def signal_handler(sig, frame):20 print("\nYou pressed Ctrl+C. Abort!")21 sys.exit(0)22def main(arguments):23 """Arguments control action."""24 if args.environment is not None:25 OSEnvController.action_environment(arguments)26 elif args.list is not False:27 OSEnvController.action_list()28 elif args.clean is not False:29 OSEnvController.action_clean()30 elif args.read is not None:31 OSEnvController.action_read(arguments)32 elif args.write is not None:33 OSEnvController.action_write(arguments)34 elif args.edit is not None:35 OSEnvController.action_edit(arguments)36 else:37 sys.exit(1)38 sys.exit()39if __name__ == "__main__":40 signal.signal(signal.SIGINT, signal_handler)41 # create the top-level parser42 parser = argparse.ArgumentParser(43 prog=_program, description=_description44 )45 home_dir = os.path.expanduser('~/')46 ###47 group = parser.add_mutually_exclusive_group(required=True)48 group.add_argument(49 "--version",50 action="version",51 version="{program} {version}".format(program=_program, version=__version__),52 )53 group.add_argument(54 "-e",55 "--environment",56 metavar="<environment-name>",57 help="Load .ostackrc environment name.",58 )59 group.add_argument(60 "-l",61 "--list",62 action="store_true",63 help="List available .ostackrc environments.",64 )65 group.add_argument(66 "-c",67 "--clean",68 action="store_true",69 help="Clean up active .ostackrc environment.",70 )71 group.add_argument(72 "-r",73 "--read",74 nargs="?",75 const=home_dir + ".ostackrc.enc",76 metavar="<encoded-file>",77 help="""Read encoded file and set content to session variables.78 Default filename is ~/.ostackrc.enc.""",79 )80 group.add_argument(81 "-w",82 "--write",83 nargs="?",84 const=home_dir + ".ostackrc.enc",85 type=str,86 metavar="<encoded-file>",87 help="""Create and write encoded file with multiple ostackrc88 environments. Default filename is ~/.ostackrc.enc.""",89 )90 group.add_argument(91 "-i",92 "--edit",93 nargs="?",94 const=home_dir + ".ostackrc.enc",95 metavar="<encoded-file>",96 help="""Edit a encoded file and write it back.97 Default filename is ~/.ostackrc.enc.""",98 )99 ###100 # Execute the parse_args() method101 args = parser.parse_args()...
init_env.py
Source: init_env.py
1from util import cmloptions, loadoptions, check_if_dir_exist2import os3from SCons.Environment import *4from SCons.Variables import *5from SCons.Script import *6def init_environment(reqlist) :7 print("Initializing Environment:")8 opts = Variables()9 print(" - Variables")10 cmloptions(opts)11 OSENV = os.environ12 print(" - os.environ")13 # first check if there's qt5 in the requirement14 print("Loading environment...")15 need_qt5 = 016 list = reqlist.split()17 for l in list:18 if l == "qt5":19 QTDIR = OSENV['QTDIR']20 check_if_dir_exist('QTDIR', QTDIR)21 env = Environment(tools=['default', 'qt5'], options = opts)22 print("QT5 environment is loaded")23 need_qt5 = 124 break25 # if not, build default26 if need_qt5 == 0:27 env = Environment(tools=['default'], options = opts)28 print("Default environment is loaded")29 sdebug = 0;30 if env['SDEBUG'] == "1":31 sdebug = 132 print("SDEBUG is set")33 # Now scanning the dependencies34 for l in list:35 if l == "cadmesh":36 from loadcadmesh import loadcadmesh37 loadcadmesh(env, OSENV)38 elif l == "gcadmesh":39 from loadgcadmesh import loadcadmesh40 loadcadmesh(env, OSENV)41 elif l == "ccdb":42 from loadccdb import loadccdb43 loadccdb(env, OSENV)44 elif l == "clas":45 from loadclas import loadclas46 loadclas(env, OSENV)47 elif l == "clas12":48 from loadclas12 import loadclas1249 loadclas12(env, OSENV)50 elif l == "clhep":51 from loadclhep import loadclhep52 loadclhep(env, OSENV)53 elif l == "cuda":54 from loadcuda import loadcuda55 loadcuda(env)56 elif l == "evio":57 from loadevio import loadevio58 loadevio(env, OSENV)59 elif l == "geant4":60 from loadgeant4 import loadgeant461 loadgeant4(env, OSENV)62 elif l == "hipo":63 from loadhipo import loadhipo64 loadhipo(env, OSENV)65 elif l == "jana":66 from loadjana import loadjana67 loadjana(env, OSENV)68 elif l == "mu":69 from loadmu import loadmu70 loadmu(env, OSENV)71 elif l == "mlibrary":72 from loadmlibrary import loadmlibrary73 loadmlibrary(env, OSENV)74 elif l == "glibrary":75 from loadglibrary import loadglibrary76 loadglibrary(env, OSENV)77 elif l == "mysql":78 from loadmysql import loadmysql79 loadmysql(env, OSENV)80 elif l == "qt5":81 QTDIR = OSENV['QTDIR']82 from loadqt import loadqt83 loadqt(env, QTDIR)84 elif l == "root":85 from loadroot import loadroot86 loadroot(env, OSENV)87 elif l == "xercesc":88 from loadxerces import loadxerces89 loadxerces(env, OSENV)90 elif l == "c12bfields":91 from loadbc12Map import loadbc12Map92 loadbc12Map(env, OSENV)93 # generating help list94 Help(opts.GenerateHelpText(env))95 if sdebug == 1:96 print("Help List Generated")97 # loading options98 loadoptions(env)99 if sdebug == 1:100 print("Options Loaded")101 return env...
osenv.py
Source: osenv.py
1# -*- coding=utf-8 -*-2import os3###########################################################################4# ç³»ç»ç¯å¢åéçåå¾5###########################################################################6class OsEnv(object):7 def __call__(self, *argl, **argd):8 return self9 def _init_ctx_(self):10 from tyframework.context import TyContext11 self.__ctx__ = TyContext12 def __init__(self):13 self.__OSENV__ = None14 def _getEnvs(self):15 if OsEnv.__OSENV__ == None:16 OsEnv.__OSENV__ = {}17 e = os.environ18 for k in e:19 OsEnv.__OSENV__[k] = e[k]20 return OsEnv.__OSENV__21 def get_env(self, key):22 envs = self._getEnvs()23 return envs[key]24 def get_env_val(self, key, defaultValue=None):25 envs = self._getEnvs()26 if key in envs:27 return envs[key]28 return defaultValue...
Check out the latest blogs from LambdaTest on this topic:
Collecting and examining data from multiple sources can be a tedious process. The digital world is constantly evolving. To stay competitive in this fast-paced environment, businesses must frequently test their products and services. While it’s easy to collect raw data from multiple sources, it’s far more complex to interpret it properly.
Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
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!!