How to use file_exists_not_empty method in localstack

Best Python code snippet using localstack_python

install.py

Source:install.py Github

copy

Full Screen

...438 )439 # download additional jar libs440 for jar_url in JAR_URLS:441 target = os.path.join(INSTALL_DIR_STEPFUNCTIONS, os.path.basename(jar_url))442 if not file_exists_not_empty(target):443 download(jar_url, target)444 # download aws-sdk lambda handler445 target = os.path.join(INSTALL_DIR_STEPFUNCTIONS, "localstack-internal-awssdk", "awssdk.zip")446 if not file_exists_not_empty(target):447 download(SFN_AWS_SDK_LAMBDA_ZIP_FILE, target)448def add_file_to_jar(class_file, class_url, target_jar, base_dir=None):449 base_dir = base_dir or os.path.dirname(target_jar)450 patch_class_file = os.path.join(base_dir, class_file)451 if not os.path.exists(patch_class_file):452 download(class_url, patch_class_file)453 run(["zip", target_jar, class_file], cwd=base_dir)454def install_dynamodb_local():455 if not os.path.exists(INSTALL_PATH_DDB_JAR):456 log_install_msg("DynamoDB")457 # download and extract archive458 tmp_archive = os.path.join(tempfile.gettempdir(), "localstack.ddb.zip")459 download_and_extract_with_retry(DYNAMODB_JAR_URL, tmp_archive, INSTALL_DIR_DDB)460 # download additional libs for Mac M1 (for local dev mode)461 ddb_local_lib_dir = os.path.join(INSTALL_DIR_DDB, "DynamoDBLocal_lib")462 if is_mac_os() and get_arch() == "arm64":463 target_path = os.path.join(ddb_local_lib_dir, "libsqlite4java-osx-aarch64.dylib")464 if not file_exists_not_empty(target_path):465 download(LIBSQLITE_AARCH64_URL, target_path)466 # fix logging configuration for DynamoDBLocal467 log4j2_config = """<Configuration status="WARN">468 <Appenders>469 <Console name="Console" target="SYSTEM_OUT">470 <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>471 </Console>472 </Appenders>473 <Loggers>474 <Root level="WARN"><AppenderRef ref="Console"/></Root>475 </Loggers>476 </Configuration>"""477 log4j2_file = os.path.join(INSTALL_DIR_DDB, "log4j2.xml")478 save_file(log4j2_file, log4j2_config)...

Full Screen

Full Screen

partition_dt.py

Source:partition_dt.py Github

copy

Full Screen

...27def save_remove_file(filename):28 noext_filename, ext = filename[:-4], filename[-4:]29 orig_filename = noext_filename + '_orig' + ext30 # check file exists31 if not file_exists_not_empty(filename=filename):32 log.warning("Cannot remove, file not found '{f}'".format(f=filename))33 return34 # check backup of file exists35 if file_exists_not_empty(filename=orig_filename):36 log.debug("Removing file '{f}'".format(f=filename))37 os.remove(filename)38 else:39 log.debug("Renaming file to '{f}'".format(f=orig_filename))40 os.rename(filename, orig_filename)41 return42def remove_previous_run(datadir, siteid, sitedir, prod_to_compare, perc_to_compare, years_to_compare, python=False):43 if python:44 for prod in prod_to_compare:45 for perc in perc_to_compare:46 for year in years_to_compare:47 py_filename = os.path.join(datadir, sitedir, DT_OUTPUT_DIR, FILENAME_TEMPLATE.format(prod=prod, perc=perc, y=year, s=siteid, e='csv', add=EXTRA_FILENAME))48 if python:49 save_remove_file(py_filename)...

Full Screen

Full Screen

partition_nt.py

Source:partition_nt.py Github

copy

Full Screen

...29def save_remove_file(filename):30 noext_filename, ext = os.path.splitext(filename)31 orig_filename = noext_filename + '_orig' + ext32 # check file exists33 if not file_exists_not_empty(filename=filename):34 log.warning("Cannot remove, file not found '{f}'".format(f=filename))35 return36 # check backup of file exists37 if file_exists_not_empty(filename=orig_filename):38 log.debug("Removing file '{f}'".format(f=filename))39 os.remove(filename)40 else:41 log.debug("Renaming file to '{f}'".format(f=orig_filename))42 os.rename(filename, orig_filename)43 return44def remove_previous_run(datadir, siteid, sitedir, prod_to_compare, perc_to_compare, years_to_compare, python=False):45 if python:46 for prod in prod_to_compare:47 for perc in perc_to_compare:48 for year in years_to_compare:49 py_filename = os.path.join(datadir, sitedir, NT_OUTPUT_DIR, FILENAME_TEMPLATE.format(prod=prod, perc=perc, y=year, s=siteid, e='csv', add=EXTRA_FILENAME))50 if python:51 save_remove_file(py_filename)...

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