Thread: [Mathlib-commitlog] SF.net SVN: mathlib:[442] JMathLib/trunk/src/jmathlib/toolbox/jmathlib/ system/
Status: Beta
Brought to you by:
st_mueller
|
From: <st_...@us...> - 2008-11-16 17:53:34
|
Revision: 442
http://mathlib.svn.sourceforge.net/mathlib/?rev=442&view=rev
Author: st_mueller
Date: 2008-11-16 17:53:27 +0000 (Sun, 16 Nov 2008)
Log Message:
-----------
load files from server
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java
Modified: JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java 2008-08-23 08:22:22 UTC (rev 441)
+++ JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java 2008-11-16 17:53:27 UTC (rev 442)
@@ -1,5 +1,8 @@
package jmathlib.toolbox.jmathlib.system;
+import java.io.*;
+import java.net.*;
+
import jmathlib.core.tokens.*;
import jmathlib.core.functions.ExternalFunction;
@@ -9,12 +12,134 @@
public OperandToken evaluate(Token[] operands)
{
- String s = "";
- String lineFile = "";;
+ String lineFile = "";
+ URL url = null;
- getInterpreter().displayText("UPDATING JMathLib");
+ getInterpreter().displayText("UPDATING JMathLib\n");
+
+ // get update site and local version of jmathlib
+ String updateSiteS = getInterpreter().prefs.getLocalProperty("update.site.primary");
+ String localVersionS = getInterpreter().prefs.getLocalProperty("jmathlib.version");
+ localVersionS = localVersionS.replaceAll("/", ".");
+ String updateVersionS = localVersionS;
+ getInterpreter().displayText("update site: "+updateSiteS);
+ getInterpreter().displayText("current version: "+localVersionS);
+
+ // first check to which version an update is possible
+ getInterpreter().displayText("Checking to which version an update is possible");
+ try {
+ url = new URL(updateSiteS+"updates/?jmathlib_version="+localVersionS);
+ BufferedReader inR = new BufferedReader(new InputStreamReader(url.openStream()));
+ String s = "";
+ while ((s = inR.readLine()) != null )
+ {
+ //getInterpreter().displayText("version"+s);
+ if (s.startsWith("update.toversion="))
+ {
+ // read a file from the server and place it on the local disc
+ updateVersionS = s.substring(17).trim();
+ getInterpreter().displayText("updating to version >"+updateVersionS+"< \n");
+ }
+ }
+ }
+ catch (Exception e) {
+ throwMathLibException("update: could not receive version for update");
+ }
+
+
+
+
+ // download new files from server
+ updateSiteS += "updates/jmathlib_" + updateVersionS + "/";
+
+ //getInterpreter().displayText("updating path: "+updateSiteS);
+ try
+ {
+ url = new URL(updateSiteS);
+ }
+ catch (Exception e)
+ {
+ throwMathLibException("update: malformed url");
+ }
+ BufferedReader inR=null;
+ try
+ {
+ inR = new BufferedReader(new InputStreamReader(url.openStream()));
+ String s = inR.readLine();
+ while (s != null )
+ {
+ //getInterpreter().displayText("update "+s);
+
+ if (s.startsWith("file"))
+ {
+ // read a file from the server and place it on the local disc
+ String fileS = s.substring(5).trim();
+ getInterpreter().displayText("new file: >"+fileS+"<");
+
+ // open URL to file on update server
+ URL fileURL = new URL(updateSiteS+fileS);
+ InputStream in = fileURL.openStream();
+
+ // open file on local disc
+ File file = new File(getWorkingDirectory(),fileS);
+ OutputStream out = new FileOutputStream(file);
+
+ byte[] cbuf = new byte[4096];
+ int len;
+ while ((len = in.read(cbuf)) != -1)
+ {
+ out.write(cbuf,0,len);
+ }
+
+ in.close();
+ out.close();
+
+
+ }
+ else if (s.startsWith("dir"))
+ {
+ // create a directory on the local disc
+ String dirS = s.substring(4).trim();
+ getInterpreter().displayText("new directory: >"+dirS+"<");
+ File file = new File(getWorkingDirectory(),dirS);
+ file.mkdir();
+
+ }
+ else if (s.startsWith("del"))
+ {
+ // delete a file/directory on the local disc
+ String delS = s.substring(4).trim();
+ getInterpreter().displayText("delete file/dir: >"+delS+"<");
+ File file = new File(getWorkingDirectory(),delS);
+ file.delete();
+ }
+ else if (s.startsWith("prop"))
+ {
+ // delete a file/directory on the local disc
+ String propS = s.substring(5).trim();
+ getInterpreter().displayText("new property: >"+propS+"<");
+ String[] p = propS.split("=");
+ getInterpreter().prefs.setLocalProperty(p[0],p[1]);
+ }
+ else
+ {
+ // empty line or unknown command or comment
+ }
+
+
+ // read next line from server
+ s = inR.readLine();
+ }
+
+ }
+ catch (Exception e)
+ {
+ throwMathLibException("update: open or reading stream");
+ }
+
+
return null;
}
}
@@ -31,7 +156,10 @@
update
</programlisting>
@NOTES
-.
+The script first checks the webserver in order to determine, if
+it is possible to update the current version and if this which
+version is next.<br>
+It also updates local properties of JMathlib
@SEE
checkforupdates
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2008-11-19 20:13:23
|
Revision: 455
http://mathlib.svn.sourceforge.net/mathlib/?rev=455&view=rev
Author: st_mueller
Date: 2008-11-19 20:13:16 +0000 (Wed, 19 Nov 2008)
Log Message:
-----------
new comments
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java
Modified: JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java 2008-11-19 20:09:35 UTC (rev 454)
+++ JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java 2008-11-19 20:13:16 UTC (rev 455)
@@ -157,9 +157,9 @@
</programlisting>
@NOTES
The script first checks the webserver in order to determine, if
-it is possible to update the current version and if this which
-version is next.<br>
-It also updates local properties of JMathlib
+it is possible to update the current version and if yes which
+version is next.
+It also updates local properties of JMathlib.
@SEE
checkforupdates
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2008-11-23 19:08:51
|
Revision: 496
http://mathlib.svn.sourceforge.net/mathlib/?rev=496&view=rev
Author: st_mueller
Date: 2008-11-23 19:08:41 +0000 (Sun, 23 Nov 2008)
Log Message:
-----------
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java
Modified: JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java 2008-11-23 11:29:10 UTC (rev 495)
+++ JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java 2008-11-23 19:08:41 UTC (rev 496)
@@ -39,6 +39,14 @@
{
// read a file from the server and place it on the local disc
updateVersionS = s.substring(17).trim();
+
+ // maybe no update is available
+ if (updateVersionS.equals("no_update_available"))
+ {
+ getInterpreter().displayText("No update available available");
+ return null;
+ }
+
getInterpreter().displayText("updating to version >"+updateVersionS+"< \n");
}
}
@@ -49,7 +57,6 @@
-
// download new files from server
updateSiteS += "updates/jmathlib_" + updateVersionS + "/";
@@ -151,7 +158,7 @@
update
@DOC
updates JMathLib over the web
-@EXAMPLE
+@EXAMPLES
<programlisting>
update
</programlisting>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2008-11-29 16:29:43
|
Revision: 499
http://mathlib.svn.sourceforge.net/mathlib/?rev=499&view=rev
Author: st_mueller
Date: 2008-11-29 16:29:33 +0000 (Sat, 29 Nov 2008)
Log Message:
-----------
bette update
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java
Modified: JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java 2008-11-23 19:09:59 UTC (rev 498)
+++ JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java 2008-11-29 16:29:33 UTC (rev 499)
@@ -2,6 +2,7 @@
import java.io.*;
import java.net.*;
+import java.util.Properties;
import jmathlib.core.tokens.*;
import jmathlib.core.functions.ExternalFunction;
@@ -13,54 +14,60 @@
{
String lineFile = "";
- URL url = null;
getInterpreter().displayText("UPDATING JMathLib\n");
- // get update site and local version of jmathlib
+ // get update site of jmathlib
String updateSiteS = getInterpreter().prefs.getLocalProperty("update.site.primary");
+ getInterpreter().displayText("update site: "+updateSiteS);
+
+ // get local version of jmathlib
String localVersionS = getInterpreter().prefs.getLocalProperty("jmathlib.version");
localVersionS = localVersionS.replaceAll("/", ".");
- String updateVersionS = localVersionS;
- getInterpreter().displayText("update site: "+updateSiteS);
getInterpreter().displayText("current version: "+localVersionS);
// first check to which version an update is possible
getInterpreter().displayText("Checking to which version an update is possible");
- try {
+
+
+ // url of the update site including the request for the version
+ // to update to
+ URL url = null;
+ try
+ {
url = new URL(updateSiteS+"updates/?jmathlib_version="+localVersionS);
- BufferedReader inR = new BufferedReader(new InputStreamReader(url.openStream()));
- String s = "";
- while ((s = inR.readLine()) != null )
- {
- //getInterpreter().displayText("version"+s);
- if (s.startsWith("update.toversion="))
- {
- // read a file from the server and place it on the local disc
- updateVersionS = s.substring(17).trim();
-
- // maybe no update is available
- if (updateVersionS.equals("no_update_available"))
- {
- getInterpreter().displayText("No update available available");
- return null;
- }
-
- getInterpreter().displayText("updating to version >"+updateVersionS+"< \n");
- }
- }
}
- catch (Exception e) {
- throwMathLibException("update: could not receive version for update");
+ catch (Exception e)
+ {
+ throwMathLibException("update: malformed url for getting update version");
}
-
+ // load information from the update server
+ Properties props = new Properties();
+ try
+ {
+ props.load(url.openStream() );
+ }
+ catch (Exception e)
+ {
+ System.out.println("updates: Properties error");
+ }
+
+ // Check return properties for "update-to-version"
+ // Update site could send a lot of properties
+ String updateVersionS = props.getProperty("update.toversion");
+ if (updateVersionS.equals("no_update_available"))
+ {
+ getInterpreter().displayText("No update available available");
+ return null;
+ }
+ getInterpreter().displayText("updating to version >"+updateVersionS+"< \n");
+
+
// download new files from server
updateSiteS += "updates/jmathlib_" + updateVersionS + "/";
-
- //getInterpreter().displayText("updating path: "+updateSiteS);
try
{
url = new URL(updateSiteS);
@@ -70,12 +77,14 @@
throwMathLibException("update: malformed url");
}
- BufferedReader inR=null;
+ BufferedReader inR = null;
try
{
inR = new BufferedReader(new InputStreamReader(url.openStream()));
- String s = inR.readLine();
- while (s != null )
+ String s = null;
+
+ // read next line from server
+ while ((s = inR.readLine()) != null )
{
//getInterpreter().displayText("update "+s);
@@ -119,7 +128,7 @@
// delete a file/directory on the local disc
String delS = s.substring(4).trim();
getInterpreter().displayText("delete file/dir: >"+delS+"<");
- File file = new File(getWorkingDirectory(),delS);
+ File file = new File(getWorkingDirectory(),delS);
file.delete();
}
else if (s.startsWith("prop"))
@@ -127,7 +136,7 @@
// delete a file/directory on the local disc
String propS = s.substring(5).trim();
getInterpreter().displayText("new property: >"+propS+"<");
- String[] p = propS.split("=");
+ String[] p = propS.split("=");
getInterpreter().prefs.setLocalProperty(p[0],p[1]);
}
else
@@ -136,8 +145,6 @@
}
- // read next line from server
- s = inR.readLine();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2008-11-30 16:21:32
|
Revision: 508
http://mathlib.svn.sourceforge.net/mathlib/?rev=508&view=rev
Author: st_mueller
Date: 2008-11-30 16:21:29 +0000 (Sun, 30 Nov 2008)
Log Message:
-----------
better handling of updates
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java
Modified: JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java 2008-11-30 16:21:05 UTC (rev 507)
+++ JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java 2008-11-30 16:21:29 UTC (rev 508)
@@ -63,6 +63,16 @@
getInterpreter().displayText("No update available available");
return null;
}
+
+ if (updateVersionS.equals("full_download_required"))
+ {
+ getInterpreter().displayText("\n");
+ getInterpreter().displayText("Full download required in order to update!");
+ getInterpreter().displayText("Please visit www.jmathlib.de for details.");
+ getInterpreter().displayText("\n");
+ return null;
+ }
+
getInterpreter().displayText("updating to version >"+updateVersionS+"< \n");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2008-11-30 17:12:56
|
Revision: 516
http://mathlib.svn.sourceforge.net/mathlib/?rev=516&view=rev
Author: st_mueller
Date: 2008-11-30 17:12:54 +0000 (Sun, 30 Nov 2008)
Log Message:
-----------
bugfix in comment
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java
Modified: JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java 2008-11-30 17:04:30 UTC (rev 515)
+++ JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java 2008-11-30 17:12:54 UTC (rev 516)
@@ -60,7 +60,7 @@
String updateVersionS = props.getProperty("update.toversion");
if (updateVersionS.equals("no_update_available"))
{
- getInterpreter().displayText("No update available available");
+ getInterpreter().displayText("No update available right now.");
return null;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2008-11-30 18:44:41
|
Revision: 519
http://mathlib.svn.sourceforge.net/mathlib/?rev=519&view=rev
Author: st_mueller
Date: 2008-11-30 18:44:38 +0000 (Sun, 30 Nov 2008)
Log Message:
-----------
better exception handling
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java
Modified: JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java 2008-11-30 17:16:25 UTC (rev 518)
+++ JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/update.java 2008-11-30 18:44:38 UTC (rev 519)
@@ -14,7 +14,8 @@
{
String lineFile = "";
-
+ boolean successB = true;
+
getInterpreter().displayText("UPDATING JMathLib\n");
// get update site of jmathlib
@@ -41,6 +42,7 @@
catch (Exception e)
{
throwMathLibException("update: malformed url for getting update version");
+ successB = false;
}
// load information from the update server
@@ -52,6 +54,7 @@
catch (Exception e)
{
System.out.println("updates: Properties error");
+ successB = false;
}
@@ -85,6 +88,7 @@
catch (Exception e)
{
throwMathLibException("update: malformed url");
+ successB = false;
}
BufferedReader inR = null;
@@ -105,41 +109,64 @@
getInterpreter().displayText("new file: >"+fileS+"<");
// open URL to file on update server
- URL fileURL = new URL(updateSiteS+fileS);
- InputStream in = fileURL.openStream();
-
- // open file on local disc
- File file = new File(getWorkingDirectory(),fileS);
- OutputStream out = new FileOutputStream(file);
-
- byte[] cbuf = new byte[4096];
- int len;
- while ((len = in.read(cbuf)) != -1)
+ try
{
- out.write(cbuf,0,len);
+ URL fileURL = new URL(updateSiteS+fileS);
+ InputStream in = fileURL.openStream();
+
+ // open file on local disc
+ File file = new File(getWorkingDirectory(),fileS);
+ OutputStream out = new FileOutputStream(file);
+
+ byte[] cbuf = new byte[4096];
+ int len;
+ while ((len = in.read(cbuf)) != -1)
+ {
+ out.write(cbuf,0,len);
+ }
+
+ in.close();
+ out.close();
}
+ catch (Exception e)
+ {
+ successB = false;
+ getInterpreter().displayText("update: problem downloading "+fileS);
+ }
- in.close();
- out.close();
-
-
}
else if (s.startsWith("dir"))
{
// create a directory on the local disc
String dirS = s.substring(4).trim();
getInterpreter().displayText("new directory: >"+dirS+"<");
- File file = new File(getWorkingDirectory(),dirS);
- file.mkdir();
-
+ try
+ {
+ File file = new File(getWorkingDirectory(),dirS);
+ file.mkdir();
+ }
+ catch (Exception e)
+ {
+ successB = false;
+ getInterpreter().displayText("update: problem creating directory "+dirS);
+ }
+
}
else if (s.startsWith("del"))
{
// delete a file/directory on the local disc
String delS = s.substring(4).trim();
getInterpreter().displayText("delete file/dir: >"+delS+"<");
- File file = new File(getWorkingDirectory(),delS);
- file.delete();
+ try
+ {
+ File file = new File(getWorkingDirectory(),delS);
+ file.delete();
+ }
+ catch (Exception e)
+ {
+ successB = false;
+ getInterpreter().displayText("update: problem deleting "+delS);
+ }
}
else if (s.startsWith("prop"))
{
@@ -154,6 +181,9 @@
// empty line or unknown command or comment
}
+ // in case something went wrong terminate
+ if (!successB)
+ break;
}
@@ -164,6 +194,10 @@
}
+ // notifiy user
+ if (!successB)
+ getInterpreter().displayText("\n Update was not successful. Repeat again later on or inform the admin.");
+
return null;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|