Internet radio browser GUI for music/video streams from various directory services.

βŒˆβŒ‹ βŽ‡ branch:  streamtuner2


Check-in [a36496ebbc]

Overview
Comment:New Windows install/uninstall versions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a36496ebbccbff9922ed191439d08e28ba9ac29d
User & Date: mario on 2016-12-09 18:38:09
Other Links: manifest | tags
Context
2016-12-10
12:19
More typos fixed, updated html check-in: 693ec3ad97 user: mario tags: trunk
2016-12-09
18:38
New Windows install/uninstall versions. check-in: a36496ebbc user: mario tags: trunk
18:37
Support for %% escaping. check-in: 5994cb76a9 user: mario tags: trunk
Changes

Modified dev/install_python_gtk.ps1 from [d96ab4ebf0] to [1029927d2c].

23
24
25
26
27
28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

58
59
60
61
62
63
64
65
66
67
68

69
70
71
72
73
74
75
76
77
78

79
80
81
82
83
84
85
86
87
88

89
90
91
92
93
94
95
96
97
98

99
100
101






102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

119
120
121
122
123

124
125
126
127
128













129
130
131
132
133

134
135
136
137
138

139
140
141
142
143

144
145
146
147
148

149
150
151

152
153



154
155
156

157
158
159
160
161
162
163
  [string]$AboutLink = "http://freshcode.club/projects/streamtuner2",
  [string]$VERSION = "2.2.0"
)            

#-- paths
$UsrFolder = $MyInvocation.MyCommand.Path -replace ("([\\/][^\\/]+){4}$","")
$UninstallPath = "$UsrFolder\share\streamtuner2\dev\uninstall.cmd"

$ModifyPath = $MyInvocation.MyCommand.Path -replace ("[.]ps1$", ".bat")
$IconPath = "$UsrFolder\share\pixmaps\streamtuner2.ico"

#-- system configuration
$ErrorActionPreference = "SilentlyContinue"  # ignore all path/registry lookup errors
$OutputEncoding = [System.Text.Encoding]::UTF8
$regPathCU = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
$regPathLM = "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall" #64-Bit machine
if(!(Test-Path $regPathLM)) {                                                        #32-Bit machine
    $regPathLM = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
    $ProgramFiles = "%ProgramFiles%"
}
New-Variable -Name STREAMRIPPER -Option AllScope -Value "$ProgramFiles\Streamripper"


