public void JoinSameCodec(TestFiles.TypeEnum type)
        {
            var output = Path.Combine(this.tempOutputDir, "concated_video" + TestFiles.Exentsions[type]);

            var slides = new[]
            {
                TestFiles.SlideEnum.Nr1Red,
                TestFiles.SlideEnum.Nr2Blue,
                TestFiles.SlideEnum.Nr3Green,
            };

            var files = slides.Select(slide => TestFiles.GetTestVideo(slide, type));

            foreach (var file in files)
            {
                Assert.That(File.Exists(file), "input test must exists");
            }

            var script = this.preparer.ConcateClips(output, files.ToArray());

            Console.Out.WriteLine("Script");
            Console.Out.WriteLine(script);

            var process = PowershellExecutor.Execute(script);

            Assert.That(File.Exists(output), "output file exists");

            Assert.That(Helper.DetermineSlide(TimeSpan.FromSeconds(2.5), output), Is.EqualTo(TestFiles.SlideEnum.Nr1Red));
            Assert.That(Helper.DetermineSlide(TimeSpan.FromSeconds(5 + 2.5), output), Is.EqualTo(TestFiles.SlideEnum.Nr2Blue));
            Assert.That(Helper.DetermineSlide(TimeSpan.FromSeconds(10 + 2.5), output), Is.EqualTo(TestFiles.SlideEnum.Nr3Green));
        }
Example #2
0
        public static TestFiles.SlideEnum DetermineSlide(TimeSpan position, string file)
        {
            var directory = TestContext.CurrentContext.TestDirectory;
            var preparer  = new PowershellPreparer($@"{directory}\..\..\FFmpegStatic\ffmpeg.exe");

            string image   = Path.GetTempFileName() + ".png";
            var    script  = preparer.CaptureImage(file, image, position);
            var    process = PowershellExecutor.Execute(script);

            var color = GetTestImageColor(image);

            if (color.R > 200 && color.G < 10 && color.B < 10)
            {
                return(TestFiles.SlideEnum.Nr1Red);
            }
            if (color.R < 10 && color.G > 200 && color.B < 10)
            {
                return(TestFiles.SlideEnum.Nr3Green);
            }
            if (color.R < 10 && color.G < 10 && color.B > 200)
            {
                return(TestFiles.SlideEnum.Nr2Blue);
            }

            throw new Exception();
        }
        private void Compile()
        {
            if (Directory.Exists(InstallDir))
            {
                Directory.Delete(InstallDir, true);
            }
            Directory.CreateDirectory(InstallDir);

            /* TODO
             * pct_space_used = pct_disk_used(@compile_base)
             * if pct_space_used >= @max_disk_usage_pct
             * raise Bosh::Agent::MessageHandlerError,
             * "Compile Package Failure. Greater than #{@max_disk_usage_pct}% " +
             * "is used (#{pct_space_used}%."
             * end
             */

            using (DirectoryScope.Create(CompileDir))
            {
                if (File.Exists(PackagingScriptName))
                {
                    log.Info(Resources.CompilePackage_CompilingPackage_Fmt, packageName, packageVersion);

                    // NB: has to have .ps1 extension
                    File.Copy(PackagingScriptName, PackagingScriptNamePS1);
                    string stdout, stderr;
                    int    exitcode;
                    using (var exe = new PowershellExecutor(PackagingScriptNamePS1))
                    {
                        exe.AddEnvironmentVariable("BoshCompileTarget", CompileDir);
                        exe.AddEnvironmentVariable("BoshInstallTarget", InstallDir);
                        exe.StartAndWait();
                        stdout   = exe.STDOUT;
                        stderr   = exe.STDERR;
                        exitcode = exe.ExitCode;
                    }
                    if (exitcode != 0)
                    {
                        throw new MessageHandlerException(
                                  String.Format(Resources.CompilePackage_CompilePackageFailure_Fmt, exitcode),
                                  String.Join(" / ", stdout, stderr));
                    }
                    log.Info(stdout);
                }
            }
        }
