Download files with a SketchUp plugin
-
Fredo,
the best I can offer for 10.5.8 (at least) is
system("curl -O http://homepage.mac.com/johnboundy/filechute/homer%20instal.dmg.zip open /homer%20instal.dmg.zip") system("osascript -e 'tell application \"Finder\"' -e 'activate' -e 'end tell'")
this downloads the zip, opens it (in the HD:) and then brings it to the front by opening Finder...
You can then click it to open for instal.Locally, I can open the .dmg fully with a single script in Terminal, but not through SU
I'll have a play later.
BTW: the file is just Jim's 'homer' [yell if you object Jim] in a wrapper if you want something to test download
john
-
Fredo: Thank you! This is what I needed! Finally got downloading working on both Mac and PC. For Mac I ended up doing something like:
system("curl -L -o \"/home/user/somefile.txt\" http://www.somesite.com/somefile.txt")
Using the -L option follows redirects so if the download link was something like http://www.somesite.com/download/?id=123 it would follow the download redirect, which comes in handy. Having the local filesystem URL in quotes helped, and wasn't needed for the URL. On windows, instead of calling curl I called the path to the curl_win.exe file that Fredo has in LibFredo6 3.7.
I finally have a working plugin installer tool! It downloads and install plugins from my website as well as from local files. It even handles uninstall with a restart. I'll update when I have something for people to try out!
Dan: I agree all users "should" have a full Ruby install but the harsh reality is that they don't and many users are not technical enough to install it. My tool needs to work "out of the box" and the curl solution allows for this. Also, the fact that the Ruby installer could not be bundled with my app is another reason I don't think that route will work for me. Thanks you for the suggestions though, I am sure they will come in handy in the future.
driven: Thanks for that. Luckily I found a workaround for downloading/extracting a zip, but I like the trick.
Cheers,
Dana -
@unknownuser said:
It would be nice if Mac users could force Sketchup to load a newer ruby version
I "upgraded" my Sketchup Ruby to 1.8.7 using this trick
I think it is more easy to create an extensions (PC/Mac) which downloads the file from a given URL (with redirect and authentification) than packaging curl
-
@ishboo said:
Dan: I agree all users "should" have a full Ruby install but the harsh reality is that they don't and many users are not technical enough to install it.
Does not make sense.
If many users are not technical enough to run a one-click installer executable, how are they technical enough to install your package?
And.. didn't they succeed in downloading and installing Sketchup's one-click installer executable despite their lack of technical skill?
-
And by the way.. pik (which is the Win32 equivalent of RVM,) uses the 7za.exe command line executable. (The file must be in the path environment var, or use an absolute path.)
There's also a DLL version. It's Free OpenSource, under GNU LPGL.
Command line versions are available for Win, Unix, Linux, OSX, etc.
http://www.7-zip.org/download.html -
@dan rathbun said:
Does not make sense.
If many users are not technical enough to run a one-click installer executable, how are they technical enough to install your package?
And.. didn't they succeed in downloading and installing Sketchup's one-click installer executable despite their lack of technical skill?
It does make sense. I was not talking about Window's one-click install but the hacking required to get it working on a Mac.
Also, having to require users to download a 25mb file and install it just to use my plugin is not acceptable in my eyes. I want this plugin to work on most systems by default, without any mucking around and dependencies.
@dan rathbun said:
And by the way.. pik (which is the Win32 equivalent of RVM,) uses the 7za.exe command line executable. (The file must be in the path environment var, or use an absolute path.)
There's also a DLL version. It's Free OpenSource, under GNU LPGL.
Command line versions are available for Win, Unix, Linux, OSX, etc.
http://www.7-zip.org/download.htmlSo this would be to extract a zip then? I got around local extraction because I do that server side and pull each file in manually, but would be interesting in case I change my mind or need that behavior in another plugin.
@unknownuser said:
I "upgraded" my Sketchup Ruby to 1.8.7 using this [url=http://stackoverflow.com/questions/3333163/how-to-update-ruby-in-google-sketchup:38tqxa52]trick[/url:38tqxa52]
Thanks for the link, if I need to upgrade I'll have to check that out.
@unknownuser said:
I think it is more easy to create an extensions (PC/Mac) which downloads the file from a given URL (with redirect and authentification) than packaging curl
Do you have an example of an extension that would download a file from the web? I asked around and searched quite a lot to no avail. Also, by extension, do you mean a C/C++ extension (I'm assuming so...)?
It seems like curl works fine for this use case (since it is working already and requires only a few lines of code and a very small .exe file). If there is a good reason to go with something else I'd love to hear it... Why do you think it is more easy to create an extension?
Thanks for all your replies guys!
-
pros for C/C++ ruby extension
• you can download directly to memory without the need to save to disk first
• no need to spawn to command line - faster
• provide a progress bar / cancel without the need to poll curl output
• smaller package sizecons
• must code it -
@unknownuser said:
pros for C/C++ ruby extension
• you can download directly to memory without the need to save to disk first
• no need to spawn to command line - faster
• provide a progress bar / cancel without the need to poll curl output
• smaller package sizecons
• must code itHow easy/hard is it to make it cross-*platform?
-
@thomthom said:
@unknownuser said:
pros for C/C++ ruby extension
• you can download directly to memory without the need to save to disk first
• no need to spawn to command line - faster
• provide a progress bar / cancel without the need to poll curl output
• smaller package sizecons
• must code itHow easy/hard is it to make it cross-*platform?
I'd also like to know this. Also would love to know if there is any open-source code or tutorials out there about how to make such an extension.
I am lacking in C knowledge and doing something like this would be a rather difficult task for me at this point.
Any info would be appreciated.
Cheers,
Dana -
As an update to this post, I am near complete with a Ruby C extension that downloads a file or files within a Ruby plugin that works on Mac and Windows. I will be releasing it as an open-source project and will post again when it is available. It is strait-forward to use and uses the powerful cURL (libcurl) library. Till then...
-
-
@ishboo said:
As an update to this post, I am near complete with a Ruby C extension that downloads a file or files within a Ruby plugin that works on Mac and Windows. I will be releasing it as an open-source project and will post again when it is available. It is strait-forward to use and uses the powerful cURL (libcurl) library. Till then...
Very good. Thanks in advance.
Fredo
-
-
-
Agreed, that's cool!
Chris
-
Thanks Dana. Just curious, since there are so many plugins posted here and people need to be registered and logged-in to download them, will your plugin handle the login?
-
@jim said:
Thanks Dana. Just curious, since there are so many plugins posted here and people need to be registered and logged-in to download them, will your plugin handle the login?
?
We're talking about generic downloader here I think. Not a plugin downloader... -
@thomthom said:
We're talking about generic downloader here I think. Not a plugin downloader...
What's the difference? Maybe my question should have been: Could the downloader be used to download plugins for SCF where a user is required to be logged in to have access to the file?
-
As a generic down-loader it will work through something like a webdialog, where the url-side contains files that can be downloaded; but once you get into a public-type web-site like SCF then the whole browser coding possibilities are setup to protect the user, and it will always asks for a 'save' confirmation via an unavoidable dialog to prevent virus invasions etc. In a database-type system what is picked 'on-screen' is merely a link to a db and the file is elsewhere - the thing that's then downloaded in 'protected', you'll probably never get the direct link to the very file itself, which lies under layers of protection to prevent backtrack hacking through html folder-paths and thereby potentially allowing the getting of all such files en mass...
As part of a 'tool' that allowed you to download plugins 'direct' from SCF you'd need to have paths available to the tool from a db ? How is the arrival folder to be determined ? Like 3dWarehouse lets you download/use SKP files from clicking links, but then you still need to select a save path etc... -
TIG,
You are perfectly right. Downloading by program (specially binary files) is something where we could go to an uncontrolled path.
What could be useful however is a Ruby method to download text file (like a public HTML page), usually to a temporary directory, just the time to read it.
The point is that you can do it from a Web dialog (via XMLHttpRequest), but sometimes you may want to check 'silently' whether something has changed on the web.
Otherwise better invoke the traditional "download dialog box" of the browser.
I have this function in LibFredo6 check for Update, but I did not enable it for several reasons:- it may not work depending on your local security configuration
- on Mac, it does not put the focus on the small download window, except the very first time
But the main reason is that I think it is always preferable that the user goes to the plugin web page and then have an opportunity to read the text and instructions, rather than to download 'blindly' files.
As an illustration, I have enabled the download file function for the plugin RemoveLonelyVertices (you should see now a small blue arrow). I am intersted in knowing what users get when clicking on it.
Fredo
Advertisement