#-- what and how to install
#   each row is a list of (title, url, cmd, msi args, regkey, pathcheck, is_optional, prelookup)
$tasks = @(
  @(
    "Python 2.7.12",                                                  # title
    "https://www.python.org/ftp/python/2.7.12/python-2.7.12.msi",     # url
    "",                                                               # custom cmd
    'TARGETDIR="{PYTHON}" /qb-!',                                     # msi args
    "$regPathLM\{9DA28CE5-0AA5-429E-86D8-686ED898C665}",              # registry
    "{PYTHON}\pythonw.exe",                                           # installed check
    "",                                                               # is optional?
    ''                                                                # check-prerequisite→$_found?
  ),

  @(
    "PyGtk 2.24.2",
    "http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/pygtk-all-in-one-2.24.2.win32-py2.7.msi",
    "",
    'TARGETDIR="{PYTHON}" ADDLOCAL=ALL REMOVE=PythonExtensionModulePyGtkSourceview2,PythonExtensionModulePyGoocanvas,PythonExtensionModulePyRsvg,DevelopmentTools /qb-!',
    "$regPathLM\{09F82967-D26B-48AC-830E-33191EC177C8}",
#    "$regPathLM\{09F82967-D26B-48AC-830E-33191EC177C8}",
    "{PYTHON}\Lib\site-packages\gtk-2.0\pygtk-2.24.0-py2.7.egg-info",
    "",
    ''
  ),

  @(
    "Python requests",
    "requests", # no download url, pip handles this
    "easy_install",
    "",
    "",
    "{PYTHON}\Lib\site-packages\requests-2*py2.7.egg",
    "",
    ''
  ),

  @(
    "LXML 2.3",
    "https://pypi.python.org/packages/d4/fa/e4e0c7a8fe971b10e275cdc20efd16f553a225e700c400c11da25276e4f4/lxml-2.3-py2.7-win32.egg",
    "easy_install",
    "",
    "",
    "{PYTHON}\Lib\site-packages\lxml-2.3-py2.7-win32.egg",
    "",
    ''
  ),

  @(
    "PyQuery 1.2.1",
    "https://pypi.python.org/packages/62/71/8ac1f5c0251e51714d20e4b102710d5eee1683c916616129552b0a025ba5/pyquery-1.2.17-py2.py3-none-any.whl",
    "pip",
    "--disable-pip-version-check",
    "",
    "{PYTHON}\Lib\site-packages\pyquery-1.2.17.dist-info",
    "",
    ''
  ),

  @(
    "PIL 1.1.7",
    "http://effbot.org/downloads/PIL-1.1.7.win32-py2.7.exe",






    "",
    "",
    "$regPathCU\PIL-py2.7",
    "{PYTHON}\Lib\site-packages\PIL",
    "",
    ''
  ),
  @(
    "Streamripper 1.64.6",
    "https://netcologne.dl.sourceforge.net/project/streamripper/streamripper%20%28current%29/1.64.6/streamripper-windows-installer-1.64.6.exe",
    "",
    "/S  /D={STREAMRIPPER}"  #NSIS does not use double quotes in /D parm,
    "$regPathLM\Streamripper",
    "{STREAMRIPPER}\streamripper.exe",
    '($true)',     # ← could use '((Ask "Install streamripper too [y/N]") -match N)' instead
    '($optionalInstall -AND ($_found = (Get-ITPV "Streamripper")) -AND ($STREAMRIPPER = $_found) -OR ((!$optionalInstall) -AND $STREAMRIPPER=""))'  # look up path in Check-Prerequisites
  ),

  @(
    "Uninstall script",
    "",
    'Create-Uninstallscript'
  ),

  @(
    "Desktop shortcut",
    "",
    'Make-Shortcut -dir $Home\Desktop -name Streamtuner2.lnk -target $PYTHON\pythonw.exe -arg $UsrFolder\bin\streamtuner2'
  ),













  @(
    "Startmenu shortcut",
    "",
    'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name Streamtuner2.lnk -target $PYTHON\pythonw.exe -arg $UsrFolder\bin\streamtuner2'
  ),

  @(
    "Startmenu help.chm",
    "",
    'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name Help.lnk -target $UsrFolder\share\streamtuner2\help\help.chm'
  ),

  @(
    "Startmenu uninstall",
    "",
    'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name Uninstall.lnk -target $UninstallPath'
  ),

  @(
    "Startmenu Internet",
    "",
    'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name "Streamtuner2 on the Web.lnk" -target "$AboutLink"'
  ),

  @(
    "Startmenu Reconfigure",
    "",

    'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name "Reconfigure.lnk" -target $ModifyPath'
  ),



  @(
    "FINISHED"
  )

)



#-- startup messages
function Display-Logo {
    Write-Host -b DarkBlue @"







>












|

<
|
<

|
|
|
|
|
|
|
|
|
<
>
|
|
|
|
|
|
<
|
<
<
<
>
|
|
|
|
<
<
|
<
<
<
>
|
|
|
|
<
<
|
<
<
<
>
|
|
|
|
|
<
|
<
<
<
>
|
|
|
>
>
>
>
>
>
|
<
<
<
<
<
<
<
<
<
<
|
|
|
|
|
<
>
|
|
<
|
<
>
|
|
<
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
<
|
<
>
|
|
<
|
<
>
|
|
<
|
<
>
|
|
<
|
<
>
|
|
<
>
|
<
>
>
>
|
|
<
>







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

45

46
47
48
49
50
51
52
53
54
55

56
57
58
59
60
61
62

63



64
65
66
67
68


69



70
71
72
73
74


75



76
77
78
79
80
81

82



83
84
85
86
87
88
89
90
91
92
93










94
95
96
97
98

99
100
101

102

103
104
105

106

107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

122

123
124
125

126

127
128
129

130

131
132
133

134

135
136
137

138
139

140
141
142
143
144

145
146
147
148
149
150
151
152
  [string]$AboutLink = "http://freshcode.club/projects/streamtuner2",
  [string]$VERSION = "2.2.0"
)            

#-- paths
$UsrFolder = $MyInvocation.MyCommand.Path -replace ("([\\/][^\\/]+){4}$","")
$UninstallPath = "$UsrFolder\share\streamtuner2\dev\uninstall.cmd"
$ResetPrefsPath = $UninstallPath -replace ("uninstall", "resetprefs")
$ModifyPath = $MyInvocation.MyCommand.Path -replace ("[.]ps1$", ".bat")
$IconPath = "$UsrFolder\share\pixmaps\streamtuner2.ico"

