need help with Plugins_Updater

2 views
Skip to first unread message

Ilan

unread,
Feb 24, 2010, 8:52:05 AM2/24/10
to Fiji-devel
Friends,
Johannes has written a Plugins_Updater which should very nicely solve
my problem of automatic updates for the hospital. I am trying it out
and am having some difficulties. The crux of the problem is in
long getRemoteModifiedTime(String fileName) throws IOException {
URLConnection connection = getConnection(fileName);
if (connection instanceof HttpURLConnection)
((HttpURLConnection)connection).setRequestMethod("HEAD");
connection.setUseCaches(false);
long lastModified = connection.getLastModified();
connection.getInputStream().close();
return lastModified;
}
where the close() method is giving me trouble, and lastModified=0.

I looked at the exception and the reason is obvious: it isn't seeing
my jar file. My project is at http://github.com/ilan/fijiPlugins and I
have to agree that I don't see any HEAD or any jar file in site. I
have looked at Wayne's source files and I see a HEAD and I have looked
at the fiji project and I see a jars folder with jar files inside it
but I don't see any HEAD there.

On the assumption that I can make http://github.com/ilan/fijiPlugins
contain the jar files in a visible manner, I would like some
suggestions on how to do it. I've been reading the help files from Git
and still don't see both parts which I presumably need.

Since you folks are doing this very thing on a daily basis, you
probably know the answer which is eluding me. Once I get the
information in place, and visible to above routine, I'll be able to
try it.

Thanks,
Ilan

Johannes Schindelin

unread,
Feb 24, 2010, 9:34:18 AM2/24/10
to Ilan, Fiji-devel
Hi,

On Wed, 24 Feb 2010, Ilan wrote:

> Johannes has written a Plugins_Updater which should very nicely solve
> my problem of automatic updates for the hospital.

For the general interest, I attach the current source code here. Please be
nice, I wrote it between 1am and 2am.

Ciao,
Johannes

Plugins_Updater.java

Johannes Schindelin

unread,
Feb 24, 2010, 9:40:58 AM2/24/10
to Ilan, Fiji-devel
Hi,

On Wed, 24 Feb 2010, Ilan wrote:

> Johannes has written a Plugins_Updater which should very nicely solve my
> problem of automatic updates for the hospital. I am trying it out and am
> having some difficulties. The crux of the problem is in
>
> long getRemoteModifiedTime(String fileName) throws IOException {
> URLConnection connection = getConnection(fileName);
> if (connection instanceof HttpURLConnection)
> ((HttpURLConnection)connection).setRequestMethod("HEAD");
> connection.setUseCaches(false);
> long lastModified = connection.getLastModified();
> connection.getInputStream().close();
> return lastModified;
> }
> where the close() method is giving me trouble, and lastModified=0.
>
> I looked at the exception and the reason is obvious: it isn't seeing
> my jar file. My project is at http://github.com/ilan/fijiPlugins and I
> have to agree that I don't see any HEAD or any jar file in site.

Sorry, I should have been clearer about the idea: You _upload_ the .jar
file to a website so that it is available via something like

http://github.com/ilan/fijiPlugins/Pet_Ct_Viewer.jar

Then you run the updater in a macro like this:

call("Plugins_Updater.runSilently",
"http://github.com/ilan/fijiPlugins/",
"Pet_Ct_Viewer.jar");

Likewise, if you want to put another plugin there, too, and keep it
up-to-date, you should make it available as, say,

http://github.com/ilan/fijiPlugins/Read_BI_Studies.jar

and then you can do the combined update with

call("Plugins_Updater.runSilently",
"http://github.com/ilan/fijiPlugins/",
"Pet_Ct_Viewer.jar Read_BI_Studies.jar");

As far as I know, you can make files available on github.com by cloning
your repository anew, checking out the "gh_pages" branch, adding the
files, committing them and pushing the result:

$ git clone -n g...@github.com:ilan/fijiPlugins github-upload
^ -n says not to check out the default branch

$ cd github-upload

$ git checkout -t origin/gh_pages
^ -t says that you will have a local branch of the
same name: gh_pages

$ cp /path/to/Pet_Ct_Viewer.jar ./

$ git add Pet_Ct_Viewer.jar

$ git commit -m "Add the Pet Ct Viewer .jar file"

$ git push origin HEAD

That should do the trick. If not, please note that I never did this
myself, there is extensive documentation on github.com, though.

Ciao,
Johannes

Ilan

unread,
Feb 24, 2010, 9:50:59 AM2/24/10
to Fiji-devel
Johannes,
Your code was perfectly clear to me - no problem on that part.
It is the Git end I am struggling with.
I just tried to do a commit and it is making my life difficult.
I'll get it but it isn't the most obvious thing in the world.

The key is all those git commands you have at the end.
I've got to play with them until I finally get something which is
visible.
Once I have something which is visible, THEN I can try the updater.

Thanks,
Ilan

Johannes Schindelin

unread,
Feb 24, 2010, 9:55:46 AM2/24/10
to Ilan, Fiji-devel
Hi,

On Wed, 24 Feb 2010, Ilan wrote:

Well, I guess it would be easier if you used another webserver than
github.com for your updating. Because the most intuitive way to update
.jar files on a webserver is to actually FTP the files there.

The Github.com crew did some cute stuff (Scott Chacon is a very
enterprisey guy, he even wrote a git daemon for the iPhone), but it is
most likely a bit too geeky to be useful here.

Ciao,
Johannes

Ilan

unread,
Mar 1, 2010, 9:04:11 AM3/1/10
to Fiji-devel
Johannes,
I've done everything I can think of with your Plugins_Updater and the
getLastModified will always return zero on git.
I asked Git for help but there is no one readily available who seems
to know the answer.
I can see where the problem is, but I don't know what the solution is.
The information is at
http://github.com/ilan/fijiPlugins/tree/master/Read_BI_Studies
but when I call getLastModified the "tree" changes to "blob" and the
blob doesn't have the file date, and thus it returns zero.

I will ask Beth Israel Hospital for a web entry on their site where I
can ftp the jar files.

I can easily solve the problem by using a server behind the firewall,
but the whole idea is to have it open to the world and not just Beth
Israel.

BTW, for something done at 1-2AM, it is really quite impressive. All I
found was a single typo.

Ilan

Reply all
Reply to author
Forward
0 new messages