Skip to content

Commit

Permalink
Merge pull request #892 from ljhljh235/release-0.9.8
Browse files Browse the repository at this point in the history
Fix for non-interactive scenario
  • Loading branch information
Jianghao Lu committed Sep 11, 2015
2 parents 13e78b5 + c66a1e5 commit a07c992
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/Common/Commands.Common/AzurePSCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,28 +254,27 @@ protected void SaveDataCollectionProfile()

protected bool CheckIfInteractive()
{
if (this.Host == null || this.Host.UI == null || this.Host.UI.RawUI == null)
{
return false;
}

bool interactive = true;
try
if (this.Host == null || this.Host.UI == null || this.Host.UI.RawUI == null)
{
var test = this.Host.UI.RawUI.KeyAvailable;
interactive = false;
}
catch (HostException ex)
else
{
if (ex.Message.StartsWith("A command that prompts the user failed"))
try
{
interactive = false;
var test = this.Host.UI.RawUI.KeyAvailable;
}
else
catch
{
throw ex;
interactive = false;
}
}

if (!interactive && !_dataCollectionProfile.EnableAzureDataCollection.HasValue)
{
_dataCollectionProfile.EnableAzureDataCollection = false;
}
return interactive;
}

Expand All @@ -288,7 +287,7 @@ protected void PromptForDataCollectionProfileIfNotExists()
// Initialize it from the environment variable or profile file.
InitializeDataCollectionProfile();

if (CheckIfInteractive() && !_dataCollectionProfile.EnableAzureDataCollection.HasValue)
if (!_dataCollectionProfile.EnableAzureDataCollection.HasValue && CheckIfInteractive())
{
WriteWarning(Resources.DataCollectionPrompt);

Expand Down

0 comments on commit a07c992

Please sign in to comment.