#-- system configuration
$ErrorActionPreference = "SilentlyContinue"  # ignore all path/registry lookup errors
$OutputEncoding = [System.Text.Encoding]::UTF8
$regPathCU = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
$regPathLM = "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall" #64-Bit machine
if(!(Test-Path $regPathLM)) {                                                        #32-Bit machine
    $regPathLM = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
    $ProgramFiles = "%ProgramFiles%"
}
New-Variable -Name STREAMRIPPER -Option AllScope -Value "$ProgramFiles\Streamripper" #can be changed in Check-Prerequisites


#-- what and how to install (hash list as used by Run-Task and Check-Prerequisites)

$tasks = @(
  @{
    title  = "Python 2.7.12"
    url    = "https://www.python.org/ftp/python/2.7.12/python-2.7.12.msi"
    cmd    = ""
    args   = 'TARGETDIR="{PYTHON}" /qb-!'
    regkey = "$regPathLM\{9DA28CE5-0AA5-429E-86D8-686ED898C665}"
    testpth= "{PYTHON}\pythonw.exe"
    is_opt = ''
    prescn = ''

  },
  @{
    title  = "PyGtk 2.24.2"
    url    = "http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/pygtk-all-in-one-2.24.2.win32-py2.7.msi"
    cmd    = ""
    args   = 'TARGETDIR="{PYTHON}" ADDLOCAL=ALL REMOVE=PythonExtensionModulePyGtkSourceview2,PythonExtensionModulePyGoocanvas,PythonExtensionModulePyRsvg,DevelopmentTools /qb-!'
    regkey = "$regPathLM\{09F82967-D26B-48AC-830E-33191EC177C8}"

    testpth= "{PYTHON}\Lib\site-packages\gtk-2.0\pygtk-2.24.0-py2.7.egg-info"



  },
  @{
    title  = "Python requests"
    url    = "requests" # no download url, pip handles this
    cmd    = "easy_install"


    testpth= "{PYTHON}\Lib\site-packages\requests-2*py2.7.egg"



  },
  @{
    title  = "LXML 2.3"
    url    = "https://pypi.python.org/packages/d4/fa/e4e0c7a8fe971b10e275cdc20efd16f553a225e700c400c11da25276e4f4/lxml-2.3-py2.7-win32.egg"
    cmd    = "easy_install"


    testpth= "{PYTHON}\Lib\site-packages\lxml-2.3-py2.7-win32.egg"



  },
  @{
    title  = "PyQuery 1.2.1"
    url    = "https://pypi.python.org/packages/62/71/8ac1f5c0251e51714d20e4b102710d5eee1683c916616129552b0a025ba5/pyquery-1.2.17-py2.py3-none-any.whl"
    cmd    = "pip"
    args   = "--disable-pip-version-check"

    testpth= "{PYTHON}\Lib\site-packages\pyquery-1.2.17.dist-info"



  },
  @{
    title  = "PIL 1.1.7"
    url    = "http://effbot.org/downloads/PIL-1.1.7.win32-py2.7.exe"
    regkey = "$regPathCU\PIL-py2.7"
    testpth= "{PYTHON}\Lib\site-packages\PIL"
  },
  @{
    title  = "Streamripper 1.64.6"
    url    = "https://netcologne.dl.sourceforge.net/project/streamripper/streamripper%20%28current%29/1.64.6/streamripper-windows-installer-1.64.6.exe"
    cmd    = ""










    args   = "/S  /D={STREAMRIPPER}"  #NSIS does not use double quotes in /D parm
    regkey = "$regPathLM\Streamripper"
    testpth= "{STREAMRIPPER}\streamripper.exe"
    is_opt = '($optionalInstall)'     # ← could use '((Ask "Install streamripper too [y/N]") -match N)' instead
    prescn = 'if ($optionalInstall) {if ($_found = (Get-ITPV "Streamripper")) {$STREAMRIPPER = $_found}} else {$STREAMRIPPER=""; continue;}'

  },
  @{
    title  = "Uninstall script"

    cmd    = 'Create-Uninstallscript'

  },
  @{
    title  = "Desktop shortcut"

    cmd    = 'Make-Shortcut -dir $Home\Desktop -name Streamtuner2.lnk -target $PYTHON\pythonw.exe -arg $UsrFolder\bin\streamtuner2'

  },
  @{
    title  = "Startmenu shortcut"
    cmd    = 'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name Streamtuner2.lnk -target $PYTHON\pythonw.exe -arg $UsrFolder\bin\streamtuner2'
  },
  @{
    title  = "Startmenu help.chm"
    cmd    = 'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name Help.lnk -target $UsrFolder\share\streamtuner2\help\help.chm'
  },
  @{
    title  = "Startmenu uninstall"
    cmd    = 'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name Uninstall.lnk -target $UninstallPath'
  },
  @{
    title  = "Startmenu Internet"

    cmd    = 'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name "Streamtuner2 on the Web.lnk" -target "$AboutLink"'

  },
  @{
    title  = "Startmenu Reconfigure"

    cmd    = 'Make-Shortcut -dir "$StartMenu\Streamtuner2\Advanced" -name "Reconfigure.lnk" -target $ModifyPath'

  },
  @{
    title  = "Startmenu RunDebug"

    cmd    = 'Make-Shortcut -dir "$StartMenu\Streamtuner2\Advanced" -name "Run in debug mode.lnk" -target $PYTHON\python.exe -arg "$UsrFolder\bin\streamtuner2" -parm "-D"'

  },
  @{
    title  = "Startmenu RunConsole"

    cmd    = 'Make-Shortcut -dir "$StartMenu\Streamtuner2\Advanced" -name "Run with console.lnk" -target $PYTHON\python.exe -arg "$UsrFolder\bin\streamtuner2"'

  },
  @{
    title  = "Startmenu ResetPrefs"

    cmd    = 'Make-Shortcut @task'
       dir = "$StartMenu\Streamtuner2\Advanced"

      name = "Reset preferences.lnk"
    target = "$ResetPrefsPath"
  },
  @{
    title  = "FINISHED"

  }
)



