Best Python code snippet using localstack_python
amazon_kclpy_helper.py
Source:amazon_kclpy_helper.py
...65 # Add the dir that the props file is in66 dir_of_file = get_dir_of_file(properties)67 paths.append(dir_of_file)68 return ":".join([p for p in paths if p != ''])69def get_kcl_app_command(args, multi_lang_daemon_class, properties, log_configuration, paths=[]):70 '''71 Generates a command to run the MultiLangDaemon.72 :type java: str73 :param java: Path to java74 :type multi_lang_daemon_class: str75 :param multi_lang_daemon_class: Name of multi language daemon class e.g. com.amazonaws.services.kinesis.multilang.MultiLangDaemon76 :type properties: str77 :param properties: Optional properties file to be included in the classpath.78 :type paths: list79 :param paths: List of strings. Additional paths to prepend to the classpath.80 :rtype: str81 :return: A command that will run the MultiLangDaemon with your properties and custom paths and java.82 '''83 return "{java} -cp {cp} {daemon} {props} {log_config}".format(java=args.java,84 cp = get_kcl_classpath(args.properties, paths),85 daemon = multi_lang_daemon_class,86 # Just need the basename because the path is added to the classpath87 props = properties,88 log_config = log_configuration)89if __name__ == '__main__':90 parser = argparse.ArgumentParser("A script for generating a command to run an Amazon KCLpy app")91 parser.add_argument("--print_classpath", dest="print_classpath", action="store_true",92 default=False,93 help="Print a java class path.\noptional arguments: --path")94 parser.add_argument("--print_command", dest="print_command", action="store_true",95 default=False,96 help="Print a command for running an Amazon KCLpy app.\nrequired "97 + "args: --java --properties\noptional args: --classpath")98 parser.add_argument("-j", "--java", dest="java",99 help="The path to the java executable e.g. <some root>/jdk/bin/java",100 metavar="PATH_TO_JAVA")101 parser.add_argument("-p", "--properties", "--props", "--prop", dest="properties",102 help="The path to a properties file (relative to where you are running this script)",103 metavar="PATH_TO_PROPERTIES")104 parser.add_argument("--sample", "--sample-props", "--use-sample-properties", dest="use_sample_props",105 help="This will use the sample.properties file included in this package as the properties file.",106 action="store_true", default=False)107 parser.add_argument("-c", "--classpath", "--path", dest="paths", action="append", default=[],108 help="Additional path to add to java class path. May be specified any number of times",109 metavar="PATH")110 parser.add_argument("-l", "--log-configuration", dest="log_configuration",111 help="This will use the logback.xml which will be used by the KCL to log.",112 metavar="PATH_TO_LOG_CONFIGURATION")113 args = parser.parse_args()114 # Possibly replace the properties with the sample. Useful if they just want to run the sample app.115 if args.use_sample_props:116 if args.properties:117 sys.stderr.write('Replacing provided properties with sample properties due to arg --sample\n')118 args.properties = os.path.join(get_dir_of_file(samples.__file__), 'sample.properties')119 # Print what the asked for120 if args.print_classpath:121 print(get_kcl_classpath(args.properties, args.paths))122 elif args.print_command:123 if args.java and args.properties:124 multi_lang_daemon_class = 'software.amazon.kinesis.multilang.MultiLangDaemon'125 properties_argument = "--properties-file {props}".format(props = args.properties)126 log_argument = ''127 if args.log_configuration is not None:128 log_argument = "--log-configuration {log}".format(log = args.log_configuration)129 print(get_kcl_app_command(args, multi_lang_daemon_class, properties_argument, log_argument, paths=args.paths))130 else:131 sys.stderr.write("Must provide arguments: --java and --properties\n")132 parser.print_usage()133 else:...
kcl_utils.py
Source:kcl_utils.py
...53 # Add the dir that the props file is in54 dir_of_file = get_dir_of_file(properties)55 paths.append(dir_of_file)56 return ":".join([p for p in paths if p != ''])57def get_kcl_app_command(java, multi_lang_daemon_class, properties, paths=None):58 """59 Generates a command to run the MultiLangDaemon.60 :param java: Path to java61 :type java: str62 :param multi_lang_daemon_class: Name of multi language daemon class e.g. com.amazonaws.services.kinesis.multilang.MultiLangDaemon63 :type multi_lang_daemon_class: str64 :param properties: Optional properties file to be included in the classpath.65 :type properties: str66 :param paths: List of strings. Additional paths to prepend to the classpath.67 :type paths: list68 :return: A command that will run the MultiLangDaemon with your properties and custom paths and java.69 :rtype: list70 """71 command = java72 args = [73 java,74 "-cp",75 get_kcl_classpath(properties, paths),76 multi_lang_daemon_class,77 properties78 ]79 return command, args80def run_kcl_process(java_path, config_file_path):81 """82 Runs the KCL process according to the given parameters (does not return).83 :param java_path: The path of the JAVA binary file84 :type java_path: str85 :param config_file_path: The path of the KCL properties file86 :type config_file_path: str87 """88 command, args = get_kcl_app_command(89 java_path,90 MULTI_LANG_DAEMON_CLASS,91 config_file_path)...
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!!