<commit_before>Param(
    [switch]$AppVeyor,
    [switch]$Verbose
)

if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }

if($AppVeyor -eq $True)
{
    $ProjectRoot = "c:\projects\spectre"
    Set-Location $ProjectRoot
}
else
{
    $ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
    $ProjectRoot = Split-Path -Parent $ScriptPath
    #$ProjectRoot = Get-Location | Select-String -Pattern spectre -SimpleMatch
}

function VerbosePrint($text)
{
    if($Verbose -eq $True)
    {
        Write-Host $text
    }
}

VerbosePrint -text "Using $($ProjectRoot) as project root."

Try
{
    VerbosePrint -text "Adding Spectre application pool."
    Import-Module "WebAdministration"
    New-Item 'IIS:\Sites\Default Web Site\spectre_api' -physicalPath "$($ProjectRoot)\src\Spectre" -type Application | Out-Null
    New-Item 'IIS:\AppPools\Spectre' | Out-Null
    Set-ItemProperty 'IIS:\AppPools\Spectre' -Name managedRuntimeVersion -Value 'v4.0'
    Set-ItemProperty 'IIS:\AppPools\Spectre' -Name managedPipelineMode -Value ([int] [Microsoft.Web.Administration.ManagedPipelineMode]::Integrated)
    VerbosePrint -text "Adding $($ProjectRoot)\src\Spectre as an application."
    Set-ItemProperty 'IIS:\Sites\Default Web Site\spectre_api' -Name applicationPool Spectre
    #New-Item 'IIS:\Sites\Default Web Site\spectre_api' -physicalPath "$($ProjectRoot)\src\Spectre" -type VirtualDirectory
    
    $Acl = Get-Acl "$($ProjectRoot)\src\Spectre"
    $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "FullControl", "Allow")
    $Acl.SetAccessRule($Ar)
    Set-Acl "$($ProjectRoot)\src\Spectre" $Acl
    
    Write-Host "Added API binding to IIS." -foregroundcolor green
}
Catch
{
    Write-Host $_.Exception.Message -foregroundcolor red -backgroundcolor black
    Write-Host "Failed to bind page to IIS." -foregroundcolor red
}

Try
{
    New-Item c:\spectre_data -type Directory | Out-Null
    $Acl = Get-Acl c:\spectre_data
    $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "FullControl", "Allow")
    $Acl.SetAccessRule($Ar)
    Set-Acl c:\spectre_data $Acl
    Copy-Item "$($ProjectRoot)\test_files\*" c:\spectre_data | Out-Null

    Write-Host "Test data copied to default data directory." -foregroundcolor green
}<commit_msg>Revert "Adapt IIS binding page for Win7"<commit_after>Param(
    [switch]$AppVeyor,
    [switch]$Verbose
)

if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }

if($AppVeyor -eq $True)
{
    $ProjectRoot = "c:\projects\spectre"
    Set-Location $ProjectRoot
}
else
{
    $ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
    $ProjectRoot = Split-Path -Parent $ScriptPath
    #$ProjectRoot = Get-Location | Select-String -Pattern spectre -SimpleMatch
}

function VerbosePrint($text)
{
    if($Verbose -eq $True)
    {
        Write-Host $text
    }
}

VerbosePrint -text "Using $($ProjectRoot) as project root."

Try
{
    VerbosePrint -text "Adding Spectre application pool."
    Import-Module "WebAdministration"
    New-Item 'IIS:\Sites\Default Web Site\spectre_api' -physicalPath "$($ProjectRoot)\src\Spectre" -type Application | Out-Null
    New-Item 'IIS:\AppPools\Spectre' | Out-Null
    Set-ItemProperty 'IIS:\AppPools\Spectre' -Name managedRuntimeVersion -Value 'v4.0'
    Set-ItemProperty 'IIS:\AppPools\Spectre' -Name managedPipelineMode -Value 'Integrated'
    VerbosePrint -text "Adding $($ProjectRoot)\src\Spectre as an application."
    Set-ItemProperty 'IIS:\Sites\Default Web Site\spectre_api' -Name applicationPool Spectre
    #New-Item 'IIS:\Sites\Default Web Site\spectre_api' -physicalPath "$($ProjectRoot)\src\Spectre" -type VirtualDirectory
    
    $Acl = Get-Acl "$($ProjectRoot)\src\Spectre"
    $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "FullControl", "Allow")
    $Acl.SetAccessRule($Ar)
    Set-Acl "$($ProjectRoot)\src\Spectre" $Acl
    
    Write-Host "Added API binding to IIS." -foregroundcolor green
}
Catch
{
    Write-Host $_.Exception.Message -foregroundcolor red -backgroundcolor black
    Write-Host "Failed to bind page to IIS." -foregroundcolor red
}

Try
{
    New-Item c:\spectre_data -type Directory | Out-Null
    $Acl = Get-Acl c:\spectre_data
    $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "FullControl", "Allow")
    $Acl.SetAccessRule($Ar)
    Set-Acl c:\spectre_data $Acl
    Copy-Item "$($ProjectRoot)\test_files\*" c:\spectre_data | Out-Null

    Write-Host "Test data copied to default data directory." -foregroundcolor green
}
{'fraction_non_alphanumeric': 0.13114427860696518, 'fraction_numerical': 0.0009950248756218905, 'mean_word_length': 4.186790505675955, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3094113', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1624, 'n_words': 357}