def get_script_path(bin_dir, script_name): ''' Return the path to a testing runtime script, generating one if it does not yet exist ''' # Late import from tests.support.runtests import RUNTIME_VARS extra_code = textwrap.dedent(r''' # During test runs, squash the msgpack deprecation warnings import salt import warnings warnings.filterwarnings( 'ignore', r'encoding is deprecated, Use raw=False instead\.', DeprecationWarning, ) ''') if not os.path.isdir(bin_dir): os.makedirs(bin_dir) cli_script_name = 'cli_{}.py'.format(script_name.replace('-', '_')) script_path = os.path.join(bin_dir, cli_script_name) if not os.path.isfile(script_path): cli_scripts.generate_script(bin_dir=bin_dir, script_name=script_name, executable=sys.executable, code_dir=RUNTIME_VARS.CODE_DIR, extra_code=extra_code, inject_sitecustomize=True) log.info('Returning script path %r', script_path) return script_path
def cli_bin_dir(tempdir, request, python_executable_path, cli_master_script_name, cli_minion_script_name, cli_salt_script_name, cli_call_script_name, cli_key_script_name, cli_run_script_name, cli_ssh_script_name, cli_syndic_script_name, cli_proxy_script_name): ''' Return the path to the CLI script directory to use ''' tmp_cli_scripts_dir = tempdir.join('cli-scrips-bin') # Make sure we re-write the scripts every time we start the tests shutil.rmtree(tmp_cli_scripts_dir.strpath, ignore_errors=True) tmp_cli_scripts_dir.ensure(dir=True) cli_bin_dir_path = tmp_cli_scripts_dir.strpath # Now that we have the CLI directory created, lets generate the required CLI scripts to run salt's test suite for script_name in (cli_master_script_name, cli_minion_script_name, cli_call_script_name, cli_key_script_name, cli_run_script_name, cli_salt_script_name, cli_ssh_script_name, cli_syndic_script_name, cli_proxy_script_name): original_script_name = os.path.splitext(script_name)[0].split( 'cli_')[-1].replace('_', '-') cli_scripts.generate_script(bin_dir=cli_bin_dir_path, script_name=original_script_name, executable=sys.executable, code_dir=CODE_DIR, inject_sitecustomize=MAYBE_RUN_COVERAGE) # Return the CLI bin dir value return cli_bin_dir_path
def get_script_path(bin_dir, script_name): ''' Return the path to a testing runtime script, generating one if it does not yet exist ''' # Late import from tests.support.runtests import RUNTIME_VARS if not os.path.isdir(bin_dir): os.makedirs(bin_dir) cli_script_name = 'cli_{}.py'.format(script_name.replace('-', '_')) script_path = os.path.join(bin_dir, cli_script_name) if 'COVERAGE_PROCESS_START' in os.environ or 'COVERAGE_FILE' in os.environ: inject_coverage = inject_sitecustomize = True else: inject_coverage = inject_sitecustomize = False if not os.path.isfile(script_path): cli_scripts.generate_script(bin_dir=bin_dir, script_name=script_name, executable=sys.executable, code_dir=RUNTIME_VARS.CODE_DIR, inject_coverage=inject_coverage, inject_sitecustomize=inject_sitecustomize) log.info('Returning script path %r', script_path) return script_path
def get_script_path(bin_dir, script_name): """ Return the path to a testing runtime script, generating one if it does not yet exist """ # Late import from tests.support.runtests import RUNTIME_VARS if not os.path.isdir(bin_dir): os.makedirs(bin_dir) cli_script_name = "cli_{}.py".format(script_name.replace("-", "_")) script_path = os.path.join(bin_dir, cli_script_name) if not os.path.isfile(script_path): cli_scripts.generate_script( bin_dir=bin_dir, script_name=script_name, executable=sys.executable, code_dir=RUNTIME_VARS.CODE_DIR, inject_sitecustomize="COVERAGE_PROCESS_START" in os.environ, ) log.info("Returning script path %r", script_path) return script_path