Example #4
0
        public void Test_Running_Powershell_Script_Two()
        {
            string scriptContents = @"Write-Host 'ONE'
Write-Host 'TWO'
Write-Host 'THREE'
Write-Host ""Install Target: $env:BoshInstallTarget""";
            string script         = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".ps1");

            File.WriteAllText(script, scriptContents);
            var p = new PowershellExecutor(script);

            p.AddEnvironmentVariable("BoshInstallTarget", Path.GetTempPath());
            p.StartAndWait();
            Console.WriteLine("STDOUT:");
            Console.Write(p.STDOUT);
            Console.WriteLine("STDERR:");
            Console.Write(p.STDERR);
        }
Example #5
0
        private PowerShellExecutionResults run_external_powershell(ChocolateyConfiguration configuration, string chocoPowerShellScript)
        {
            var result = new PowerShellExecutionResults();

            result.ExitCode = PowershellExecutor.execute(
                wrap_script_with_module(chocoPowerShellScript, configuration),
                _fileSystem,
                configuration.CommandExecutionTimeoutSeconds,
                (s, e) =>
            {
                if (string.IsNullOrWhiteSpace(e.Data))
                {
                    return;
                }
                //inspect for different streams
                if (e.Data.StartsWith("DEBUG:"))
                {
                    this.Log().Debug(() => " " + e.Data.escape_curly_braces());
                }
                else if (e.Data.StartsWith("WARNING:"))
                {
                    this.Log().Warn(() => " " + e.Data.escape_curly_braces());
                }
                else if (e.Data.StartsWith("VERBOSE:"))
                {
                    this.Log().Info(ChocolateyLoggers.Verbose, () => " " + e.Data.escape_curly_braces());
                }
                else
                {
                    this.Log().Info(() => " " + e.Data.escape_curly_braces());
                }
            },
                (s, e) =>
            {
                if (string.IsNullOrWhiteSpace(e.Data))
                {
                    return;
                }
                result.StandardErrorWritten = true;
                this.Log().Error(() => " " + e.Data.escape_curly_braces());
            });

            return(result);
        }
        public void CaptureImage(byte r, byte g, byte b, int ms)
        {
            var file = Path.Combine(this.tempOutputDir, "picture.png");

            TimeSpan pos    = TimeSpan.FromMilliseconds(ms);
            var      script = this.preparer.CaptureImage(TestFiles.Slides, file, pos);

            Console.Out.WriteLine("Script");
            Console.Out.WriteLine(script);

            var process = PowershellExecutor.Execute(script);

            Assert.That(File.Exists(file), "output file exists");

            Color pixelColor = Helper.GetTestImageColor(file);

            Assert.That(pixelColor.A, Is.EqualTo(255).Within(ColorTolerance).Percent);
            Assert.That(pixelColor.R, Is.EqualTo(r).Within(ColorTolerance).Percent);
            Assert.That(pixelColor.G, Is.EqualTo(g).Within(ColorTolerance).Percent);
            Assert.That(pixelColor.B, Is.EqualTo(b).Within(ColorTolerance).Percent);
        }
Example #7
0
        public bool run_action(ChocolateyConfiguration configuration, PackageResult packageResult, CommandNameType command)
        {
            var installerRun = false;

            var file = "chocolateyInstall.ps1";

            switch (command)
            {
            case CommandNameType.uninstall:
                file = "chocolateyUninstall.ps1";
                break;
            }

            var packageDirectory = packageResult.InstallLocation;

            if (!_fileSystem.directory_exists(packageDirectory))
            {
                packageResult.Messages.Add(new ResultMessage(ResultType.Error, "Package install not found:'{0}'".format_with(packageDirectory)));
                return(installerRun);
            }

            var powershellScript = _fileSystem.get_files(packageDirectory, file, SearchOption.AllDirectories);

            if (powershellScript.Count != 0)
            {
                var chocoPowerShellScript = powershellScript.FirstOrDefault();

                var failure = false;

                var package = packageResult.Package;
                Environment.SetEnvironmentVariable("CHOCOLATEY_VERSION", configuration.Information.ChocolateyVersion);
                Environment.SetEnvironmentVariable("OS_TYPE", configuration.Information.PlatformType.get_description_or_value());
                Environment.SetEnvironmentVariable("OS_VERSION", configuration.Information.PlatformVersion.to_string());
                // experimental until we know if this value returns correctly based on the OS and not the current process.
                Environment.SetEnvironmentVariable("OS_IS64BIT", configuration.Information.Is64Bit ? "true":"false");
                Environment.SetEnvironmentVariable("chocolateyPackageName", package.Id);
                Environment.SetEnvironmentVariable("chocolateyPackageVersion", package.Version.to_string());
                Environment.SetEnvironmentVariable("chocolateyPackageFolder", ApplicationParameters.PackagesLocation);
                Environment.SetEnvironmentVariable("installerArguments", configuration.InstallArguments);
                Environment.SetEnvironmentVariable("chocolateyPackageParameters", configuration.PackageParameters);
                if (configuration.ForceX86)
                {
                    Environment.SetEnvironmentVariable("chocolateyForceX86", "true");
                }
                if (configuration.OverrideArguments)
                {
                    Environment.SetEnvironmentVariable("chocolateyInstallOverride", "true");
                }

                if (!string.IsNullOrWhiteSpace(configuration.CacheLocation))
                {
                    //refactor - this is possibly temporary until we get all things running Posh into here
                    Environment.SetEnvironmentVariable("TEMP", configuration.CacheLocation);
                }

                //verify how not silent is passed
                //if (configuration.NotSilent)
                //{
                //    Environment.SetEnvironmentVariable("installerArguments", "  ");
                //    Environment.SetEnvironmentVariable("chocolateyInstallOverride", "true");
                //}
                if (configuration.Debug)
                {
                    Environment.SetEnvironmentVariable("ChocolateyEnvironmentDebug", "true");
                }
                if (configuration.Verbose)
                {
                    Environment.SetEnvironmentVariable("ChocolateyEnvironmentVerbose", "true");
                }
                //todo:if (configuration.NoOutput)
                //{
                //    Environment.SetEnvironmentVariable("ChocolateyEnvironmentQuiet","true");
                //}

                this.Log().Debug(ChocolateyLoggers.Important, "Contents of '{0}':".format_with(chocoPowerShellScript));
                string chocoPowerShellScriptContents = _fileSystem.read_file(chocoPowerShellScript).escape_curly_braces();
                this.Log().Debug(chocoPowerShellScriptContents);

                bool shouldRun = !configuration.PromptForConfirmation;

                if (!shouldRun)
                {
                    this.Log().Info(ChocolateyLoggers.Important, () => " Found '{0}':".format_with(_fileSystem.get_file_name(chocoPowerShellScript)));
                    this.Log().Info(() => "{0}{1}{0}".format_with(Environment.NewLine, chocoPowerShellScriptContents));
                    var selection = InteractivePrompt.prompt_for_confirmation(" Do you want to run the script?", new[] { "yes", "no", "skip" }, "yes", requireAnswer: true);
                    if (selection.is_equal_to("yes"))
                    {
                        shouldRun = true;
                    }
                    if (selection.is_equal_to("no"))
                    {
                        Environment.ExitCode = 1;
                        packageResult.Messages.Add(new ResultMessage(ResultType.Error, "User cancelled powershell portion of installation for '{0}'.{1} Use skip to install without run.".format_with(powershellScript.FirstOrDefault(), Environment.NewLine)));
                    }
                }

                if (shouldRun)
                {
                    installerRun = true;
                    var exitCode = PowershellExecutor.execute(
                        wrap_command_with_module(chocoPowerShellScript),
                        _fileSystem,
                        configuration.CommandExecutionTimeoutSeconds,
                        (s, e) =>
                    {
                        if (string.IsNullOrWhiteSpace(e.Data))
                        {
                            return;
                        }
                        //inspect for different streams
                        if (e.Data.StartsWith("DEBUG:"))
                        {
                            this.Log().Debug(() => " " + e.Data);
                        }
                        else if (e.Data.StartsWith("WARNING:"))
                        {
                            this.Log().Warn(() => " " + e.Data);
                        }
                        else if (e.Data.StartsWith("VERBOSE:"))
                        {
                            this.Log().Info(ChocolateyLoggers.Verbose, () => " " + e.Data);
                        }
                        else
                        {
                            this.Log().Info(() => " " + e.Data);
                        }
                    },
                        (s, e) =>
                    {
                        if (string.IsNullOrWhiteSpace(e.Data))
                        {
                            return;
                        }
                        failure = true;
                        this.Log().Error(() => " " + e.Data);
                    });

                    if (failure)
                    {
                        Environment.ExitCode = exitCode;
                        packageResult.Messages.Add(new ResultMessage(ResultType.Error, "Error while running '{0}'.{1} See log for details.".format_with(powershellScript.FirstOrDefault(), Environment.NewLine)));
                    }
                    packageResult.Messages.Add(new ResultMessage(ResultType.Note, "Ran '{0}'".format_with(powershellScript)));
                }
            }

            return(installerRun);
        }
Example #8
0
        public bool run_action(ChocolateyConfiguration configuration, PackageResult packageResult, CommandNameType command)
        {
            var installerRun = false;

            var file = "chocolateyInstall.ps1";

            switch (command)
            {
            case CommandNameType.uninstall:
                file = "chocolateyUninstall.ps1";
                break;
            }

            var packageDirectory = packageResult.InstallLocation;

            if (packageDirectory.is_equal_to(ApplicationParameters.InstallLocation) || packageDirectory.is_equal_to(ApplicationParameters.PackagesLocation))
            {
                packageResult.Messages.Add(
                    new ResultMessage(
                        ResultType.Error,
                        "Install location is not specific enough, cannot run PowerShell script:{0} Erroneous install location captured as '{1}'".format_with(Environment.NewLine, packageResult.InstallLocation)
                        )
                    );

                return(false);
            }

            if (!_fileSystem.directory_exists(packageDirectory))
            {
                packageResult.Messages.Add(new ResultMessage(ResultType.Error, "Package install not found:'{0}'".format_with(packageDirectory)));
                return(installerRun);
            }

            var powershellScript = _fileSystem.get_files(packageDirectory, file, SearchOption.AllDirectories);

            if (powershellScript.Count() != 0)
            {
                var chocoPowerShellScript = powershellScript.FirstOrDefault();

                var failure = false;

                //todo: this is here for any possible compatibility issues. Should be reviewed and removed.
                ConfigurationBuilder.set_environment_variables(configuration);

                var package = packageResult.Package;
                Environment.SetEnvironmentVariable("chocolateyPackageName", package.Id);
                Environment.SetEnvironmentVariable("packageName", package.Id);
                Environment.SetEnvironmentVariable("chocolateyPackageVersion", package.Version.to_string());
                Environment.SetEnvironmentVariable("packageVersion", package.Version.to_string());
                Environment.SetEnvironmentVariable("chocolateyPackageFolder", packageDirectory);
                Environment.SetEnvironmentVariable("packageFolder", packageDirectory);
                Environment.SetEnvironmentVariable("installArguments", configuration.InstallArguments);
                Environment.SetEnvironmentVariable("installerArguments", configuration.InstallArguments);
                Environment.SetEnvironmentVariable("chocolateyInstallArguments", configuration.InstallArguments);
                Environment.SetEnvironmentVariable("packageParameters", configuration.PackageParameters);
                Environment.SetEnvironmentVariable("chocolateyPackageParameters", configuration.PackageParameters);
                if (configuration.ForceX86)
                {
                    Environment.SetEnvironmentVariable("chocolateyForceX86", "true");
                }
                if (configuration.OverrideArguments)
                {
                    Environment.SetEnvironmentVariable("chocolateyInstallOverride", "true");
                }

                if (configuration.NotSilent)
                {
                    Environment.SetEnvironmentVariable("chocolateyInstallOverride", "true");
                }

                //todo:if (configuration.NoOutput)
                //{
                //    Environment.SetEnvironmentVariable("ChocolateyEnvironmentQuiet","true");
                //}

                this.Log().Debug(ChocolateyLoggers.Important, "Contents of '{0}':".format_with(chocoPowerShellScript));
                string chocoPowerShellScriptContents = _fileSystem.read_file(chocoPowerShellScript);
                this.Log().Debug(chocoPowerShellScriptContents.escape_curly_braces());

                bool shouldRun = !configuration.PromptForConfirmation;

                if (!shouldRun)
                {
                    this.Log().Info(ChocolateyLoggers.Important, () => "The package {0} wants to run '{1}'.".format_with(package.Id, _fileSystem.get_file_name(chocoPowerShellScript)));
                    this.Log().Info(ChocolateyLoggers.Important, () => "Note: If you don't run this script, the installation will fail.");
                    this.Log().Info(ChocolateyLoggers.Important, () => @"Note: To confirm automatically next time, use '-y' or consider setting 
 'allowGlobalConfirmation'. Run 'choco feature -h' for more details.");

                    var selection = InteractivePrompt.prompt_for_confirmation(@"Do you want to run the script?", new[] { "yes", "no", "print" }, defaultChoice: null, requireAnswer: true);

                    if (selection.is_equal_to("print"))
                    {
                        this.Log().Info(ChocolateyLoggers.Important, "------ BEGIN SCRIPT ------");
                        this.Log().Info(() => "{0}{1}{0}".format_with(Environment.NewLine, chocoPowerShellScriptContents.escape_curly_braces()));
                        this.Log().Info(ChocolateyLoggers.Important, "------- END SCRIPT -------");
                        selection = InteractivePrompt.prompt_for_confirmation(@"Do you want to run this script?", new[] { "yes", "no" }, defaultChoice: null, requireAnswer: true);
                    }

                    if (selection.is_equal_to("yes"))
                    {
                        shouldRun = true;
                    }
                    if (selection.is_equal_to("no"))
                    {
                        Environment.ExitCode = 1;
                        packageResult.Messages.Add(new ResultMessage(ResultType.Error, "User cancelled powershell portion of installation for '{0}'.{1} Specify -n to skip automated script actions.".format_with(powershellScript.FirstOrDefault(), Environment.NewLine)));
                    }
                }

                if (shouldRun)
                {
                    installerRun = true;
                    var exitCode = PowershellExecutor.execute(
                        wrap_script_with_module(chocoPowerShellScript, configuration),
                        _fileSystem,
                        configuration.CommandExecutionTimeoutSeconds,
                        (s, e) =>
                    {
                        if (string.IsNullOrWhiteSpace(e.Data))
                        {
                            return;
                        }
                        //inspect for different streams
                        if (e.Data.StartsWith("DEBUG:"))
                        {
                            this.Log().Debug(() => " " + e.Data);
                        }
                        else if (e.Data.StartsWith("WARNING:"))
                        {
                            this.Log().Warn(() => " " + e.Data);
                        }
                        else if (e.Data.StartsWith("VERBOSE:"))
                        {
                            this.Log().Info(ChocolateyLoggers.Verbose, () => " " + e.Data);
                        }
                        else
                        {
                            this.Log().Info(() => " " + e.Data);
                        }
                    },
                        (s, e) =>
                    {
                        if (string.IsNullOrWhiteSpace(e.Data))
                        {
                            return;
                        }
                        if (e.Data.is_equal_to(OPERATION_COMPLETED_SUCCESSFULLY) || e.Data.is_equal_to(INITIALIZE_DEFAULT_DRIVES))
                        {
                            this.Log().Info(() => " " + e.Data);
                        }
                        else
                        {
                            failure = true;
                            this.Log().Error(() => " " + e.Data);
                        }
                    });

                    if (exitCode != 0)
                    {
                        failure = true;
                    }

                    if (failure)
                    {
                        Environment.ExitCode = exitCode;
                        packageResult.Messages.Add(new ResultMessage(ResultType.Error, "Error while running '{0}'.{1} See log for details.".format_with(powershellScript.FirstOrDefault(), Environment.NewLine)));
                    }
                    packageResult.Messages.Add(new ResultMessage(ResultType.Note, "Ran '{0}'".format_with(chocoPowerShellScript)));
                }
            }

            return(installerRun);
        }
Example #9
0
 public override void Because()
 {
     result = PowershellExecutor.get_powershell_location(FileSystem.Object);
 }
Example #10
0
 public void should_throw_an_error()
 {
     Assert.Throws <FileNotFoundException>(() => PowershellExecutor.get_powershell_location(FileSystem.Object));
 }
Example #11
0
        public bool run_action(ChocolateyConfiguration configuration, PackageResult packageResult, CommandNameType command)
        {
            var installerRun = false;

            var file = "chocolateyInstall.ps1";

            switch (command)
            {
            case CommandNameType.uninstall:
                file = "chocolateyUninstall.ps1";
                break;
            }

            var packageDirectory = packageResult.InstallLocation;

            if (packageDirectory.is_equal_to(ApplicationParameters.InstallLocation) || packageDirectory.is_equal_to(ApplicationParameters.PackagesLocation))
            {
                packageResult.Messages.Add(
                    new ResultMessage(
                        ResultType.Error,
                        "Install location is not specific enough, cannot run PowerShell script:{0} Erroneous install location captured as '{1}'".format_with(Environment.NewLine, packageResult.InstallLocation)
                        )
                    );

                return(false);
            }

            if (!_fileSystem.directory_exists(packageDirectory))
            {
                packageResult.Messages.Add(new ResultMessage(ResultType.Error, "Package install not found:'{0}'".format_with(packageDirectory)));
                return(installerRun);
            }

            var powershellScript = _fileSystem.get_files(packageDirectory, file, SearchOption.AllDirectories);

            if (powershellScript.Count() != 0)
            {
                var chocoPowerShellScript = powershellScript.FirstOrDefault();

                var failure = false;

                var package = packageResult.Package;
                Environment.SetEnvironmentVariable(ApplicationParameters.ChocolateyInstallEnvironmentVariableName, ApplicationParameters.InstallLocation);
                Environment.SetEnvironmentVariable("CHOCOLATEY_VERSION", configuration.Information.ChocolateyVersion);
                Environment.SetEnvironmentVariable("CHOCOLATEY_VERSION_PRODUCT", configuration.Information.ChocolateyProductVersion);
                Environment.SetEnvironmentVariable("OS_PLATFORM", configuration.Information.PlatformType.get_description_or_value());
                Environment.SetEnvironmentVariable("OS_VERSION", configuration.Information.PlatformVersion.to_string());
                Environment.SetEnvironmentVariable("OS_NAME", configuration.Information.PlatformName.to_string());
                // experimental until we know if this value returns correctly based on the OS and not the current process.
                Environment.SetEnvironmentVariable("OS_IS64BIT", configuration.Information.Is64Bit ? "true" : "false");
                Environment.SetEnvironmentVariable("IS_ADMIN", configuration.Information.IsUserAdministrator ? "true" : "false");
                Environment.SetEnvironmentVariable("IS_PROCESSELEVATED", configuration.Information.IsProcessElevated ? "true" : "false");
                Environment.SetEnvironmentVariable("chocolateyPackageName", package.Id);
                Environment.SetEnvironmentVariable("packageName", package.Id);
                Environment.SetEnvironmentVariable("chocolateyPackageVersion", package.Version.to_string());
                Environment.SetEnvironmentVariable("packageVersion", package.Version.to_string());
                Environment.SetEnvironmentVariable("chocolateyPackageFolder", packageDirectory);
                Environment.SetEnvironmentVariable("packageFolder", packageDirectory);
                Environment.SetEnvironmentVariable("installArguments", configuration.InstallArguments);
                Environment.SetEnvironmentVariable("installerArguments", configuration.InstallArguments);
                Environment.SetEnvironmentVariable("chocolateyInstallArguments", configuration.InstallArguments);
                Environment.SetEnvironmentVariable("packageParameters", configuration.PackageParameters);
                Environment.SetEnvironmentVariable("chocolateyPackageParameters", configuration.PackageParameters);
                if (configuration.ForceX86)
                {
                    Environment.SetEnvironmentVariable("chocolateyForceX86", "true");
                }
                if (configuration.OverrideArguments)
                {
                    Environment.SetEnvironmentVariable("chocolateyInstallOverride", "true");
                }

                Environment.SetEnvironmentVariable("TEMP", configuration.CacheLocation);

                if (configuration.NotSilent)
                {
                    Environment.SetEnvironmentVariable("chocolateyInstallOverride", "true");
                }
                if (configuration.Debug)
                {
                    Environment.SetEnvironmentVariable("ChocolateyEnvironmentDebug", "true");
                }
                if (configuration.Verbose)
                {
                    Environment.SetEnvironmentVariable("ChocolateyEnvironmentVerbose", "true");
                }
                //todo:if (configuration.NoOutput)
                //{
                //    Environment.SetEnvironmentVariable("ChocolateyEnvironmentQuiet","true");
                //}

                this.Log().Debug(ChocolateyLoggers.Important, "Contents of '{0}':".format_with(chocoPowerShellScript));
                string chocoPowerShellScriptContents = _fileSystem.read_file(chocoPowerShellScript);
                this.Log().Debug(chocoPowerShellScriptContents.escape_curly_braces());

                bool shouldRun = !configuration.PromptForConfirmation;

                if (!shouldRun)
                {
                    this.Log().Info(ChocolateyLoggers.Important, () => "The package {0} wants to run '{1}'.".format_with(package.Id, _fileSystem.get_file_name(chocoPowerShellScript)));
                    this.Log().Info(ChocolateyLoggers.Important, () => "Note: If you don't run this script, the installation will fail.");
                    this.Log().Info(ChocolateyLoggers.Important, () => @"Note: To confirm automatically next time, use '-y' or consider setting 
 'allowGlobalConfirmation'. Run 'choco feature -h' for more details.");

                    var selection = InteractivePrompt.prompt_for_confirmation(@"Do you want to run the script?", new[] { "yes", "no", "print" }, defaultChoice: null, requireAnswer: true);

                    if (selection.is_equal_to("print"))
                    {
                        this.Log().Info(ChocolateyLoggers.Important, "------ BEGIN SCRIPT ------");
                        this.Log().Info(() => "{0}{1}{0}".format_with(Environment.NewLine, chocoPowerShellScriptContents.escape_curly_braces()));
                        this.Log().Info(ChocolateyLoggers.Important, "------- END SCRIPT -------");
                        selection = InteractivePrompt.prompt_for_confirmation(@"Do you want to run this script?", new[] { "yes", "no" }, defaultChoice: null, requireAnswer: true);
                    }

                    if (selection.is_equal_to("yes"))
                    {
                        shouldRun = true;
                    }
                    if (selection.is_equal_to("no"))
                    {
                        Environment.ExitCode = 1;
                        packageResult.Messages.Add(new ResultMessage(ResultType.Error, "User cancelled powershell portion of installation for '{0}'.{1} Use skip to install without run.".format_with(powershellScript.FirstOrDefault(), Environment.NewLine)));
                    }
                }

                if (shouldRun)
                {
                    installerRun = true;
                    var exitCode = PowershellExecutor.execute(
                        wrap_script_with_module(chocoPowerShellScript, configuration),
                        _fileSystem,
                        configuration.CommandExecutionTimeoutSeconds,
                        (s, e) =>
                    {
                        if (string.IsNullOrWhiteSpace(e.Data))
                        {
                            return;
                        }
                        //inspect for different streams
                        if (e.Data.StartsWith("DEBUG:"))
                        {
                            this.Log().Debug(() => " " + e.Data);
                        }
                        else if (e.Data.StartsWith("WARNING:"))
                        {
                            this.Log().Warn(() => " " + e.Data);
                        }
                        else if (e.Data.StartsWith("VERBOSE:"))
                        {
                            this.Log().Info(ChocolateyLoggers.Verbose, () => " " + e.Data);
                        }
                        else
                        {
                            this.Log().Info(() => " " + e.Data);
                        }
                    },
                        (s, e) =>
                    {
                        if (string.IsNullOrWhiteSpace(e.Data))
                        {
                            return;
                        }
                        failure = true;
                        this.Log().Error(() => " " + e.Data);
                    });

                    if (failure)
                    {
                        Environment.ExitCode = exitCode;
                        packageResult.Messages.Add(new ResultMessage(ResultType.Error, "Error while running '{0}'.{1} See log for details.".format_with(powershellScript.FirstOrDefault(), Environment.NewLine)));
                    }
                    packageResult.Messages.Add(new ResultMessage(ResultType.Note, "Ran '{0}'".format_with(chocoPowerShellScript)));
                }
            }

            return(installerRun);
        }