'Check for Updates' Script
-
None in existence so far.
But I've started to sketch out a system. -
JonD, Not automatic, but look at Dxf_In. If you do, select a file to open, then select Help Options. It links to the "Su plugin topic".
-
smustard offers it. Its part of the smustard toolbar. You can download that script and look at it I think. But I think there might be more happening on the back end than in that script. But it might be worth looking at.
Chris
-
My preference is either RubyGems, or RVM (for OSX,) and pik (for Win32.)
-
Thanks all, I have check these out and post what I come up with.
Jon
-
@jond said:
Has anyone had any luck making a script that automatically updates. I would like to somehow check the script version against my website and offer to download an update if one exists. My initial thought was to have a text file on the website that contains a version number. The script would check the version number in the text file when it loads (if online) and then prompt the user to download the updated files directly into the plugins folder. I am sure it is not as easy I am making it sound...
Has anyone tried this? If so, please share!
Thanks,
JonYes, I've done exactly this in SkIndigo and it seems to work well.
@mat_editor.add_action_callback("check_current_version") {|d,p| version=p.to_s current=SkIndigo;;VERSION.to_s if version>current text="A newer version of SkIndigo is available. Would you like to update? (Click 'No' to be reminded in two weeks.)" result=UI.messagebox(text,MB_YESNO) if result==6 #yes UI.openURL("http://www.indigorenderer.com/documentation/sketchup") else time=Time.now.to_i Sketchup.write_default("SkIndigo","LastUpdateCheck",time) end end }
def check_for_updates() last_update_check=Sketchup.read_default("SkIndigo","LastUpdateCheck",0) current_time=Time.now.to_i update_check_period=1209600 if current_time-last_update_check>update_check_period #check for updates every 2 weeks @mat_editor.execute_script("check_current_version();") end end
Javascript in the webdialog initiates in the version check using jquery:
function check_current_version() { $.get("http://www.indigorenderer.com/dist/exporters/skindigo/skindigo_current_version.txt", function(data){ window.location='skp;check_current_version@'+data; }); }
-
That is perfect! Thanks for the post.
-
Thanks for the direction. Here is how I ended up doing it - very close to Whaat's method. The main difference is I am loading a very small page in the web dialog, not getting the contents of the text file. I had trouble getting the $.get method to work...javascript newbie, I am...
This is the code in the ruby script. I basically open the webdialog during the startup of Sketchup. The web page loaded in the dialog (from my server) just returns the current build code. I had to add the UI.start_timer to pause a second to let the javascript happen, then close the web dialog
current = $current.to_s if Sketchup.is_online ssupdate = UI;;WebDialog.new("Check for Updates", false, "Check for Updates", 200, 200, 200, 200, true) ssupdate.add_action_callback("check_current_version") {|d,p| version=p.to_s if version>current text="A newer version of Lakefront Layout is available. Would you like to update?" result=UI.messagebox(text,MB_YESNO) if result==6 #yes UI.openURL("http://www.shorestation.com/") end end } ssupdate.set_url("http://www.shorestation.com/IPADock/Sketchup/checkupdate.html") ssupdate.show id = UI.start_timer(1, false){ssupdate.close} end#if
Here is the html file I have on y website:
the 20111112 is the date code of the latest build. This is what I edit when I want to push a new update.
<html> <script> function check_current_version() { window.location='skp;check_current_version@'+20101112; } window.onload = check_current_version() </script> <body> </body> </html>
I am sure this is not the greatest approach, but it is working. Again, thanks for the help -great forum!
Jon
-
Jon,
It is relatively easy to perform the check of whether the version on the web (and then comare with the one currently installed locally).
The real difficulty is to download the file and install it when it is in binary format (for instance a Zip file). It is possible for a .rb file which is plain text however.
Fredo
PS: I would use Whaat's method, which is to check periodically, even letting the user set the next date. If all scripts do their check at each SU statup, then it would take too long.
-
@unknownuser said:
If all scripts do their check at each SU statup, then it would take too long.
A menu to trigger the check would also work. Or a button if the plugins preference/option dialog if it has one.
-
If you all agree on an API, there could be a single "Update All Plugins" option.
-
@jim said:
If you all agree on an API, there could be a single "Update All Plugins" option.
I got some notes done for this...
-
Here is what I would propose, and which I will do for my own scripts whenever I have time.
-
I will Build a module
CheckForUpdate
It will take care of displaying a window showing the status of plugins. -
A plugin can register to CheckForUpdateby just invoking the following (for instance in its startup section)
CheckForUpdate.register(plugin_name, url) { |text| my_own_check(text) } if defined?(CheckForUpdate)
where
plugin_name
is the unique name of the pluginurl
is the address of the page where the plugin is available for download (for instance Sketchucation, which keeps the page url quite stable)- the dynamic method will receive the whole HTML page as a string (argument
text
) and will be responsible for parsing it the way it likes, and return three information as[outdated, new_version, url_details]
.outdated
is true if the plugin is not up to datenew_version
is a text to be displayed, encoding the new version and date (and whatever additional comment)url_details
is simply a url where the detail of the updated version can be displayed. If nil, thenurl
is used instead.
In the case of my plugins, I will probably use the title of the first post to be parsed: like [Plugin] FredoScale 2.0i - 26 Nov 09.
This API is neutral as it does not make any hypothesis on how the version and dates are coded in the HTML page or text file pointed to by the URL.
Note that the above is only for check for update. Downloading and installing the plugin is another story.
By the way, at Sketchucation, we can probably optimize the process by having a special private page, which is refreshed by a robot every night, where the header of the first post {plugin xxx] are collected 'a little bit like Jim's page on plugin). The benefit is that there is a single url for all pulgins published at Skecthucation, and the url fetching is done once.
Fredo
-
-
@unknownuser said:
Jon,
It is relatively easy to perform the check of whether the version on the web (and then comare with the one currently installed locally).
The real difficulty is to download the file and install it when it is in binary format (for instance a Zip file). It is possible for a .rb file which is plain text however.
Fredo
PS: I would use Whaat's method, which is to check periodically, even letting the user set the next date. If all scripts do their check at each SU statup, then it would take too long.
You are right on with the downloading difficulty. I originally wanted to have each 'dependent' represented in the version string so I could only download the file that needed updating. Unfortunately, I could not find a clean way to initiate a download of a .rb or .rbs file into the plugins directory. I have resorted to having the link point directly to a download of an installer (.exe) and the installer is handling the file moves to the plugins folder. It is an acceptable solution for me.
I have changed my script so that the update is user initiated through the plugin commands. Again, thanks to all for the help.
Jon
Advertisement