def install_environment( repo_cmd_runner, version='default', additional_dependencies=None, ): assert repo_cmd_runner.exists('setup.py') directory = helpers.environment_dir(ENVIRONMENT_DIR, version) # Install a virtualenv with clean_path_on_failure(repo_cmd_runner.path(directory)): venv_cmd = [ sys.executable, '-m', 'virtualenv', '{{prefix}}{0}'.format(directory) ] if version != 'default': venv_cmd.extend(['-p', norm_version(version)]) repo_cmd_runner.run(venv_cmd) with in_env(repo_cmd_runner, version) as env: env.run("cd '{prefix}' && pip install .") if additional_dependencies: env.run( "cd '{prefix}' && pip install " + ' '.join( shell_escape(dep) for dep in additional_dependencies ) )
def install_environment( repo_cmd_runner, version='default', additional_dependencies=None, ): assert repo_cmd_runner.exists('setup.py') directory = helpers.environment_dir(ENVIRONMENT_DIR, version) # Install a virtualenv with clean_path_on_failure(repo_cmd_runner.path(directory)): venv_cmd = [ sys.executable, '-m', 'virtualenv', '{{prefix}}{0}'.format(directory) ] if version != 'default': venv_cmd.extend(['-p', norm_version(version)]) repo_cmd_runner.run(venv_cmd) with in_env(repo_cmd_runner, version) as env: env.run("cd '{prefix}' && pip install .", encoding=None) if additional_dependencies: env.run( "cd '{prefix}' && pip install " + ' '.join( shell_escape(dep) for dep in additional_dependencies ), encoding=None, )
def install_environment( repo_cmd_runner, version='default', additional_dependencies=None, ): assert repo_cmd_runner.exists('package.json') directory = helpers.environment_dir(ENVIRONMENT_DIR, version) env_dir = repo_cmd_runner.path(directory) with clean_path_on_failure(env_dir): cmd = [ sys.executable, '-m', 'nodeenv', '--prebuilt', '{{prefix}}{0}'.format(directory), ] if version != 'default': cmd.extend(['-n', version]) repo_cmd_runner.run(cmd) with in_env(repo_cmd_runner, version) as node_env: node_env.run("cd '{prefix}' && npm install -g") if additional_dependencies: node_env.run("cd '{prefix}' && npm install -g " + ' '.join( shell_escape(dep) for dep in additional_dependencies))
def install_environment( repo_cmd_runner, version='default', additional_dependencies=None, ): assert repo_cmd_runner.exists('package.json') directory = helpers.environment_dir(ENVIRONMENT_DIR, version) env_dir = repo_cmd_runner.path(directory) with clean_path_on_failure(env_dir): cmd = [ sys.executable, '-m', 'nodeenv', '--prebuilt', '{{prefix}}{0}'.format(directory), ] if version != 'default': cmd.extend(['-n', version]) repo_cmd_runner.run(cmd) with in_env(repo_cmd_runner, version) as node_env: node_env.run("cd '{prefix}' && npm install -g") if additional_dependencies: node_env.run( "cd '{prefix}' && npm install -g " + ' '.join( shell_escape(dep) for dep in additional_dependencies ) )
def install_environment( repo_cmd_runner, version='default', additional_dependencies=None, ): directory = helpers.environment_dir(ENVIRONMENT_DIR, version) with clean_path_on_failure(repo_cmd_runner.path(directory)): # TODO: this currently will fail if there's no version specified and # there's no system ruby installed. Is this ok? _install_rbenv(repo_cmd_runner, version=version) with in_env(repo_cmd_runner, version) as ruby_env: if version != 'default': _install_ruby(ruby_env, version) ruby_env.run( 'cd {prefix} && gem build *.gemspec && ' 'gem install --no-ri --no-rdoc *.gem', encoding=None, ) if additional_dependencies: ruby_env.run( 'cd {prefix} && gem install --no-ri --no-rdoc ' + ' '.join( shell_escape(dep) for dep in additional_dependencies ), encoding=None, )
def run_hook(repo_cmd_runner, hook, file_args): # For PCRE the entry is the regular expression to match return repo_cmd_runner.run( [ 'xargs', '-0', 'sh', '-c', # Grep usually returns 0 for matches, and nonzero for non-matches # so we flip it here. '! grep -H -n -P {0} $@'.format(shell_escape(hook['entry'])), '--', ], stdin=file_args_to_stdin(file_args), retcode=None, encoding=None, )
def run_hook(repo_cmd_runner, hook, file_args): # For PCRE the entry is the regular expression to match return repo_cmd_runner.run( [ 'xargs', '-0', 'sh', '-c', # Grep usually returns 0 for matches, and nonzero for non-matches # so we flip it here. '! grep -H -n -P {0} $@'.format(shell_escape(hook['entry'])), '--', ], stdin=file_args_to_stdin(file_args), retcode=None, )
def run_hook(repo_cmd_runner, hook, file_args): # For PCRE the entry is the regular expression to match return repo_cmd_runner.run( [ "xargs", "-0", "sh", "-c", # Grep usually returns 0 for matches, and nonzero for non-matches # so we flip it here. "! grep -H -n -P {0} $@".format(shell_escape(hook["entry"])), "--", ], stdin=file_args_to_stdin(file_args), retcode=None, )
def run_hook(repo_cmd_runner, hook, file_args): grep_command = 'grep -H -n -P' if platform == 'darwin': # pragma: no cover (osx) grep_command = 'ggrep -H -n -P' # For PCRE the entry is the regular expression to match return repo_cmd_runner.run( [ 'xargs', '-0', 'sh', '-c', # Grep usually returns 0 for matches, and nonzero for non-matches # so we flip it here. '! {0} {1} $@'.format(grep_command, shell_escape(hook['entry'])), '--', ], stdin=file_args_to_stdin(file_args), retcode=None, encoding=None, )
def install_environment( repo_cmd_runner, version='default', additional_dependencies=None, ): directory = helpers.environment_dir(ENVIRONMENT_DIR, version) with clean_path_on_failure(repo_cmd_runner.path(directory)): # TODO: this currently will fail if there's no version specified and # there's no system ruby installed. Is this ok? _install_rbenv(repo_cmd_runner, version=version) with in_env(repo_cmd_runner, version) as ruby_env: if version != 'default': _install_ruby(ruby_env, version) ruby_env.run( 'cd {prefix} && gem build *.gemspec && ' 'gem install --no-ri --no-rdoc *.gem', ) if additional_dependencies: ruby_env.run('cd {prefix} && gem install --no-ri --no-rdoc ' + ' '.join( shell_escape(dep) for dep in additional_dependencies))
def run_hook(repo_cmd_runner, hook, file_args): grep_command = "grep -H -n -P" if platform == "darwin": # pragma: no cover (osx) grep_command = "ggrep -H -n -P" # For PCRE the entry is the regular expression to match return repo_cmd_runner.run( [ "xargs", "-0", "sh", "-c", # Grep usually returns 0 for matches, and nonzero for non-matches # so we flip it here. "! {0} {1} {2} $@".format(grep_command, " ".join(hook["args"]), shell_escape(hook["entry"])), "--", ], stdin=file_args_to_stdin(file_args), retcode=None, encoding=None, )
def run_hook(repo_cmd_runner, hook, file_args): grep_command = 'grep -H -n -P' if platform == 'darwin': # pragma: no cover (osx) grep_command = 'ggrep -H -n -P' # For PCRE the entry is the regular expression to match return repo_cmd_runner.run( [ 'xargs', '-0', 'sh', '-c', # Grep usually returns 0 for matches, and nonzero for non-matches # so we flip it here. '! {0} {1} {2} $@'.format(grep_command, ' '.join(hook['args']), shell_escape(hook['entry'])), '--', ], stdin=file_args_to_stdin(file_args), retcode=None, encoding=None, )
def test_shell_escape(input_str, expected): assert shell_escape(input_str) == expected