Re: [josm-dev] slippymap plugin not wanting to make render requests

2008-08-26 Thread Robin Rattay
Dirk Stöcker schrieb:
 a) Temporary filename is final name+.tmp.
 b) Do the move as is done now. When move fails, leave the tmp file.
 c) On start check if there is a temp file and move it when possible.
 If not, inform the user.

I've done it over.

I called the new plugins files *.new instead of *.tmp, because latter
sounds as if it were something you could delete after the programm has
quit, which it isn't.

I also cleaned up the use of hardcoded slashes in file paths in some
places using File.separator instead.

I wasn't sure what to write when informing the user that the moving
failed, so if you have any ideas, please change that.

Robin
Index: src/org/openstreetmap/josm/plugins/PluginInformation.java
===
--- src/org/openstreetmap/josm/plugins/PluginInformation.java   (revision 868)
+++ src/org/openstreetmap/josm/plugins/PluginInformation.java   (working copy)
@@ -195,7 +195,7 @@
 CollectionString locations = getPluginLocations();
 
for (String s : locations) {
-   File pluginFile = new File(s+/+pluginName+.jar);
+   File pluginFile = new File(s, pluginName + .jar);
if (pluginFile.exists()) {
PluginInformation info = new 
PluginInformation(pluginFile);
return info;
Index: src/org/openstreetmap/josm/plugins/PluginDownloader.java
===
--- src/org/openstreetmap/josm/plugins/PluginDownloader.java(revision 868)
+++ src/org/openstreetmap/josm/plugins/PluginDownloader.java(working copy)
@@ -12,6 +12,7 @@
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.FileWriter;
+import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -53,14 +54,17 @@
}
 
@Override protected void realRun() throws SAXException, 
IOException {
+   File pluginDir = Main.pref.getPluginsDirFile();
+   if (!pluginDir.exists())
+   pluginDir.mkdirs();
for (PluginDescription d : toUpdate) {
-   File tempFile = new 
File(Main.pref.getPreferencesDir()+temp.jar);
-   if (download(d.resource, tempFile)) {
-   tempFile.renameTo(new 
File(Main.pref.getPreferencesDir()+plugins/+d.name+.jar));
+   File pluginFile = new File(pluginDir, d.name + 
.jar.new);
+   if (download(d.resource, pluginFile))
count++;
-   } else
+   else
errors += d.name + \n;
}
+   PluginDownloader.moveUpdatedPlugins();
}
}
 
@@ -78,7 +82,9 @@
txt = readWiki(r);
r.close();
new 
File(Main.pref.getPreferencesDir()+plugins).mkdir();
-   FileWriter out = new 
FileWriter(Main.pref.getPreferencesDir()+plugins/+count+-site-+site.replaceAll([/:
 |], _)+.xml);
+   FileWriter out = new FileWriter(new 
File(Main.pref
+   .getPluginsDirFile(), count + -site-
+   + site.replaceAll([/: |], _) 
+ .xml));
out.append(txt);
out.close();
count++;
@@ -122,7 +128,7 @@
}
 