#-- startup messages
function Display-Logo {
    Write-Host -b DarkBlue @"
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
        $host.UI.RawUI.set_bufferSize($MyBuffer)
        $host.UI.RawUI.set_windowSize($MyWindow)
    }
}

#-- create Desktop/Startmenu shortcuts
function Make-Shortcut {
    [CmdletBinding()]
    param($dir, $name, $target, $arg=$false)
    if (!(Test-Path -Path $dir)) {
        New-Item -Path $dir -ItemType directory > $null
    }
    $wsh = New-Object -ComObject WScript.Shell
    if (!$wsh) { return }
    $lnk = $wsh.CreateShortcut("$dir\$name")
    $lnk.TargetPath = $target
    if ($arg) {
        $lnk.Arguments = '"'+$arg+'"'
        $lnk.IconLocation = "$IconPath"
        $lnk.WorkingDirectory = "$UsrFolder\bin"
    }
    $lnk.Save()
}

#-- create uninstall script and registry key







<
|








|







194
195
196
197
198
199
200

201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
        $host.UI.RawUI.set_bufferSize($MyBuffer)
        $host.UI.RawUI.set_windowSize($MyWindow)
    }
}

#-- create Desktop/Startmenu shortcuts
function Make-Shortcut {

    param($dir, $name, $target, $arg=$false, $parm=$false, [parameter(ValueFromRemainingArguments)]$kwargs)
    if (!(Test-Path -Path $dir)) {
        New-Item -Path $dir -ItemType directory > $null
    }
    $wsh = New-Object -ComObject WScript.Shell
    if (!$wsh) { return }
    $lnk = $wsh.CreateShortcut("$dir\$name")
    $lnk.TargetPath = $target
    if ($arg) {
        ($lnk.Arguments =  '"'+$arg+'"') | %{if ($parm) {$lnk.Arguments += " $parm"}}
        $lnk.IconLocation = "$IconPath"
        $lnk.WorkingDirectory = "$UsrFolder\bin"
    }
    $lnk.Save()
}

#-- create uninstall script and registry key
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356

357
358
359

360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381

382
383
384
385
386
387
388
389
390
391
392
393
394
395

396
397
398
399
400


401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
    return $PYTHON
}

