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

⌈⌋ branch:  streamtuner2


Check-in [ed3c221a07]

Overview
Comment:minor updates
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ed3c221a0725fe3cdc80e5591ebd5392ee3c8479
User & Date: mario on 2016-12-03 21:26:33
Other Links: manifest | tags
Context
2016-12-03
21:27
Manual slightly restructured, icons for plugins added back in. check-in: 8147a96b12 user: mario tags: trunk
21:26
minor updates check-in: ed3c221a07 user: mario tags: trunk
21:24
lsplugins: export {png} to help/img/ check-in: f9e21a1d69 user: mario tags: trunk
Changes

Modified dev/install_python_gtk.ps1 from [0748f98fbb] to [d96ab4ebf0].

16
17
18
19
20
21
22
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
16
17
18
19
20
21
22




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







-
-
-
-
+
+

















-
+







Param(
  [string]$reinstall = "ask",
  [string]$TEMP = $env:TEMP,
  [string]$PYTHON = "C:\Python27",
  [string]$StartMenu = "$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs",
 #[string]$UsrFolder = $MyInvocation.MyCommand.Path -replace ("([\\/][^\\/]+){4}$",""),
  [string]$ProgramFiles = "%ProgramFiles(x86)%",
 #[string]$UninstallPath = "$UsrFolder\share\streamtuner2\dev\uninstall.cmd",
 #[string]$IconPath = "$UsrFolder\share\pixmaps\streamtuner2.ico",
  [string]$AboutLink = "http://freshcode.club/projects/streamtuner2"
 #[string]$ModifyPath = $MyInvocation.MyCommand.Path -replace (".ps1", ".bat")
  [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%"
}
$STREAMRIPPER = "$ProgramFiles\Streamripper"
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
59
60
61
62
63
64
65
66


67
68
69
70
71
72
73
57
58
59
60
61
62
63

64
65
66
67
68
69
70
71
72







-
+
+







  ),
  @(
    "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}",
#    "$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",
111
112
113
114
115
116
117
118

119
120
121
122
123
124
125
110
111
112
113
114
115
116

117
118
119
120
121
122
123
124







-
+







    "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
    '(($_found = (Get-ITPV "Streamripper")) -AND ($script:STREAMRIPPER = $_found))'  # look up path in Check-Prerequisites
    '($optionalInstall -AND ($_found = (Get-ITPV "Streamripper")) -AND ($STREAMRIPPER = $_found) -OR ((!$optionalInstall) -AND $STREAMRIPPER=""))'  # look up path in Check-Prerequisites
  ),
  @(
    "Uninstall script",
    "",
    'Create-Uninstallscript'
  ),
  @(
171
172
173
174
175
176
177
178

179
180
181
182
183
184
185
186
187

188
189
190
191
192
193
194
195
196
197
170
171
172
173
174
175
176

177
178
179
180
181
182
183
184
185

186
187
188

189
190
191
192
193
194
195







-
+








-
+


-







|           ______\////\\\____________\/\\\______________/\\\//_____          |
|            _________\////\\\_________\/\\\___________/\\\//________         |
|             __/\\\______\//\\\________\/\\\_________/\\\/___________        |
|              _\///\\\\\\\\\\\/_________\/\\\________/\\\\\\\\\\\\\\\_       |
|               ___\///////////___________\///________\///////////////__      |
|                                                                             |
|                                                                             |
|    Streamtuner2 for Windows                               Version 2.2.0     |
|    Streamtuner2 for Windows                               Version $VERSION     |
|                                                                             |
|    Installer for Python 2.7.12 & Gtk 2.24.2                                 |
 ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 
"@
}
function Ask-First {
    Write-Host ""
    if ((Ask "Do you want install Streamtuner2 and its Python dependencies now? [Y/n] ") -notmatch "^[yY]|^$") {
        $tasks = $tasks[7..($tasks.length-1)]
        #$tasks = $tasks[7..($tasks.length-1)]; return 0,0
        exit
    }
#   $reuseCachedFiles = (Ask "Reuse any cached setup files? [r]euse/[I]gnore) ") -match "^[Rr]"
    $reuseCachedFiles = (Ask "Reuse any cached setup files or ignore them? [r/I] ") -match "^[Rr]"
    $optionalInstall =  (Ask "Install optional components? [y/N] ") -match "^[Yy]"
    Write-Host ""
    return $reuseCachedFiles, $optionalInstall
}

