How to use update_jar_manifest method in localstack

Best Python code snippet using localstack_python

install.py

Source: install.py Github

copy

Full Screen

...423 patch_url = f"{SFN_PATCH_URL_PREFIX}/​{patch_class}"424 add_file_to_jar(patch_class, patch_url, target_jar=INSTALL_PATH_STEPFUNCTIONS_JAR)425 # add additional classpath entries to JAR manifest file426 classpath = " ".join([os.path.basename(jar) for jar in JAR_URLS])427 update_jar_manifest(428 "StepFunctionsLocal.jar",429 INSTALL_DIR_STEPFUNCTIONS,430 "Class-Path: . ",431 f"Class-Path: {classpath} . ",432 )433 update_jar_manifest(434 "StepFunctionsLocal.jar",435 INSTALL_DIR_STEPFUNCTIONS,436 re.compile("Main-Class: .+"),437 "Main-Class: cloud.localstack.StepFunctionsStarter",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)479 run_safe(lambda: run(["zip", "-u", "DynamoDBLocal.jar", "log4j2.xml"], cwd=INSTALL_DIR_DDB))480 # download agent JAR481 if not os.path.exists(DDB_AGENT_JAR_PATH):482 download(DDB_AGENT_JAR_URL, DDB_AGENT_JAR_PATH)483 if not os.path.exists(JAVASSIST_JAR_PATH):484 download(JAVASSIST_JAR_URL, JAVASSIST_JAR_PATH)485 # patch/​update libraries with known CVEs486 upgrade_jar_file(487 ddb_local_lib_dir,488 "jackson-databind-*.jar",489 "com/​fasterxml/​jackson/​core/​jackson-databind:2.13.3",490 )491 upgrade_jar_file(ddb_local_lib_dir, "slf4j-ext-*.jar", "org/​slf4j/​slf4j-ext:1.8.0-beta4")492 # ensure that javassist.jar is in the manifest classpath493 update_jar_manifest(494 "DynamoDBLocal.jar", INSTALL_DIR_DDB, "Class-Path:", "Class-Path: javassist.jar"495 )496 update_jar_manifest(497 "DynamoDBLocal.jar", INSTALL_DIR_DDB, "databind-2.12.3.jar", "databind-2.13.3.jar"498 )499def update_jar_manifest(500 jar_file_name: str, parent_dir: str, search: Union[str, re.Pattern], replace: str501):502 manifest_file_path = "META-INF/​MANIFEST.MF"503 run(["unzip", "-o", jar_file_name, manifest_file_path], cwd=parent_dir)504 manifest_file = os.path.join(parent_dir, manifest_file_path)505 manifest = load_file(manifest_file)506 if replace not in manifest:507 if isinstance(search, re.Pattern):508 manifest = search.sub(replace, manifest, 1)509 else:510 manifest = manifest.replace(search, replace, 1)511 save_file(manifest_file, manifest)512 run(["zip", jar_file_name, manifest_file_path], cwd=parent_dir)513 os.remove(manifest_file)...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Quick Guide To Drupal Testing

Dries Buytaert, a graduate student at the University of Antwerp, came up with the idea of developing something similar to a chat room. Moreover, he modified the conventional chat rooms into a website where his friends could post their queries and reply through comments. However, for this project, he thought of creating a temporary archive of posts.

How To Create Custom Menus with CSS Select

When it comes to UI components, there are two versatile methods that we can use to build it for your website: either we can use prebuilt components from a well-known library or framework, or we can develop our UI components from scratch.

QA&#8217;s and Unit Testing &#8211; Can QA Create Effective Unit Tests

Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.

Testing Modern Applications With Playwright ????

Web applications continue to evolve at an unbelievable pace, and the architecture surrounding web apps get more complicated all of the time. With the growth in complexity of the web application and the development process, web application testing also needs to keep pace with the ever-changing demands.

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