public static boolean downloadPlugin(PluginDescription pd) {
-   File file = new 
File(Main.pref.getPreferencesDir()+plugins/+pd.name+.jar);
+   File file = new File(Main.pref.getPluginsDirFile(), pd.name + 
.jar);
if (!download(pd.resource, file)) {
JOptionPane.showMessageDialog(Main.parent, tr(Could 
not download plugin: {0} from {1}, pd.name, pd.resource));
} else {
@@ -162,4 +168,21 @@
public static void update(CollectionPluginDescription update) {
Main.worker.execute(new UpdateTask(update));
}
+   
+   public static boolean moveUpdatedPlugins() {
+   File pluginDir = Main.pref.getPluginsDirFile();
+   boolean ok = true;  
+   if (pluginDir.exists()  pluginDir.isDirectory()) {
+   final File[] files = pluginDir.listFiles(new 
FilenameFilter() {
+   public boolean accept(File dir, String name) {
+   return name.endsWith(.new);
+}});
+   for (File updatedPlugin 

Re: [josm-dev] slippymap plugin not wanting to make render requests

2008-08-26 Thread Dirk Stöcker

On Tue, 26 Aug 2008, Robin Rattay wrote:


Dirk Stöcker schrieb:

a) Temporary filename is final name+.tmp.
b) Do the move as is done now. When move fails, leave the tmp file.
c) On start check if there is a temp file and move it when possible.
If not, inform the user.


I've done it over.

I called the new plugins files *.new instead of *.tmp, because latter
sounds as if it were something you could delete after the programm has
quit, which it isn't.

I also cleaned up the use of hardcoded slashes in file paths in some
places using File.separator instead.

I wasn't sure what to write when informing the user that the moving
failed, so if you have any ideas, please change that.


Applied. Also added some better version display in dialog :-)

Ciao
--
http://www.dstoecker.eu/ (PGP key available)___
josm-dev mailing list
josm-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/josm-dev


Re: [josm-dev] slippymap plugin not wanting to make render requests

2008-08-25 Thread Maarten Deen
Frederik Ramm wrote:

 Maarten Deen wrote:
 I've got the slippymap plugin which works fine when downloading tiles, but 
 for 
 every tile that I want to make a render request for it displays error 
 requesting update in the tile.
 
 Is this a general problem in the plugin or is there anything I can do to fix 
 this?
 
 The submit URL is hard-coded and it had changed in the mean time. 
 Download a new version of the slippymap plugin and try again!

The automatic update from within JOSM doesn't work. It keeps saying there is a 
new version of the slippymap plugin and appears to download it, but it isn't 
updated.
I've downloaded it manually and JOSM still says there is a new version of the 
slippymap plugin. In JOSM it says it's version 7821.

After I downloaded it manually, the render request works. Thanks.

Maarten

___
josm-dev mailing list
[EMAIL PROTECTED]
http://lists.openstreetmap.org/listinfo/josm-dev


Re: [josm-dev] slippymap plugin not wanting to make render requests

2008-08-25 Thread Dirk Stöcker
On Mon, 25 Aug 2008, Maarten Deen wrote:

 The automatic update from within JOSM doesn't work. It keeps saying there is a
 new version of the slippymap plugin and appears to download it, but it isn't
 updated.
 I've downloaded it manually and JOSM still says there is a new version of the
 slippymap plugin. In JOSM it says it's version 7821.

 After I downloaded it manually, the render request works. Thanks.

You first need to update the list. Recent plugins hace something above 
1 as revision.

Ciao
-- 
http://www.dstoecker.eu/ (PGP key available)

___
josm-dev mailing list
josm-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/josm-dev


Re: [josm-dev] slippymap plugin not wanting to make render requests

2008-08-25 Thread Robin Rattay
Dirk Stöcker schrieb:
 On Mon, 25 Aug 2008, Robin Rattay wrote:
 Has this actually worked at all or only on specific environments? It
 seems that the update mechanism needs to be changed.
 
 Works on Linux, but probably you're right and it wont work on Windows due 
 to the strange Windows file locking. Anyway I seldom use Windows, so 
 that's not my problem :-)
 
 Maybe a solution would be to store files with an intermediate name in 
 case of copy failure and copy these on restart before plugins get loaded.

Here you go...

Robin
Index: src/org/openstreetmap/josm/plugins/PluginDownloader.java
===
--- src/org/openstreetmap/josm/plugins/PluginDownloader.java(revision 868)
+++ src/org/openstreetmap/josm/plugins/PluginDownloader.java(working copy)
@@ -53,12 +53,14 @@
}
 
@Override protected void realRun() throws SAXException, 
IOException {
+   File updatedPluginDir = new 
File(Main.pref.getPreferencesDir() + plugin-updates);
+   if (!updatedPluginDir.exists())
+   updatedPluginDir.mkdirs();
for (PluginDescription d : toUpdate) {
-   File tempFile = new 
File(Main.pref.getPreferencesDir()+temp.jar);
-   if (download(d.resource, tempFile)) {
-   tempFile.renameTo(new 
File(Main.pref.getPreferencesDir()+plugins/+d.name+.jar));
+   File pluginFile = new File(updatedPluginDir, 
d.name + .jar);
+   if (download(d.resource, pluginFile))
count++;
-   } else
+   else
errors += d.name + \n;
}
}
Index: src/org/openstreetmap/josm/gui/MainApplication.java
===
--- src/org/openstreetmap/josm/gui/MainApplication.java (revision 868)
+++ src/org/openstreetmap/josm/gui/MainApplication.java (working copy)
@@ -118,6 +118,17 @@
Main.pref.save();
}
 
