[tuxdroid-svn] r5078 - software_suite_v3/smart-core/smart-server/trunk
Status: Beta
Brought to you by:
ks156
|
From: remi <c2m...@c2...> - 2009-07-08 07:20:51
|
Author: remi
Date: 2009-07-08 09:20:44 +0200 (Wed, 08 Jul 2009)
New Revision: 5078
Modified:
software_suite_v3/smart-core/smart-server/trunk/TDSAutoUpdater.py
Log:
* Added logger in the auto-updater
Modified: software_suite_v3/smart-core/smart-server/trunk/TDSAutoUpdater.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/TDSAutoUpdater.py 2009-07-08 06:40:46 UTC (rev 5077)
+++ software_suite_v3/smart-core/smart-server/trunk/TDSAutoUpdater.py 2009-07-08 07:20:44 UTC (rev 5078)
@@ -21,6 +21,7 @@
from util.misc import DirectoriesAndFilesTools
from util.misc import URLTools
+from util.logger import *
DIST_STATE = "beta"
@@ -65,6 +66,15 @@
"""
if not os.path.isdir(TDS_UPDATES_PATH):
DirectoriesAndFilesTools.MKDirs(TDS_UPDATES_PATH)
+ self.__logger = SimpleLogger("auto_updater.log")
+ self.__logger.setTarget(TDS_CONF_LOG_TARGET)
+ self.__logger.setLevel(TDS_CONF_LOG_LEVEL)
+ self.__logger.resetLog()
+ self.__logger.logInfo("-----------------------------------------------")
+ self.__logger.logInfo("TDSAutoUpdater%s" % __version__)
+ self.__logger.logInfo("Author : %s" % __author__)
+ self.__logger.logInfo("Licence : %s" % __licence__)
+ self.__logger.logInfo("-----------------------------------------------")
# Write default CVER files
self.__writeDefaultCVerFiles()
@@ -121,6 +131,10 @@
try:
confDict = eval(f.read())
except:
+ self.__logger.logError("Conf file is corrupted [%s]" % UPDATES_PARTS[partName][PART_CONF_DEST])
+ f.close()
+ DirectoriesAndFilesTools.RMFile(destConf)
+ DirectoriesAndFilesTools.RMFile(cverFile)
continue
f.close()
archName = "win32"
@@ -145,9 +159,9 @@
"/S",
"/START=true",
]
- print "Install : [%s](%s)" % (installerName, currentVersion)
+ self.__logger.logInfo("Installation started [%s] (%s)" % (installerName, currentVersion))
process = subprocess.Popen(cmd)
- print "Installed : [%s](%s)" % (installerName, currentVersion)
+ self.__logger.logInfo("Installation finished")
else:
pass
@@ -157,6 +171,7 @@
# Wait for connection to internet enabled
while not URLTools.URLCheckConnection():
time.sleep(1.0)
+ self.__logger.logInfo("Internet connection is detected")
# Download conf files
for partName in PART_NAMES:
confUrl = UPDATES_PARTS[partName][PART_CONF_SRC_URL]
@@ -165,31 +180,40 @@
try:
confDict = eval(confStr)
except:
+ self.__logger.logError("Conf file is corrupted [%s]" % confUrl)
continue
archName = "win32"
if os.name == "nt":
if not confDict.has_key('win32'):
+ self.__logger.logWarning("Conf file have no information for your system [%s]" % confUrl)
continue
archName = "win32"
else:
if not confDict.has_key('unix'):
+ self.__logger.logWarning("Conf file have no information for your system [%s]" % confUrl)
continue
archName = "unix"
currentVersion = self.__getCurrentPartVersion(partName)
stateVersion = confDict[archName]["version"]
- print "[%s] : CV = [%s] SV = [%s]" % (partName, currentVersion,
- stateVersion)
+ self.__logger.logInfo("Versions for [%s] :" % partName)
+ self.__logger.logInfo("\tCurrent version : %s" % currentVersion)
+ self.__logger.logInfo("\tServer version : %s" % stateVersion)
if stateVersion != currentVersion:
+ self.__logger.logInfo("\tNew version available")
installerUrl = confDict[archName]["url"]
installerDest = os.path.join(TDS_UPDATES_PATH,
confDict[archName]["fileName"])
- print "Download installer : [%s]" % confDict[archName]["fileName"]
+ self.__logger.logInfo("\tStart to download the new version installer")
+ self.__logger.logInfo("\tFrom [%s]" % installerUrl)
+ self.__logger.logInfo("\tTo [%s]" % installerDest)
if URLTools.URLDownloadToFile(installerUrl, installerDest):
- print "Installer downloaded : [%s]" % confDict[archName]["fileName"]
+ self.__logger.logInfo("\tNew installer is successfully downloaded")
destConf = os.path.join(TDS_UPDATES_PATH,
UPDATES_PARTS[partName][PART_CONF_DEST])
f = open(destConf, "w")
f.write(str(confDict))
f.close()
else:
- print "Can't download installer : [%s]" % confDict[archName]["fileName"]
+ self.__logger.logInfo("\tCan't download the installer")
+ else:
+ self.__logger.logInfo("\tYour version up to date")
|