[tuxdroid-svn] r5183 - in software_suite_v3/smart-core/smart-server/trunk: . util/applicationserve
Status: Beta
Brought to you by:
ks156
|
From: remi <c2m...@c2...> - 2009-07-28 08:59:04
|
Author: remi
Date: 2009-07-28 10:58:49 +0200 (Tue, 28 Jul 2009)
New Revision: 5183
Modified:
software_suite_v3/smart-core/smart-server/trunk/TDSAutoUpdater.py
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetOnline.py
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetsOnlineContainer.py
software_suite_v3/smart-core/smart-server/trunk/util/misc/URLTools.py
Log:
* Check if the kysoh ftp server is ok.
Modified: software_suite_v3/smart-core/smart-server/trunk/TDSAutoUpdater.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/TDSAutoUpdater.py 2009-07-28 08:44:56 UTC (rev 5182)
+++ software_suite_v3/smart-core/smart-server/trunk/TDSAutoUpdater.py 2009-07-28 08:58:49 UTC (rev 5183)
@@ -197,7 +197,7 @@
"""Check for updates.
"""
# Wait for connection to internet enabled
- while not URLTools.URLCheckConnection("http://ftp.kysoh.com"):
+ while not URLTools.URLCheck("http://ftp.kysoh.com", 1.0):
time.sleep(1.0)
self.__logger.logInfo("Internet connection is detected")
# Download conf files
@@ -244,4 +244,4 @@
else:
self.__logger.logInfo("\tCan't download the installer")
else:
- self.__logger.logInfo("\tYour version up to date")
+ self.__logger.logInfo("\tYour version is up to date")
Modified: software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetOnline.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetOnline.py 2009-07-28 08:44:56 UTC (rev 5182)
+++ software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetOnline.py 2009-07-28 08:58:49 UTC (rev 5183)
@@ -3,7 +3,8 @@
# Distributed under the terms of the GNU General Public License
# http://www.gnu.org/copyleft/gpl.html
-ONLINE_GADGETS_BASE_URL = "http://ftp.kysoh.com/ssv3/content/gadgets/"
+ONLINE_FTP_URL = "http://ftp.kysoh.com"
+ONLINE_GADGETS_BASE_URL = ONLINE_FTP_URL + "/ssv3/content/gadgets/"
# ------------------------------------------------------------------------------
# Gadget online class.
Modified: software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetsOnlineContainer.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetsOnlineContainer.py 2009-07-28 08:44:56 UTC (rev 5182)
+++ software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetsOnlineContainer.py 2009-07-28 08:58:49 UTC (rev 5183)
@@ -10,6 +10,7 @@
from util.misc import DirectoriesAndFilesTools
from util.misc import URLTools
from GadgetOnline import GadgetOnline
+from GadgetOnline import ONLINE_FTP_URL
from GadgetOnline import ONLINE_GADGETS_BASE_URL
# ------------------------------------------------------------------------------
@@ -42,6 +43,10 @@
if self.__gadgetsCount != 0:
self.__mutex.release()
return
+ # Check ftp server
+ if not URLTools.URLCheck(ONLINE_FTP_URL, 1.0):
+ self.__mutex.release()
+ return
self.__gadgetsOnline = []
self.__gadgetsCount = 0
gadgetsXmlFile = os.path.join(DirectoriesAndFilesTools.GetOSTMPDir(),
Modified: software_suite_v3/smart-core/smart-server/trunk/util/misc/URLTools.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/util/misc/URLTools.py 2009-07-28 08:44:56 UTC (rev 5182)
+++ software_suite_v3/smart-core/smart-server/trunk/util/misc/URLTools.py 2009-07-28 08:58:49 UTC (rev 5183)
@@ -51,6 +51,36 @@
return result
# ------------------------------------------------------------------------------
+# Check connection to an url.
+# ------------------------------------------------------------------------------
+def URLCheck(urlToCheck, timeout = 5.0):
+ """Check connection to an url.
+ @param urlToCheck: Check this url.
+ @param timeout: Connection timeout.
+ @return: The connection result.
+ """
+ # Save the old default connection timeout
+ old_timeout = socket.getdefaulttimeout()
+ # Set the default connection timeout
+ socket.setdefaulttimeout(timeout)
+ # Initialize the result dictionary
+ result = True
+ # Attempt to connect to the url
+ try:
+ f = urllib2.urlopen(urlToCheck)
+ f.close()
+ except urllib2.HTTPError, exc:
+ result = False
+ except urllib2.URLError, exc:
+ result = False
+ except:
+ result = False
+ # Restore the old default connection timeout
+ socket.setdefaulttimeout(old_timeout)
+ # Return the result
+ return result
+
+# ------------------------------------------------------------------------------
# Retrieve informations from url.
# ------------------------------------------------------------------------------
def URLGetInfos(url, timeout = 5.0):
|