[tuxdroid-svn] r5075 - software_suite_v3/smart-core/smart-server/trunk
Status: Beta
Brought to you by:
ks156
|
From: remi <c2m...@c2...> - 2009-07-07 20:21:12
|
Author: remi
Date: 2009-07-07 22:21:00 +0200 (Tue, 07 Jul 2009)
New Revision: 5075
Added:
software_suite_v3/smart-core/smart-server/trunk/TDSAutoUpdater.py
Modified:
software_suite_v3/smart-core/smart-server/trunk/TDSConfiguration.py
software_suite_v3/smart-core/smart-server/trunk/TuxDroidServer.py
software_suite_v3/smart-core/smart-server/trunk/installer.nsi
Log:
* Added auto-update system for ("smart_server", "smart_api", "smart_content") (Only Windows for now)
Added: software_suite_v3/smart-core/smart-server/trunk/TDSAutoUpdater.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/TDSAutoUpdater.py (rev 0)
+++ software_suite_v3/smart-core/smart-server/trunk/TDSAutoUpdater.py 2009-07-07 20:21:00 UTC (rev 5075)
@@ -0,0 +1,191 @@
+# -*- coding: latin1 -*-
+
+import version
+__author__ = version.author
+__date__ = version.date
+__version__ = version.version
+__licence__ = version.licence
+del version
+
+# Copyright (C) 2009 C2ME Sa
+# Remi Jocaille <rem...@c2...>
+# Distributed under the terms of the GNU General Public License
+# http://www.gnu.org/copyleft/gpl.html
+
+import os
+import threading
+import subprocess
+
+from TDSConfiguration import *
+
+from util.misc import DirectoriesAndFilesTools
+from util.misc import URLTools
+
+DIST_STATE = "beta"
+
+PART_CONF_SRC_URL = 0
+PART_CONF_DEST = 1
+PART_CVER_FILE = 2
+PART_DEFAULT_VER = 3
+
+UPDATES_PARTS = {
+ 'smart_server' : [
+ 'http://ftp.kysoh.com/ssv3/smart_core/smart_server/%s.conf' % DIST_STATE,
+ 'smart_server.conf',
+ 'smart_server.cver',
+ __version__,
+ ],
+ 'smart_api' : [
+ 'http://ftp.kysoh.com/ssv3/smart_core/smart_api/%s.conf' % DIST_STATE,
+ 'smart_api.conf',
+ 'smart_api.cver',
+ '',
+ ],
+ 'smart_content' : [
+ 'http://ftp.kysoh.com/ssv3/smart_core/smart_content/%s.conf' % DIST_STATE,
+ 'smart_content.conf',
+ 'smart_content.cver',
+ '',
+ ],
+}
+
+PART_NAMES = [
+ 'smart_content',
+ 'smart_api',
+ 'smart_server',
+]
+
+class TDSAutoUpdater(object):
+ """
+ """
+
+ def __init__(self):
+ """
+ """
+ if not os.path.isdir(TDS_UPDATES_PATH):
+ DirectoriesAndFilesTools.MKDirs(TDS_UPDATES_PATH)
+ # Write default CVER files
+ self.__writeDefaultCVerFiles()
+
+ def __writeDefaultCVerFiles(self):
+ """
+ """
+ for partName in PART_NAMES:
+ defaultVersion = UPDATES_PARTS[partName][PART_DEFAULT_VER]
+ cverFile = os.path.join(TDS_UPDATES_PATH,
+ UPDATES_PARTS[partName][PART_CVER_FILE])
+ if not os.path.isfile(cverFile):
+ self.__writeCVerFile(partName, defaultVersion)
+
+ def __writeCVerFile(self, partName, currentVersion):
+ """
+ """
+ cverFile = os.path.join(TDS_UPDATES_PATH,
+ UPDATES_PARTS[partName][PART_CVER_FILE])
+ if currentVersion != "":
+ f = open(cverFile, "w")
+ f.write(currentVersion)
+ f.close()
+
+ def __getCurrentPartVersion(self, partName):
+ """
+ """
+ cverFile = os.path.join(TDS_UPDATES_PATH,
+ UPDATES_PARTS[partName][PART_CVER_FILE])
+ if os.path.isfile(cverFile):
+ f = open(cverFile, "r")
+ result = f.read()
+ f.close()
+ return result
+ else:
+ return ""
+
+ def start(self):
+ """
+ """
+ self.__checkStartInstallers()
+ t = threading.Thread(target = self.__updateFromTheNet)
+ t.start()
+
+ def __checkStartInstallers(self):
+ """
+ """
+ for partName in PART_NAMES:
+ destConf = os.path.join(TDS_UPDATES_PATH,
+ UPDATES_PARTS[partName][PART_CONF_DEST])
+ cverFile = os.path.join(TDS_UPDATES_PATH,
+ UPDATES_PARTS[partName][PART_CVER_FILE])
+ if os.path.isfile(destConf):
+ f = open(destConf, "r")
+ try:
+ confDict = eval(f.read())
+ except:
+ continue
+ f.close()
+ archName = "win32"
+ if os.name == "nt":
+ if not confDict.has_key('win32'):
+ continue
+ archName = "win32"
+ else:
+ if not confDict.has_key('unix'):
+ continue
+ archName = "unix"
+ installerName = confDict[archName]["fileName"]
+ currentVersion = confDict[archName]["version"]
+ if self.__getCurrentPartVersion(partName) == currentVersion:
+ continue
+ # Write CVER file
+ self.__writeCVerFile(partName, currentVersion)
+ installerFile = os.path.join(TDS_UPDATES_PATH, installerName)
+ if os.name == "nt":
+ cmd = [
+ installerFile,
+ "/S",
+ "/START=true",
+ ]
+ print "Install : [%s](%s)" % (installerName, currentVersion)
+ process = subprocess.Popen(cmd)
+ print "Installed : [%s](%s)" % (installerName, currentVersion)
+ else:
+ pass
+
+ def __updateFromTheNet(self):
+ """
+ """
+ # Download conf files
+ for partName in PART_NAMES:
+ confUrl = UPDATES_PARTS[partName][PART_CONF_SRC_URL]
+ confStr = URLTools.URLDownloadToString(confUrl)
+ if confStr != None:
+ try:
+ confDict = eval(confStr)
+ except:
+ continue
+ archName = "win32"
+ if os.name == "nt":
+ if not confDict.has_key('win32'):
+ continue
+ archName = "win32"
+ else:
+ if not confDict.has_key('unix'):
+ continue
+ archName = "unix"
+ currentVersion = self.__getCurrentPartVersion(partName)
+ stateVersion = confDict[archName]["version"]
+ print "[%s] : CV = [%s] SV = [%s]" % (partName, currentVersion,
+ stateVersion)
+ if stateVersion != currentVersion:
+ installerUrl = confDict[archName]["url"]
+ installerDest = os.path.join(TDS_UPDATES_PATH,
+ confDict[archName]["fileName"])
+ print "Download installer : [%s]" % confDict[archName]["fileName"]
+ if URLTools.URLDownloadToFile(installerUrl, installerDest):
+ print "Installer downloaded : [%s]" % confDict[archName]["fileName"]
+ 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"]
Modified: software_suite_v3/smart-core/smart-server/trunk/TDSConfiguration.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/TDSConfiguration.py 2009-07-07 20:08:38 UTC (rev 5074)
+++ software_suite_v3/smart-core/smart-server/trunk/TDSConfiguration.py 2009-07-07 20:21:00 UTC (rev 5075)
@@ -97,6 +97,8 @@
TDS_DEFAULT_CONTENT_PATH = os.path.join(ALLUSERSBASEDIR, "resources")
else:
TDS_DEFAULT_CONTENT_PATH = os.path.join(TUXDROID_BASE_PATH, "resources")
+# Path of the server updates
+TDS_UPDATES_PATH = os.path.join(TDS_DEFAULT_CONTENT_PATH, "updates")
# ------------------------------------------------------------------------------
# Resources configuration
Modified: software_suite_v3/smart-core/smart-server/trunk/TuxDroidServer.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/TuxDroidServer.py 2009-07-07 20:08:38 UTC (rev 5074)
+++ software_suite_v3/smart-core/smart-server/trunk/TuxDroidServer.py 2009-07-07 20:21:00 UTC (rev 5075)
@@ -28,6 +28,7 @@
from TDSHTTPServer import *
from TDSResourcesManager import *
from TDSConfiguration import *
+from TDSAutoUpdater import TDSAutoUpdater
# Define the events handler.
eventsHandler = TuxEventHandlers()
@@ -56,6 +57,9 @@
def initializeServer():
"""Initialize the server.
"""
+ # Check for updates
+ autoUpdater = TDSAutoUpdater()
+ autoUpdater.start()
# Load and start the resources manager
resourcesManager.load(TDS_RESOURCES_PATH)
resourcesManager.addDirectoryToServe("/data/web_interface/server_menu/xsl/")
Modified: software_suite_v3/smart-core/smart-server/trunk/installer.nsi
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/installer.nsi 2009-07-07 20:08:38 UTC (rev 5074)
+++ software_suite_v3/smart-core/smart-server/trunk/installer.nsi 2009-07-07 20:21:00 UTC (rev 5075)
@@ -39,6 +39,7 @@
DetailPrint "Uninstalling old versions"
SetDetailsPrint none
ExecWait '"$TUXDROID_PATH\uninstallers\sub\${UNINSTALLER_EXE}" /S _?=$TUXDROID_PATH\uninstallers'
+ Sleep 3000
SetDetailsPrint textonly
!endif
SectionEnd
@@ -66,6 +67,7 @@
File TDSHTTPServer.py
File TDSResourcesManager.py
File TDSService.py
+ File TDSAutoUpdater.py
File TuxDroidServer.py
CreateDirectory "$TUXDROID_PATH\softwares\smart-server\data"
@@ -122,12 +124,19 @@
; -----------------------------------------------------------------------------
Section "Uninstall"
; Kill troublesome tasks
- Processes::KillProcess "pythonForTuxdroid"
- Processes::KillProcess "pythonForTuxdroidA"
+ Processes::KillProcess "tux_wifi_channel"
+ Sleep 100
+ Processes::KillProcess "SCMSN"
+ Sleep 100
Processes::KillProcess "python"
+ Sleep 100
Processes::KillProcess "java"
+ Sleep 100
Processes::KillProcess "javaw"
- Processes::KillProcess "tux_wifi_channel"
+ Sleep 100
+ Processes::KillProcess "pythonForTuxdroid"
+ Sleep 100
+ Processes::KillProcess "pythonForTuxdroidA"
; Get the Tuxdroid installation paths
ReadRegStr $TUXDROID_PATH HKLM "SOFTWARE\Tux Droid\Installation" "Install_Dir"
|