#-- check prereqs installation
function Check-Prerequisites {
    [CmdletBinding()]
    param($result = 1)
    ForEach ($task in $tasks) {
        $title, $url, $cmd, $args, $regkey, $checkpath, $is_optional, $presearch, $_found = $task;
        $checkpath = $checkpath -replace "{PYTHON}","$PYTHON"
        #if ($is_optional -and !$optionalInstall) {
        #    $STREAMRIPPER = ""
        #    continue
        #}
        if (!$regkey -and !$checkpath) {
            continue
        }
        if ($presearch) {  # expression for e.g. registry β†’ path lookup
            Invoke-Expression $presearch > $null # should set $_found + global $PLACEHOLDER variable
        }
        elseif ($checkpath) {
            if (Test-Path $checkpath) {
                $_found = $checkpath
            }
            elseif ($regkey -and (Test-Path $regkey)) {
                $_found = "installer/registry"
            }
        }
        if (!$_found) {

            Write-Host "   - $title not found"
            $result = 0;
        }

        else {
            Write-Host -n "   + $title found "  # and display shortened path:
            Write-Host -f DarkGray "($($_found -replace '(?<!^.{1,4})(\\[^\\]+(?=\\)){2,5}(?!.?$)', '...'))"
        }
    }
    if ($result) {
        Write-Host -f Yellow @"
`nAll required Python components are already installed.
Use 'none', 'skip' or 'S' to skip them. Or just press ENTER on each prompt.
If you want to reinstall them though, use 'all' or 'reinstall' or 'R'.`n
"@
    }
    else {
        Write-Host ""
        Write-Host -f Yellow "Setup is ready for installation now."
    }
    Any-Key Green
}





#-- ask before running
Clear-Host
$host.ui.RawUI.BackgroundColor = ($bckgrnd = 'Black')
Console-MaxHeight
Display-Logo
Check-Package
$PYTHON = Check-PythonInstall
$reuseCachedFiles, $optionalInstall = Ask-First
Check-Prerequisites


#-- process
:tasks ForEach ($task in $tasks) {
    $title, $url, $cmd, $args, $regkey, $testpath, $is_optional, $presearch = $task | 

       % { [regex]::Replace($_, "[#{](\w+)[}#]", { param($m) Invoke-Expression ("$"+$m.Groups[1].Value) }) }
    # options
    if ($is_optional -AND (Invoke-Expression $is_optional) -AND !$optionalInstall) {
        continue    # optional expression test
    }



    # print step
    if ($title -match "\d+\.\d+") { $title = "Installing $title" }
    Write-Host -b DarkBlue "`n $title `n"
    chdir($TEMP);

    # test if element (file path or registry key) already exists:
    if ($testpath -AND ($reinstall -ne "all") -AND (Test-Path -Path $testpath)) {
        Write-Host -f DarkGreen -NoNewline " β†’ Is already present."
        if ($reinstall -eq "none") { continue tasks }
        Switch -regex ( Ask "   Reinstall [y/N/all/none]? " ) {
            "^all|always|re|^A" { $reinstall = "all"; break }
            "never|none|skip|^S" { $reinstall = "none"; continue tasks }
            "^y|yes|1|go|^R" { break } # YES
            ".*" { continue tasks } # everything else counts as NO
        }
    }

    # get "filename" part from url
    $file = [regex]::match($url, "/([^/]+?)([\?\#]|$)").Groups[1].Value;

    # download







|
|
|
<
<
<
<
|


|
|

|
|
|

|
|


|
>
|
|
|
>

|
|
















|
|
|
>
|
<
|
|
|
|
<
<
|
|
|
<
|
<
>
|
<
<
<
|
>
>







|

|


|

|







316
317
318
319
320
321
322
323
324
325




326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369

370
371
372
373


374
375
376

377

378
379



380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
    return $PYTHON
}

