How to use modules_needed method in autotest

Best Python code snippet using autotest_python

config.py

Source:config.py Github

copy

Full Screen

1import sys, os, modulefinder, pkgutil, subprocess23from . import etc_default4from . import etc56test_should_clobber_config = False7if "UNIT_TEST" in globals():8 if UNIT_TEST:9 if pkgutil.find_loader("config.etc_test_overrides"):10 pkgutil.find_loader("config.etc_test_overrides").load()11 test_should_clobber_config = True121314class configuration:1516 @staticmethod17 def check_packages():18 mdfinder = modulefinder.ModuleFinder(path=['..',])19 builtin_packages = sys.builtin_module_names20 installed_packages = [x[1] for x in pkgutil.iter_modules()]21 here_packages = [x[1] for x in pkgutil.iter_modules()]2223 # installed_packages=pip.get_installed_distributions()24 # installed_packages=[x.project_name for x in installed_packages]25 required_modules = set()26 for root, dirs, files in os.walk("..", followlinks=False):27 for fil in files:28 if fil.endswith(".py"):29 print(os.path.join(root, fil))30 mdfinder.run_script(os.path.join(root, fil))31 top_packages = [32 x.split(".")[0] for x in list(mdfinder.modules.keys())33 ]34 required_modules |= set(top_packages)3536 modules_needed = []37 for mod in required_modules:38 if (39 (mod not in builtin_packages)40 and (mod not in installed_packages)41 and (mod not in here_packages)42 ):43 modules_needed.append(mod)44 if modules_needed:45 print("FATAL CONFIGURATION ERROR !")46 print("The following modules need to be installed for Infoshopkeeper to run.")47 print("Use pip, apt-get, conda or your preferred package manager to download.")48 for m in modules_needed:49 print(("%s is not installed" % m))50 sys.exit(0)5152 @staticmethod53 def improper_config_die(var):54 print("FATAL CONFIGURATION ERROR !")55 print("Unable to reach configuration value %s" % var)56 print(" (did you modify the config before using ? did you used an")57 print(58 " obsolete config file ?)"59 )60 print("\n\n\n")61 sys.exit(0)6263 @staticmethod64 def no_sql_die(sql_type):65 print("FATAL CONFIGURATION ERROR !")66 print("infoshopkeeper requires MySQL, PostGreSQL or sqlite to be installed.")67 print("""You are configured to use sql database type '%s' and it is not installed \n68 or not reachable via your system path.""")6970 @staticmethod71 def get(var):72 if test_should_clobber_config and hasattr(etc_tst, var):73 return getattr(etc_tst, var)74 elif hasattr(etc, var):75 return getattr(etc, var)76 elif hasattr(etc_default, var):77 return getattr(etc_default, var)78 else:79 improper_config_die.__func__(var)8081 db_type = get.__func__("dbtype")82 if db_type == "mysql":83 try:84 subprocess.call("mysql --version", shell=True)85 except subprocess.CalledProcessError as e:86 no_sql_die.__func__(db_type)87 elif db_type == "postgres":88 try:89 subprocess.call("postgres -v", shell=True)90 except subprocess.CalledProcessError as e:91 no_sql_die.__func__(db_type)92 elif get("dbytpy") == "sqlite":93 try:94 subprocess.call("sqlite3 -version", shell=True)95 except subprocess.CalledProcessError as e:96 no_sql_die.__func__(db_type)97 else:98 no_sql_die.__func__(db_type)99 ...

Full Screen

Full Screen

setup.py

Source:setup.py Github

copy

Full Screen

1import setuptools2with open("README.md", "r", encoding="utf-8") as fh:3 long_description = fh.read()4 5try:6 # if have requirements.txt file inside the folder7 with open("requirements.txt", "r", encoding="utf-8") as f:8 modules_needed = [i.strip() for i in fh.readlines()] 9except:10 modules_needed = []11setuptools.setup(12 name="exceltopostgresql", # Replace with your own username13 version="0.0.9",14 author="Xiangyong Luo",15 author_email="rochemay@163.com",16 description="This package help to convert your excel files (xlsx,xls,csv) to Postgresql database.",17 long_description=long_description,18 long_description_content_type="text/markdown",19 url="https://github.com/Xiangyongluo/exceltopostgresql",20 21 22 classifiers=[23 "Programming Language :: Python :: 3",24 "License :: OSI Approved :: MIT License",25 "Operating System :: OS Independent",26 ],27 python_requires='>=3.6',28 29 install_requires=modules_needed,30 packages=setuptools.find_packages(),31 include_package_data=True,32 package_data= {'':['*.txt','*.xls','*.xlsx','*.csv'],33 "test_data":['*.txt']}...

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