Author: ks156
Date: 2009-03-18 16:12:09 +0100 (Wed, 18 Mar 2009)
New Revision: 4137

Modified:
   
software_suite_v2/tuxware/installers/unix/branches/refactoring/software_updater/tux_software_updater.py
Log:
* Added an header
* Added a function to update the IUUID


Modified: 
software_suite_v2/tuxware/installers/unix/branches/refactoring/software_updater/tux_software_updater.py
===================================================================
--- 
software_suite_v2/tuxware/installers/unix/branches/refactoring/software_updater/tux_software_updater.py
     2009-03-18 14:42:17 UTC (rev 4136)
+++ 
software_suite_v2/tuxware/installers/unix/branches/refactoring/software_updater/tux_software_updater.py
     2009-03-18 15:12:09 UTC (rev 4137)
@@ -9,7 +9,13 @@
 import getopt
 import sys
 import os
+import commands
 
+## Global informations
+VERSION = "0.1.0"
+
+## Global variables for the update process
+STTY_SIZE = 0
 GRANT = ""
 ARCH = None
 PREFIX = None
@@ -44,6 +50,14 @@
     print ""
     sys.exit(0)
 
+def header():
+    print "-"*STTY_SIZE
+    print "Tux Software Updater version %s"%VERSION
+    print " Licence : GPLv2"
+    print " Author  : Paul Rathgeb"
+    print "-"*STTY_SIZE
+    print ""
+
 def __retrieveRules(data):
     """__retrieveRules :
     This function check if the database exists, and create two lists :
@@ -53,7 +67,6 @@
     @param data : an array containing the server rules
     #return: toInstall, toRemove
     """
-
     # Retrieve the DB file
     if isInstalledDb() and not CREATE_DB:
         toInstall, toRemove = parseDb(data, ARCH)
@@ -83,7 +96,6 @@
     # Check if new updates are available
     proceed = False
     if len(toInstall) == 0:
-        print ""
         print "No new update available"
         proceed = False
     else:
@@ -105,6 +117,24 @@
             proceed = False
     return proceed
 
+def __updateIUUID():
+    w = open("/tmp/tuxdroid.conf", "w")
+    r = open("/etc/tuxdroid/tuxdroid.conf", "r")
+    stream = r.read()
+    lines = stream.split('\n')
+    for line in lines:
+        if line.find("IUUID=") != -1:
+            iuuid = commands.getoutput("uuidgen")
+            str = "IUUID=%s"%iuuid
+        else:
+            str = line + "\n"
+        w.write(str)
+    w.close()
+    r.close()
+    os.system("%s mv /tmp/tuxdroid.conf /etc/tuxdroid/tuxdroid.conf"%GRANT)
+
+            
+            
 def __updateSystem(data, toInstall, toRemove, processToKillList,
         processToRelaunchList):
     """__updateSystem
@@ -119,6 +149,7 @@
     for service in processToKillList:
         os.system("%s %s"%(GRANT,service))
 
+    print ""
     pb = progressBar()
     pb.init(len(toInstall), 'Download', '%')
     # Install or update the new software
@@ -169,6 +200,8 @@
     for service in processToRelaunchList:
         os.system("%s"%service)
 
+    __updateIUUID()
+
 def __isRightArchitecture(item):
     global ARCH
     # Unix32 file (x86)
@@ -205,8 +238,15 @@
     global DEBUG
     global PREFIX 
     global MIRROR
+    global STTY_SIZE
+    
+    STTY_SIZE =  int(commands.getoutput("/bin/stty size").split(" ")[1])
+    if STTY_SIZE == 0:
+        STTY_SIZE = 80
+    header()
+
+    # Set the prefix
     PREFIX = TUXDROID_PREFIX
-    
     # Set the default version type
     VERSION="Online"
     __retrieveArchitecture()
@@ -245,11 +285,11 @@
             CREATE_DB = True
 
     # Retrieve informations from the server
-    print ""
     print "Retrieving informations from the server."
     print "This operation can take a while ..."
     success, data, processToKillList, processToRelaunchList = \
     getSoftwaresDataFromServer(VERSION)
+    print ""
 
     # Control the errors
     if success != RES_NO_ERROR:
@@ -258,8 +298,10 @@
         print "The server seems to be under maintenance. Please retry later."
         if DEBUG:
             print "(%d) : %s" % (success, data)
-
+    
+    print "Searching for new files ..." 
     toInstall, toRemove = __retrieveRules(data)
+    print ""
     
     if  __isSomethingToUpdate(toInstall):
         __grantPrivilege()


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to