Best Python code snippet using fMBT_python
make.py
Source: make.py
...11MICRON_INSTALL_DIR = abspath("guichan")12SDL_CXXFLAGS = "-I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT"13SDL_LDFLAGS = "-L/usr/lib -lSDL -lSDL_image -lSDL_ttf "14PYTHON_INCLUDE_DIR = "/usr/include/python2.5"15def exec_in(path):16 def dec_f(f):17 def new_f(*args,**kwargs):18 os.chdir(path)19 try:20 return f(*args,**kwargs)21 finally:22 os.chdir("../..")23 return new_f24 return dec_f25def system(cmd):26 print cmd27 os.system(cmd)28@exec_in(GUICHAN_BUILD_DIR)29def make_guichan_interfaces():30 ifaces = sorted(glob.glob("interfaces/*.i"))31 ifaces += sorted(glob.glob("interfaces/widgets/*.i"))32 in_templ = open("guichan_template.i").read()33 includes = ''.join(['%%include %s\n' % iface for iface in ifaces])34 out_file = open("guichan.i","w")35 out_file.write( in_templ )36 out_file.write( includes )37 out_file.close()38 print includes39 40@exec_in(GUICHAN_BUILD_DIR)41def make_guichan_cxx():42 cmd = "swig -w511 -c++ -python -I%s -outdir swig_wrapper guichan.i" % GUICHAN_INCLUDE_DIR43 system(cmd)44@exec_in(GUICHAN_BUILD_DIR)45def make_guichan_wrap():46 cmd = "c++ guichan_wrap.cxx -I%(GUICHAN_INCLUDE_DIR)s -I. -I%(PYTHON_INCLUDE_DIR)s -o guichan_wrap.o -c -fPIC -ggdb -O0" % globals()47 system(cmd)48 sofiles = GUICHAN_LIB_DIR + "/libguichan.so"49 cmd = "c++ -shared guichan_wrap.o %%s -o swig_wrapper/_guichan.so -Wl,-rpath=%(GUICHAN_LIB_DIR)s " % globals()50 system(cmd % sofiles)51@exec_in(MICRON_BUILD_DIR)52def make_micron_lib():53 sources = [(src,src[:-3]+"o") for src in sorted(glob.glob("src/*.cpp"))]54 for src, objfile in sources:55 cmd = "c++ -fPIC -c -g -O0 %%s -o %%s -I%(GUICHAN_INCLUDE_DIR)s %(SDL_CXXFLAGS)s" % globals()56 cmd = cmd % (src, objfile)57 system(cmd)58 objfiles = " ".join([objfile for src,objfile in sources])59 sofiles = " ".join([GUICHAN_LIB_DIR + "/libguichan%s.so" % variant for variant in ['','_opengl']])60 cmd = "c++ -fPIC -shared %%s %%s -o libmicron.so -Wl,-rpath=%(GUICHAN_LIB_DIR)s" % globals()61 cmd = cmd % (objfiles,sofiles)62 system(cmd)63@exec_in(MICRON_BUILD_DIR)64def make_micron_cxx():65 cmd = "swig -w511 -c++ -python -I./src -Wall -outdir swig_wrapper micron.i"66 system(cmd)67@exec_in(MICRON_BUILD_DIR)68def make_micron_wrap():69 cmd = "c++ micron_wrap.cxx -I. -I./src -I%(GUICHAN_INCLUDE_DIR)s -I%(PYTHON_INCLUDE_DIR)s -o micron_wrap.o -c -fPIC -ggdb -O0 %(SDL_CXXFLAGS)s" % globals()70 system(cmd)71 LDFLAGS=" -lGL %(SDL_LDFLAGS)s -lguichan -lguichan_sdl " % globals()72 cmd = "c++ -shared micron_wrap.o libmicron.so -o swig_wrapper/_micron.so -L%(GUICHAN_LIB_DIR)s -Wl,-rpath=%(MICRON_LIB_DIR)s" % globals()73 system(cmd + LDFLAGS)74def make_micron_install():75 system("cp %(MICRON_BUILD_DIR)s/swig_wrapper/micron.py %(MICRON_INSTALL_DIR)s/" % globals())76 system("cp %(MICRON_BUILD_DIR)s/swig_wrapper/_micron.so %(MICRON_INSTALL_DIR)s/" % globals())77 system("cp %(MICRON_BUILD_DIR)s/libmicron.so %(MICRON_LIB_DIR)s/" % globals())78def make_guichan_install():79 system("cp %(GUICHAN_BUILD_DIR)s/swig_wrapper/guichan.py %(GUICHAN_INSTALL_DIR)s/" % globals())80 system("cp %(GUICHAN_BUILD_DIR)s/swig_wrapper/_guichan.so %(GUICHAN_INSTALL_DIR)s/" % globals())81 ...
utils.py
Source: utils.py
...5from tornado.web import RequestHandler6def config_from_file(path, final=True):7 config = {}8 with open(path) as f:9 exec_in(f.read(), config, config)10 for name in config:11 if not name in options._options:12 define(name)13 options._options[name].set(str(config[name]))14def css_html(path):15 html = '<link rel="stylesheet" type="text/css" href="%s" />' % path16 return html17def js_html(path):18 html = ('<script language="javascript" '19 'type="text/javascript" src="%s"></script>' % path)20 return html21def __default(obj):22 if isinstance(obj, datetime):23 return obj.strftime("%Y-%m-%d %H:%M:%S")...
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!!