How to use get_dir_of_file method in localstack

Best Python code snippet using localstack_python

kclipy_helper.py

Source:kclipy_helper.py Github

copy

Full Screen

...5from amazon_kclpy import kcl6from six import iteritems7from localstack.utils.aws import aws_stack8from localstack.utils.common import save_file9def get_dir_of_file(f):10 return os.path.dirname(os.path.abspath(f))11def get_kcl_dir():12 return get_dir_of_file(kcl.__file__)13def get_kcl_jar_path():14 jars = ":".join(glob(os.path.join(get_kcl_dir(), "jars", "*jar")))15 return jars16def get_kcl_classpath(properties=None, paths=[]):17 """18 Generates a classpath that includes the location of the kcl jars, the19 properties file and the optional paths.20 :type properties: str21 :param properties: Path to properties file.22 :type paths: list23 :param paths: List of strings. The paths that will be prepended to the classpath.24 :rtype: str25 :return: A java class path that will allow your properties to be26 found and the MultiLangDaemon and its deps and27 any custom paths you provided.28 """29 # First make all the user provided paths absolute30 paths = [os.path.abspath(p) for p in paths]31 # We add our paths after the user provided paths because this permits users to32 # potentially inject stuff before our paths (otherwise our stuff would always33 # take precedence).34 paths.append(get_kcl_jar_path())35 if properties:36 # Add the dir that the props file is in37 dir_of_file = get_dir_of_file(properties)38 paths.append(dir_of_file)39 # add path of custom java code40 dir_name = os.path.dirname(os.path.realpath(__file__))41 paths.insert(42 0,43 os.path.realpath(44 os.path.join(45 dir_name,46 "..",47 "..",48 "infra",49 "amazon-kinesis-client",50 "aws-java-sdk-sts.jar",51 )52 ),53 )54 paths.insert(0, os.path.realpath(os.path.join(dir_name, "java")))55 return ":".join([p for p in paths if p != ""])56def get_kcl_app_command(java, multi_lang_daemon_class, properties, paths=[]):57 """58 Generates a command to run the MultiLangDaemon.59 :type java: str60 :param java: Path to java61 :type multi_lang_daemon_class: str62 :param multi_lang_daemon_class: Name of multi language daemon class, e.g.63 com.amazonaws.services.kinesis.multilang.MultiLangDaemon64 :type properties: str65 :param properties: Optional properties file to be included in the classpath.66 :type paths: list67 :param paths: List of strings. Additional paths to prepend to the classpath.68 :rtype: str69 :return: A command that will run the MultiLangDaemon with your70 properties and custom paths and java.71 """72 logging_config = os.path.join(get_dir_of_file(__file__), "java", "logging.properties")73 sys_props = '"-Djava.util.logging.config.file=%s"' % logging_config74 return "{java} -cp {cp} {sys_props} {daemon} {props}".format(75 java=java,76 cp=get_kcl_classpath(properties, paths),77 daemon=multi_lang_daemon_class,78 # Just need the basename because the path is added to the classpath79 props=os.path.basename(properties),80 sys_props=sys_props,81 )82def create_config_file(83 config_file,84 executableName,85 streamName,86 applicationName,...

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