+   // Copy updated plugins to proper directory
+   File updatedPluginDir = new File(Main.pref.getPreferencesDir() 
+ plugin-updates/);
+   File pluginDir = new File(Main.pref.getPreferencesDir() + 
plugins/);
+   if (updatedPluginDir.exists()  
updatedPluginDir.isDirectory()) {
+   for (File updatedPlugin : updatedPluginDir.listFiles()) 
{
+   File plugin = new File(pluginDir, 
updatedPlugin.getName());
+   plugin.delete();
+   updatedPlugin.renameTo(plugin);
+   }
+   }
+
// load the early plugins
Main.loadPlugins(true);
 

___
josm-dev mailing list
josm-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/josm-dev


Re: [josm-dev] slippymap plugin not wanting to make render requests

2008-08-25 Thread Dirk Stöcker

On Mon, 25 Aug 2008, Robin Rattay wrote:


Dirk Stöcker schrieb:

On Mon, 25 Aug 2008, Robin Rattay wrote:

Has this actually worked at all or only on specific environments? It
seems that the update mechanism needs to be changed.


Works on Linux, but probably you're right and it wont work on Windows due
to the strange Windows file locking. Anyway I seldom use Windows, so
that's not my problem :-)

Maybe a solution would be to store files with an intermediate name in
case of copy failure and copy these on restart before plugins get loaded.


Here you go...


Nah, that always creates a usually useless directory and also always 
creates the temporaryfile-on-start-copy. Both is not useful on non-Windows 
systems.


Better:
a) Temporary filename is final name+.tmp.
b) Do the move as is done now. When move fails, leave the tmp file.
c) On start check if there is a temp file and move it when possible.
   If not, inform the user.

Ciao
--
http://www.dstoecker.eu/ (PGP key available)___
josm-dev mailing list
josm-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/josm-dev


Re: [josm-dev] slippymap plugin not wanting to make render requests

2008-08-25 Thread Robin Rattay
Dirk Stöcker schrieb:
 Nah, that always creates a usually useless directory 

Ok.

 and also always 
 creates the temporaryfile-on-start-copy. Both is not useful on non-Windows 
 systems.

New plugins can't be used until the next restart anyway, so IMHO it
makes no difference when the files are copied.

I'll change it tomorrow. I'd like to change the building of the plugin
path so that it doesn't use hardcoded slashes anyway.

Robin

___
josm-dev mailing list
josm-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/josm-dev


Re: [josm-dev] slippymap plugin not wanting to make render requests

2008-08-25 Thread Maarten Deen
Dirk Stöcker wrote:
 On Mon, 25 Aug 2008, Maarten Deen wrote:
 
 The automatic update from within JOSM doesn't work. It keeps saying there is 
 a
 new version of the slippymap plugin and appears to download it, but it isn't
 updated.
 I've downloaded it manually and JOSM still says there is a new version of the
 slippymap plugin. In JOSM it says it's version 7821.

 After I downloaded it manually, the render request works. Thanks.
 
 You first need to update the list. Recent plugins hace something above 
 1 as revision.

Ah, ok. Didn't catch that one.

Maarten

___
josm-dev mailing list
josm-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/josm-dev


Re: [josm-dev] slippymap plugin not wanting to make render requests

2008-08-24 Thread Frederik Ramm
Hi,

Maarten Deen wrote:
 I've got the slippymap plugin which works fine when downloading tiles, but 
 for 
 every tile that I want to make a render request for it displays error 
 requesting update in the tile.
 
 Is this a general problem in the plugin or is there anything I can do to fix 
 this?

The submit URL is hard-coded and it had changed in the mean time. 
Download a new version of the slippymap plugin and try again!

Cc to spaetz: Could I get back the old one-line, text-only tile status 
call (like http://tah.openstreetmap.org/Browse/details/tile/2/2/1/ but 
with return data in a machine-readable way)? The slippy map plugin has 
an option for downloading and displaying these if desired.

Bye
Frederik

-- 
Frederik Ramm  ##  eMail [EMAIL PROTECTED]  ##  N49°00'09 E008°23'33

___
josm-dev mailing list
josm-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/josm-dev