Author: ks156
Date: 2009-03-11 13:00:05 +0100 (Wed, 11 Mar 2009)
New Revision: 3949
Added:
software_suite_v2/tuxware/installers/unix/branches/refactoring/misc/progressBar.py
Modified:
software_suite_v2/tuxware/installers/unix/branches/refactoring/tux_software_updater.py
Log:
* Added a progress bar to display the progression
Added:
software_suite_v2/tuxware/installers/unix/branches/refactoring/misc/progressBar.py
===================================================================
---
software_suite_v2/tuxware/installers/unix/branches/refactoring/misc/progressBar.py
(rev 0)
+++
software_suite_v2/tuxware/installers/unix/branches/refactoring/misc/progressBar.py
2009-03-11 12:00:05 UTC (rev 3949)
@@ -0,0 +1,29 @@
+#!/usr/bin/python
+__steps = 0
+__progress = 0.0
+
+def initProgressBar(steps):
+ global __steps
+ global __progress
+ #print '\033[sProgression : [\033[57C] 0%\033[u',
+ __steps = 57.0 / float(steps)
+ __progress = 0
+
+def setProgressBar(percent):
+ global __progress
+ progress = ((float(percent) * 57.0) / 100.0)
+
+def getProgressBar():
+ global __progress
+ return ((float (__progress) * 100.0) / 57.0)
+
+def incProgressBar():
+ global __steps
+ global __progress
+ __progress = __progress + __steps
+ percent = getProgressBar()
+ __strokeProgressBar(percent, __progress)
+
+def __strokeProgressBar(percent, progress):
+ print 'Progression : [\033[s'\
+ +"#"*int(progress)+'\033[u\033[56C] '+"%.0f"%percent+'%\033[1A'
Property changes on:
software_suite_v2/tuxware/installers/unix/branches/refactoring/misc/progressBar.py
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ text/x-python
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified:
software_suite_v2/tuxware/installers/unix/branches/refactoring/tux_software_updater.py
===================================================================
---
software_suite_v2/tuxware/installers/unix/branches/refactoring/tux_software_updater.py
2009-03-11 10:51:24 UTC (rev 3948)
+++
software_suite_v2/tuxware/installers/unix/branches/refactoring/tux_software_updater.py
2009-03-11 12:00:05 UTC (rev 3949)
@@ -5,13 +5,14 @@
from misc.tuxPaths import *
from misc.URLTools import *
from misc.DirectoriesAndFilesTools import *
+from misc.progressBar import *
import getopt
import sys
import os
DEBUG = 0
-def usage():
+def __usage():
print "-"*80
print "Tux Software Updater"
print "-"*80
@@ -35,58 +36,18 @@
print ""
sys.exit(0)
-def main():
- global DEBUG
-
- # Set the default version type
- VERSION="Online"
-
- # Set the options parameters
- try:
- opts, args = getopt.getopt(sys.argv[1:], "dhv:",\
- ["debug", "help", "version="])
- except getopt.error, msg:
- print msg
- print "For help use --help"
- sys.exit(2)
-
- # Parse the given options
- for o,a in opts:
- if o in ("-d", "--debug"):
- DEBUG=1
- if o in ("-h", "--help"):
- usage()
- if o in ("-v", "--version"):
- if a == "QC" or a == "Online" or a == "Work":
- VERSION=a
- else:
- print "Unrecognized version type : %s"%a
- print "Please see the help for the version type"
- sys.exit(2)
-
- # 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)
-
- # Control the errors
- if success != RES_NO_ERROR:
- print ""
- print "Error !"
- print "The server seems to be under maintenance. Please retry later."
- if DEBUG:
- print "(%d) : %s" % (success, data)
-
+def __retrieveRules(data):
# Retrieve the DB file
if isInstalledDb():
toInstall, toRemove = parseDb(data)
else:
toInstall = data
toRemove = []
+ return toInstall, toRemove
+def __isSomethingToUpdate(toInstall):
# Check if new updates are available
+ proceed = False
if len(toInstall) == 0:
print ""
print "No new update available"
@@ -108,14 +69,17 @@
else:
print "The update process has been aborted"
proceed = False
+ return proceed
- if proceed:
+def __updateSystem(data, toInstall, toRemove, processToKillList):
# Kill the services
for service in processToKillList:
os.system("pkill -f %s"%service)
+ initProgressBar(len(toInstall))
# Install or update the new software
for item in toInstall:
+ incProgressBar()
# Copy the new files
if item['command'] == "COPY":
dest = item['destination'].replace("$PREFIX", TUXDROID_PREFIX)
@@ -124,7 +88,7 @@
os.system("mkdir -p %s"%path)
URLDownloadToFile(item['source'], dest)
-
+ # Install a meta-package
elif item['command'] == "INST":
os.system("mkdir -p /tmp/tuxdroid_upd")
dest = item['destination'].replace("$PREFIX", TUXDROID_PREFIX)
@@ -137,9 +101,10 @@
cd /tmp/tuxdroid_upd/%s && /bin/bash install.sh %s &&\
rm -rf /tmp/tuxdroid_upd/" \
%(filename, filename.split("-")[0], dest))
+ print ''
writeDb(data)
- # Uninstall the ununsed stuff
+ # Uninstall the ununsed stuff
for item in toRemove:
dest = item['destination'].replace("$PREFIX", TUXDROID_PREFIX)
if item['command'] == "COPY":
@@ -151,6 +116,55 @@
if os.path.isdir(dest):
RMDirs(dest)
+def main():
+ global DEBUG
+
+ # Set the default version type
+ VERSION="Online"
+
+ # Set the options parameters
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "dhv:",\
+ ["debug", "help", "version="])
+ except getopt.error, msg:
+ print msg
+ print "For help use --help"
+ sys.exit(2)
+
+ # Parse the given options
+ for o,a in opts:
+ if o in ("-d", "--debug"):
+ DEBUG=1
+ if o in ("-h", "--help"):
+ __usage()
+ if o in ("-v", "--version"):
+ if a == "QC" or a == "Online" or a == "Work":
+ VERSION=a
+ else:
+ print "Unrecognized version type : %s"%a
+ print "Please see the help for the version type"
+ sys.exit(2)
+
+ # 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)
+
+ # Control the errors
+ if success != RES_NO_ERROR:
+ print ""
+ print "Error !"
+ print "The server seems to be under maintenance. Please retry later."
+ if DEBUG:
+ print "(%d) : %s" % (success, data)
+
+ toInstall, toRemove = __retrieveRules(data)
+
+ if __isSomethingToUpdate(toInstall):
+ __updateSystem(data, toInstall, toRemove, processToKillList)
+
if __name__ == "__main__":
main()
------------------------------------------------------------------------------
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