Stringscan

Check-in [32766420e8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Tweaks for softwareupdate library
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 32766420e88a36dd671aa8d63850ff6b8b57c40d1f50ad3d81e6bd872cfcd5e9
User & Date: kevin 2018-05-22 12:28:08
Context
2018-05-22
12:28
Tweaks for softwareupdate library check-in: 07c65e8aea user: kevin tags: trunk
12:28
Tweaks for softwareupdate library check-in: 32766420e8 user: kevin tags: trunk
2018-05-17
12:39
Add new Mac icon check-in: f231eae0a5 user: kevin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to scriptlibs/softwareupdate/pkgIndex.tcl.

1
2
3
4
5
6
7
8
9
10
11
# Tcl package index file, version 1.1
# This file is generated by the "pkg_mkIndex" command
# and sourced either when an application starts up or
# by a "package unknown" script.  It invokes the
# "package ifneeded" command to set up package-related
# information so that packages will be loaded automatically
# in response to "package require" commands.  When this
# script is sourced, the variable $dir must contain the
# full path name of this file's directory.

package ifneeded softwareupdate_ruby 1.5 [list source [file join $dir softwareupdate.tcl]]










|
1
2
3
4
5
6
7
8
9
10
11
# Tcl package index file, version 1.1
# This file is generated by the "pkg_mkIndex" command
# and sourced either when an application starts up or
# by a "package unknown" script.  It invokes the
# "package ifneeded" command to set up package-related
# information so that packages will be loaded automatically
# in response to "package require" commands.  When this
# script is sourced, the variable $dir must contain the
# full path name of this file's directory.

package ifneeded softwareupdate 1.5 [list source [file join $dir softwareupdate.tcl]]

Changes to scriptlibs/softwareupdate/softwareupdate.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#softwareupdate.tcl  routines to manage spoftware updates

#  Copyright (C) 2014  WordTech Communications LLC

#MIT license

package provide softwareupdate_ruby 1.5
package require http
package require tls

::http::register https 443 [list ::tls::socket -servername codebykevin.com -request 0 -require 0 -ssl2 0 -ssl3 0 -tls1 1]

namespace eval softwareupdate {







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
#softwareupdate.tcl  routines to manage spoftware updates

#  Copyright (C) 2014  WordTech Communications LLC

#MIT license

package provide softwareupdate 1.5
package require http
package require tls

::http::register https 443 [list ::tls::socket -servername codebykevin.com -request 0 -require 0 -ssl2 0 -ssl3 0 -tls1 1]

namespace eval softwareupdate {

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
	variable currentversion
	variable versionnumber

	set appname $app

	softwareupdate::checkingForUpdates

	set versionurl https://www.codebykevin.com/$appname-version.tcl
	http::config -useragent "$appname Update Check"

	if [catch {http::geturl $versionurl} msg] {
	    puts "error: $msg"
	    tk_messageBox -icon warning -title "Unable to Connect to Server" -message "Unable to Connect to Server" -detail "Unable to connect to www.codebykevin.com to check for updates. Please make sure you are connected to the Internet." -parent .
	catch {destroy .updateprogress}
	    return
	} 

	set versionnumber [string trim [http::data [http::geturl $versionurl]]]
	if [expr $currentversion < $versionnumber] {







|



|







61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
	variable currentversion
	variable versionnumber

	set appname $app

	softwareupdate::checkingForUpdates

	set versionurl [string tolower https://www.codebykevin.com/$appname-version.tcl]
	http::config -useragent "$appname Update Check"

	if [catch {http::geturl $versionurl} msg] {
	    if {[tk windowingsystem] ne "win32"} { puts "error: $msg"}
	    tk_messageBox -icon warning -title "Unable to Connect to Server" -message "Unable to Connect to Server" -detail "Unable to connect to www.codebykevin.com to check for updates. Please make sure you are connected to the Internet." -parent .
	catch {destroy .updateprogress}
	    return
	} 

	set versionnumber [string trim [http::data [http::geturl $versionurl]]]
	if [expr $currentversion < $versionnumber] {
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
    #get the current installation path
    proc findCurrentInstallation {} {
	variable currentinstall
	variable appname 
	switch [tk windowingsystem] {

	    "aqua" {
		set approot [file join [file dirname [info script]]]
		set approot [info nameofexecutable]
		set apppath [split $approot /]
		set currentinstall [join [lrange $apppath 0 [lsearch $apppath "*.app"]] / ]
	    }
	    
	    "win32" {
		set currentinstall [file join $::env(APPDATA) ${appname}_App]  
	    }
	    
	    "x11" {
		return
	    }
	}
	
	return $currentinstall

    }

    #alternative way to get installation path
    proc setCurrentInstallation {path} {
	variable currentinstall

	set currentinstall $path
	return $currentinstall

    }



    #prompt user to update
    proc updatePitch {} {
	variable appname
	variable icon
	variable changedata
	variable currentversion
	variable versionnumber

	catch {destroy .updateprogress}

	catch {destroy .update}
	
	variable appname

	set changeurl https://www.codebykevin.com/$appname-changes.tcl

        if [catch {http::geturl $changeurl} msg] {
	    puts "error: $msg"
	    tk_messageBox -icon warning -title "Unable to Connect to Server" -message "Unable to Connect to Server" -detail "Unable to connect to www.codebykevin.com to check for updates. Please make sure you are connected to the Internet." -parent .
	    catch {destroy .updateprogress}
	    return
	} 


	set changelist [http::data [http::geturl $changeurl]]







<
















<
<
<
<
<
<
<
<
<


















|


|







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
    #get the current installation path
    proc findCurrentInstallation {} {
	variable currentinstall
	variable appname 
	switch [tk windowingsystem] {

	    "aqua" {

		set approot [info nameofexecutable]
		set apppath [split $approot /]
		set currentinstall [join [lrange $apppath 0 [lsearch $apppath "*.app"]] / ]
	    }
	    
	    "win32" {
		set currentinstall [file join $::env(APPDATA) ${appname}_App]  
	    }
	    
	    "x11" {
		return
	    }
	}
	
	return $currentinstall










    }



    #prompt user to update
    proc updatePitch {} {
	variable appname
	variable icon
	variable changedata
	variable currentversion
	variable versionnumber

	catch {destroy .updateprogress}

	catch {destroy .update}
	
	variable appname

	set changeurl [string tolower https://www.codebykevin.com/$appname-changes.tcl]

        if [catch {http::geturl $changeurl} msg] {
	    if {[tk windowingsystem] ne "win32"} { puts "error: $msg"}
	    tk_messageBox -icon warning -title "Unable to Connect to Server" -message "Unable to Connect to Server" -detail "Unable to connect to www.codebykevin.com to check for updates. Please make sure you are connected to the Internet." -parent .
	    catch {destroy .updateprogress}
	    return
	} 


	set changelist [http::data [http::geturl $changeurl]]
273
274
275
276
277
278
279
280


281
282
283
284
285
286



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329






330
331
332
333
334
335
336
337
338
339
    proc installUpdate {} {
	variable currentinstall
	variable status
	variable appname
	variable tmpdir

	catch {destroy .update}
	


	softwareupdate::progressDialog
	set status "Downloading update for $appname"
	
	switch [tk windowingsystem] {

	    "aqua" {



		http::geturl https://www.codebykevin.com/updates/[list $appname].dmg -channel [open $tmpdir/[list $appname].dmg w] 
		update
		after 1000
		cd $tmpdir
		set status "Attaching [list $appname].dmg"
		update
		exec hdiutil attach  [list $appname].dmg
	    }
	    
	    "win32" {
		
		http::geturl https://www.codebykevin.com/updates/[list $appname]_Setup.exe -channel [open $tmpdir/[list $appname]_Setup.exe w]

	    }
	    
	    "x11" {
		tk_messageBox -icon info -parent . -message "Please ask the maintainer of $appname on your platform to prepare a release of the latest version."
		return
	    }
	}
	
	
	set status "Ready to install"
	.downloadprogress.frame.bar configure -mode determinate
	.downloadprogress.frame.bar configure -value 100
	.downloadprogress.frame.bar stop
	destroy .downloadprogress.frame.b 
	pack [ttk::button .downloadprogress.frame.b -text "Install" -command softwareupdate::launchUpdate] -side right -fill both -expand no
	return
    }


    #launch the update
    proc launchUpdate {}  {

	variable currentinstall
	variable appname
	variable tmpdir
	
	switch [tk windowingsystem] {

	    "aqua" {







		exec open -R /Volumes/[list $appname]

		 exit
	    }
	    
	    "win32" {
		
		eval exec [auto_execok start] [file normalize $tmpdir/[list $appname]_Setup.exe] &
		exit
	    }







|
>
>






>
>
>
|





|




|















|















>
>
>
>
>
>
|

|







263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
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
    proc installUpdate {} {
	variable currentinstall
	variable status
	variable appname
	variable tmpdir

	catch {destroy .update}

	softwareupdate::findCurrentInstallation

	softwareupdate::progressDialog
	set status "Downloading update for $appname"
	
	switch [tk windowingsystem] {

	    "aqua" {
		update
		after 1000
		#http package causes file corruption of the DMG for some reason
		exec curl -s https://www.codebykevin.com/updates/[list $appname].dmg -o  $tmpdir/[list $appname].dmg
		update
		after 1000
		cd $tmpdir
		set status "Attaching [list $appname].dmg"
		update
		exec hdiutil attach [list $appname].dmg
	    }
	    
	    "win32" {
		
		http::geturl https://www.codebykevin.com/updates/[list $appname]_Setup.exe -binary 1 -channel [open $tmpdir/[list $appname]_Setup.exe wb]

	    }
	    
	    "x11" {
		tk_messageBox -icon info -parent . -message "Please ask the maintainer of $appname on your platform to prepare a release of the latest version."
		return
	    }
	}
	
	
	set status "Ready to install"
	.downloadprogress.frame.bar configure -mode determinate
	.downloadprogress.frame.bar configure -value 100
	.downloadprogress.frame.bar stop
	destroy .downloadprogress.frame.b 
	pack [ttk::button .downloadprogress.frame.b -text "Install and Relaunch" -command softwareupdate::launchUpdate] -side right -fill both -expand no
	return
    }


    #launch the update
    proc launchUpdate {}  {

	variable currentinstall
	variable appname
	variable tmpdir
	
	switch [tk windowingsystem] {

	    "aqua" {

		file rename -force $currentinstall [file join /Users [exec whoami] .Trash [file tail $currentinstall]]

		file copy -force /Volumes/[list $appname]/[list $appname].app $currentinstall

		exec $currentinstall/Contents/MacOS/$appname &

		exec hdiutil detach /Volumes/[list $appname]

		exit
	    }
	    
	    "win32" {
		
		eval exec [auto_execok start] [file normalize $tmpdir/[list $appname]_Setup.exe] &
		exit
	    }

Changes to stringscan.rb.

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52


53
54
55
56
57
58
59

    #here we initialize our app class
    def initialize

        $dirname = ""
        $searchterm = ""
        $appname = 'Stringscan'
        $appversion = '1.2'
        Tk.tk_call('machelp::setAppName', $appname, $appversion)
        Tk.tk_call('softwareupdate::setAppName', $appname)
        Tk.tk_call('softwareupdate::setVersion', $appname, $appversion)

        bgerror = Tk.install_cmd(proc{
            |*args|
            puts args
        })
        Tk.ip_eval("proc bgerror {args} {#{bgerror} $args}")



        if $platform == 'aqua'
            ##map ruby proc to "odoc" Apple Event
            setDir = Tk.install_cmd(proc{
                |*args|
                filename=(args[0]).delete('{}')
                begin







|









>
>







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

    #here we initialize our app class
    def initialize

        $dirname = ""
        $searchterm = ""
        $appname = 'Stringscan'
        $appversion = '2.0'
        Tk.tk_call('machelp::setAppName', $appname, $appversion)
        Tk.tk_call('softwareupdate::setAppName', $appname)
        Tk.tk_call('softwareupdate::setVersion', $appname, $appversion)

        bgerror = Tk.install_cmd(proc{
            |*args|
            puts args
        })
        Tk.ip_eval("proc bgerror {args} {#{bgerror} $args}")
        $foo = Tk.ip_eval("softwareupdate::findCurrentInstallation")
        puts "install location is $foo" 

        if $platform == 'aqua'
            ##map ruby proc to "odoc" Apple Event
            setDir = Tk.install_cmd(proc{
                |*args|
                filename=(args[0]).delete('{}')
                begin
67
68
69
70
71
72
73

74
75
76
77
78
79
80
                    end
                rescue
                    raise
                end
            })    
            Tk.ip_eval("proc ::tk::mac::OpenDocument {args} {#{setDir} $args}")
            Tk.ip_eval("proc ::tk::mac::ShowHelp {} {#{Tk.install_cmd(proc{showHelp})}}")

        end        
        drawgui
        Tk.tk_call('regproc::readLic', $appname, $appversion)
        getInstall
    end  

    #core method; here we search for a string in text files within a directory and  display a list of matching files in the listbox 







>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
                    end
                rescue
                    raise
                end
            })    
            Tk.ip_eval("proc ::tk::mac::OpenDocument {args} {#{setDir} $args}")
            Tk.ip_eval("proc ::tk::mac::ShowHelp {} {#{Tk.install_cmd(proc{showHelp})}}")
            Tk.ip_eval("proc ::softwareupdate::findCurrentInstallation {} {#{Tk.install_cmd(proc{getInstall})}}")
        end        
        drawgui
        Tk.tk_call('regproc::readLic', $appname, $appversion)
        getInstall
    end  

    #core method; here we search for a string in text files within a directory and  display a list of matching files in the listbox 
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
end

#about window for app
def aboutWindow
    Tk::messageBox :type => 'ok',
    :message => 'Stringscan: Text Search Tool',
    :icon => 'info', :title => 'About Stringscan',
    :detail  => "Version 1.2\n(c) 2018 WordTech Communications LLC",
    :parent => $root
end

#check version of installed software
def checkUpdate 
    Tk.tk_call('softwareupdate::setIcon', $icon)
    Tk.tk_call('softwareupdate::checkVersion', $appname, $appversion)







|







1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
end

#about window for app
def aboutWindow
    Tk::messageBox :type => 'ok',
    :message => 'Stringscan: Text Search Tool',
    :icon => 'info', :title => 'About Stringscan',
    :detail  => "Version 2.0\n(c) 2018 WordTech Communications LLC",
    :parent => $root
end

#check version of installed software
def checkUpdate 
    Tk.tk_call('softwareupdate::setIcon', $icon)
    Tk.tk_call('softwareupdate::checkVersion', $appname, $appversion)