#-- check prereqs installation
function Check-Prerequisites {
    [CmdletBinding()]
    param($result = 1)
    ForEach ($t in $tasks) {
        $t.found = 0
        $t.testpth = $t.testpth -replace "{PYTHON}","$PYTHON"




        if (!$t.regkey -and !$t.testpth) {
            continue
        }
        if ($t.prescn) {  # expression for e.g. registry β†’ path lookup
            Invoke-Expression $t.prescn  # should set $_found + global $PLACEHOLDER variable
        }
        elseif ($t.testpth) {
            if (Test-Path $t.testpth) {
                $t.found = $t.testpth
            }
            elseif ($t.regkey -and (Test-Path $t.regkey)) {
                $t.found = "installer/registry"
            }
        }
        if (!$t.found) {
            if ((!$t.is_opt) -or ($optionalInstall)) {
                Write-Host "   - $($t.title) not found"
                $result = 0;
            }
        }
        else {
            Write-Host -n "   + $($t.title) found "  # and display shortened path:
            Write-Host -f DarkGray "($($t.found -replace '(?<!^.{1,4})(\\[^\\]+(?=\\)){2,5}(?!.?$)', '...'))"
        }
    }
    if ($result) {
        Write-Host -f Yellow @"
`nAll required Python components are already installed.
Use 'none', 'skip' or 'S' to skip them. Or just press ENTER on each prompt.
If you want to reinstall them though, use 'all' or 'reinstall' or 'R'.`n
"@
    }
    else {
        Write-Host ""
        Write-Host -f Yellow "Setup is ready for installation now."
    }
    Any-Key Green
}

#-- Operates on parameters of each hash from `$tasks`
#
#  Β· $title   β†’ print current step
#  Β· $url     β†’ download from given link, keep as local `$file`
#  Β· $cmd     β†’ instead of running file, run a custom command

#  Β· $args    β†’ used for MSI installation
#  Β· $testpth β†’ check for exisiting dir/file
#  Β· $regkey  β†’ set registry key if successful
#  Β· $is_opt  β†’ run as expression


#  Β· $prescn  β†’ used in check-prereq()
#
filter Run-Task {

    # extract flags/vars from $tasks pipe

    $title=""; $cmd=""; $url=""; $args=""; $testpth=""; $regkey=""; $is_opt=""; $prescn=""; $_found=""
    ($task = $_).GetEnumerator() | % { Set-Variable -Scope Local -Name $_.key -Value ([regex]::Replace($_.value, "[#{](\w+)[}#]", { param($m) Invoke-Expression ("$"+$m.Groups[1].Value) })) }




    # skip optionals
    if ($is_opt -AND !(Invoke-Expression $is_opt)) { return }

    # print step
    if ($title -match "\d+\.\d+") { $title = "Installing $title" }
    Write-Host -b DarkBlue "`n $title `n"
    chdir($TEMP);

    # test if element (file path or registry key) already exists:
    if ($testpth -AND ($reinstall -ne "all") -AND (Test-Path -Path $testpth)) {
        Write-Host -f DarkGreen -NoNewline " β†’ Is already present."
        if ($reinstall -eq "none") { return }
        Switch -regex ( Ask "   Reinstall [y/N/all/none]? " ) {
            "^all|always|re|^A" { $reinstall = "all"; break }
            "never|none|skip|^S" { $reinstall = "none"; return }
            "^y|yes|1|go|^R" { break } # YES
            ".*" { return } # everything else counts as NO
        }
    }

    # get "filename" part from url
    $file = [regex]::match($url, "/([^/]+?)([\?\#]|$)").Groups[1].Value;

    # download
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
            if (!($file)) {
                $cmd = "& `"$PYTHON\Scripts\easy_install.exe`" $url" #"
            }
            else {
                $cmd = "& `"$PYTHON\Scripts\easy_install.exe`" $TEMP\$file" #"
            }
        }
        Write-Host -f DarkGray   " β†’ $cmd"
        Invoke-Expression "$cmd"
    }
    # msi
    elseif ($file -match ".+.msi$") {
        Write-Host -f DarkGray (" β†’ msiexec /i " + "$file " + $args)
        Start-Process -Wait msiexec -ArgumentList /i,"$TEMP\$file", $args
        if ($regkey) {







|







418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
            if (!($file)) {
                $cmd = "& `"$PYTHON\Scripts\easy_install.exe`" $url" #"
            }
            else {
                $cmd = "& `"$PYTHON\Scripts\easy_install.exe`" $TEMP\$file" #"
            }
        }
        Write-Host -f Yellow " β†’ $cmd"
        Invoke-Expression "$cmd"
    }
    # msi
    elseif ($file -match ".+.msi$") {
        Write-Host -f DarkGray (" β†’ msiexec /i " + "$file " + $args)
        Start-Process -Wait msiexec -ArgumentList /i,"$TEMP\$file", $args
        if ($regkey) {
464
465
466
467
468
469
470



471


472





473

    # other files
    elseif ($file) {
        echo " β†’ $file"
        & "$TEMP\$file"
    }
}




#Clear-Host


#Display-Logo





Any-Key Green








>
>
>
|
>
>
|
>
>
>
>
>

>
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
    # other files
    elseif ($file) {
        echo " β†’ $file"
        & "$TEMP\$file"
    }
}