function Console-MaxHeight {
228
229
230
231
232
233
234
235

236
237
238
239
240
241
242
243
244
245

246

247
248
249

250
251
252
253
254
255
256
257
258
259










260



261
262
263
264
265
266
267
226
227
228
229
230
231
232

233
234
235
236
237
238
239
240
241


242

243
244
245
246
247










248
249
250
251
252
253
254
255
256
257

258
259
260
261
262
263
264
265
266
267







-
+








-
-
+
-
+



+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
+







    $lnk.Save()
}

#-- create uninstall script and registry key
function Create-Uninstallscript {
    [CmdletBinding()]
    param()
    #Write-Host " → Creating uninstall script"
    # update uninstall.cmd with current values
    $installFolder = $usrFolder.substring(0,$usrFolder.LastIndexOf('\'))
    $UninstallScript = Get-Content -Path $UninstallPath
    Out-File -FilePath $UninstallPath -Encoding ascii -InputObject @"
@set installFolder=$installFolder
@set usrFolder=$usrFolder
@set Python=$PYTHON
@set StreamripperFolder=$STREAMRIPPER
"@
    for ($i=4; $i -lt $UninstallScript.Length ; $i++) {
        Out-File -FilePath $UninstallPath -Encoding ascii -Append -InputObject $UninstallScript[$i]
    $UninstallScript | %{if ($_ -notmatch "@set") {Out-File -FilePath $UninstallPath -Encoding ascii -Append -InputObject $_}} 
    }
    # registry entry for ST2
    Remove-Item -Path $regPathCU\Streamtuner2 2> $null        
    New-Item $regPathCU -Name "Streamtuner2" > $null
    Set-Location -Path $regPathCU\Streamtuner2
    @(
    New-ItemProperty -Path . -Name DisplayName -PropertyType String -Value "Streamtuner2" > $null
    New-ItemProperty -Path . -Name DisplayVersion -PropertyType String -Value "2.2.0" > $null
    New-ItemProperty -Path . -Name DisplayIcon -PropertyType String -Value "$IconPath" > $null
    New-ItemProperty -Path . -Name UninstallString -PropertyType String -Value "$UninstallPath" > $null
    New-ItemProperty -Path . -Name URLInfoAbout -PropertyType String -Value "$AboutLink" > $null
    New-ItemProperty -Path . -Name Publisher -PropertyType String -Value "Mario Salzer" > $null
    New-ItemProperty -Path . -Name NoModify -PropertyType DWord -Value 0 > $null
    New-ItemProperty -Path . -Name ModifyPath -PropertyType String -Value "$ModifyPath" > $null
    New-ItemProperty -Path . -Name NoRepair -PropertyType DWord -Value 1 > $null
    New-ItemProperty -Path . -Name HelpLink -PropertyType String -Value "http://fossil.include-once.org/streamtuner2/wiki?name=windows" > $null
        @("DisplayName",     "String",  "Streamtuner2"),
        @("DisplayVersion",  "String",  "$VERSION"),
        @("DisplayIcon",     "String",  "$IconPath"),
        @("UninstallString", "String",  "$UninstallPath"),
        @("URLInfoAbout",    "String",  "$AboutLink"),
        @("Publisher",       "String",  "Mario Salzer"),
        @("NoModify",        "DWord",   0x00000000),
        @("ModifyPath",      "String",  "$ModifyPath"),
        @("NoRepair",        "DWord",   0x00000001),
        @("HelpLink",        "String",  "http://fossil.include-once.org/streamtuner2/wiki/windows")
    #}
    ) | % {
        New-ItemProperty -Path . -Name $_[0] -PropertyType $_[1] -Value $_[2] > $null
    }
}

#-- wait for keypress
function Any-Key($color) {
    Write-Host -f $color "[Press any key]"
    $null = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
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
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







-
+
+
+
+
+









-
-
-
+
+
+







#-- 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) -or (!$regkey -and !$checkpath)) {
        #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"
            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:
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
390
391
392
393
394
395
396

397
398
399
400
401
402
403







-







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" }