#-- run through tasks
Clear-Host
$host.ui.RawUI.BackgroundColor = ($bckgrnd = 'Black')
Console-MaxHeight
Display-Logo
Check-Package
$PYTHON = Check-PythonInstall
$reuseCachedFiles, $optionalInstall = Ask-First
Check-Prerequisites
$tasks | Run-Task  # <-- main loop: process all commands
Any-Key Green

Modified dev/uninstall.cmd from [3476a2c2b1] to [773744179d].

45
46
47
48
49
50
51














52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
cd /d "%~dp0"

if NOT "%cd%" == "%TEMP%" (
	copy "%UsrFolder%\share\streamtuner2\dev\uninstall.cmd" "%temp%\STuninst.cmd" 
	"%temp%\STuninst.cmd"
)















echo | set /p=Do you want to uninstall Streamtuner2 for Windows? [y/N]
set /P INPUT=%=%
If /I NOT '%INPUT%' == 'Y' exit

echo | set /p=Do you want to keep your Streamtuner2 settings? [Y/n]
set /P INPUT=%=%
If /I '%INPUT%' == 'N' (
	echo Deleting personal settings...
	del "%Userprofile%\AppData\Roaming\streamtuner2\*.*" /F /S /Q
)
set INPUT=

if '"%StreamripperFolder%"' NEQ '' ( 
	echo | set /p=Do you want to uninstall Streamripper? [y/N]
	goto uninstallSR
)







>
>
>
>
>
>
>
>
>
>
>
>
>
>








|







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
cd /d "%~dp0"

if NOT "%cd%" == "%TEMP%" (
	copy "%UsrFolder%\share\streamtuner2\dev\uninstall.cmd" "%temp%\STuninst.cmd" 
	"%temp%\STuninst.cmd"
)

tasklist /fi "Imagename eq python.exe" /fi "Windowtitle eq Streamtuner2*" /v | find "Streamtuner2" >nul
if %errorlevel% EQU 0 goto ST2isRunning
tasklist /fi "Imagename eq pythonw.exe" /fi "Windowtitle eq Streamtuner2*" /v | find "Streamtuner2" >nul
if %errorlevel% EQU 1 goto NotRunning

:ST2isRunning
echo Streamtuner2 is still running!
echo Please close all instances of Streamtuner2 before uninstalling!
pause
exit



:NotRunning
echo | set /p=Do you want to uninstall Streamtuner2 for Windows? [y/N]
set /P INPUT=%=%
If /I NOT '%INPUT%' == 'Y' exit

echo | set /p=Do you want to keep your Streamtuner2 settings? [Y/n]
set /P INPUT=%=%
If /I '%INPUT%' == 'N' (
	echo Deleting personal settings...
	del "%Userprofile%\AppData\Roaming\streamtuner2\*.*" /F /S /Q 1>nul
)
set INPUT=

if '"%StreamripperFolder%"' NEQ '' ( 
	echo | set /p=Do you want to uninstall Streamripper? [y/N]
	goto uninstallSR
)
100
101
102
103
104
105
106
107
108
109
110
111
112
113
	rd "%Python%"  /S /Q
)

echo Removing Streamtuner2
rd "%installFolder%" /S /Q

echo Removing shortcuts
rd "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Streamtuner2" /S /Q
del "%USERPROFILE%\Desktop\Streamtuner2.lnk" 1>nul

reg delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Streamtuner2 /f 1>nul  2>&1

echo Finished uninstalling Streamtuner2
pause







|






114
115
116
117
118
119
120
121
122
123
124
125
126
127
	rd "%Python%"  /S /Q
)

echo Removing Streamtuner2
rd "%installFolder%" /S /Q

echo Removing shortcuts
rd "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Streamtuner2" /S /Q 1>nul
del "%USERPROFILE%\Desktop\Streamtuner2.lnk" 1>nul

reg delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Streamtuner2 /f 1>nul  2>&1

echo Finished uninstalling Streamtuner2
pause

Modified gtk3.xml.gz from [ddb4445ce8] to [2a1b78224d].

cannot compute difference between binary files