[Apt-offline-devel] [SCM] Offline APT Package Manager branch, apt-offline-qt, updated. v0.9.9-110-gdeef88f

Abhishek Mishra ideamonk at gmail.com
Sat Aug 21 15:40:14 UTC 2010


The following commit has been merged in the apt-offline-qt branch:
commit bc1d1de3779f537eafd3a70fd006fd49ca4ca993
Author: Abhishek Mishra <ideamonk at gmail.com>
Date:   Sat Aug 21 14:31:34 2010 +0530

    installer progressbar added

diff --git a/apt_offline_core/AptOfflineCoreLib.py b/apt_offline_core/AptOfflineCoreLib.py
index 9ba2dda..bd40151 100644
--- a/apt_offline_core/AptOfflineCoreLib.py
+++ b/apt_offline_core/AptOfflineCoreLib.py
@@ -1028,13 +1028,23 @@ def installer( args ):
                         log.err( "I couldn't understand file type %s.\n" % ( filename ) )
                 
                 if retval:
+                        #CHANGE: track progress
+                        totalSize[0]+=1 
+                        if guiBool:
+                            log.msg("[%d/%d]" % (totalSize[0], totalSize[1]))
+                        #ENDCHANGE
                         log.verbose( "%s file synced to %s.\n" % ( filename, apt_update_target_path ) )
                 else:
                         log.err("Failed to sync %s\n" % (filename) )
+
         
         if os.path.isfile(install_file_path):
                 #INFO: For now, we support zip bundles only
                 file = zipfile.ZipFile( install_file_path, "r" )
+                #CHANGE: for progress tracking
+                totalSize[1] = len(file.namelist())
+                totalSize[0] = 0
+                #ENDCHANGE
                 
                 SrcPkgDict = {}
                 for filename in file.namelist():
@@ -1103,7 +1113,6 @@ def installer( args ):
                                                         shutil.copy2(archive_file, os.path.join(Str_InstallSrcPath, filename) )
                                                         log.msg("Installing src package file %s to %s.\n" % (filename, Str_InstallSrcPath) )
                                                         continue
-                                                
                                                 magic_check_and_uncompress( archive_file, filename )
                                                 data.file.close()
                                         sys.exit( 0 )
@@ -1160,7 +1169,7 @@ def installer( args ):
                                         shutil.copy2(archive_file, os.path.join(Str_InstallSrcPath, filename) )
                                         log.msg("Installing src package file %s to %s.\n" % (filename, Str_InstallSrcPath) )
                                         continue
-                                
+                                    
                                 magic_check_and_uncompress( archive_file, filename )
                                 data.file.close()
                         #else:
@@ -1277,7 +1286,7 @@ def installer( args ):
                                         shutil.copy2(eachfile, Str_InstallSrcPath)
                                         log.msg("Installed src package file %s to %s.\n" % (filename, Str_InstallSrcPath) )
                                         continue
-                                
+                                    
                                 magic_check_and_uncompress( eachfile, filename )
                         #else:
                         #        log.msg( "Exiting gracefully on user request.\n" )
diff --git a/apt_offline_gui/AptOfflineQtInstall.py b/apt_offline_gui/AptOfflineQtInstall.py
index e7a412e..268340c 100644
--- a/apt_offline_gui/AptOfflineQtInstall.py
+++ b/apt_offline_gui/AptOfflineQtInstall.py
@@ -35,7 +35,7 @@ class Worker(QtCore.QThread):
             except:
                 pass
             self.emit (QtCore.SIGNAL('output(QString)'), text)
-        if ('apt/lists' in text):
+        elif ('apt/lists' in text):
             try:
                 # this part is always done on a linux system so we can hardcode / for a while
                 text = guicommon.style("Update : ",'orange') + guicommon.style(text.split("/")[-1],'green')
@@ -43,9 +43,16 @@ class Worker(QtCore.QThread):
                 # let the text be original otherwise
                 pass
             self.emit (QtCore.SIGNAL('output(QString)'), text)
+        elif ('[' in text and ']' in text):
+            try:
+                progress = str(apt_offline_core.AptOfflineCoreLib.totalSize[0])
+                total = str(apt_offline_core.AptOfflineCoreLib.totalSize[1])
+                self.emit (QtCore.SIGNAL('progress(QString,QString)'), progress,total)
+            except:
+                ''' nothing to do '''
         else:
             self.emit (QtCore.SIGNAL('output(QString)'), guicommon.style(text,'red'))
-
+                            
     def flush(self):
         ''' nothing to do :D '''
         
@@ -134,9 +141,12 @@ class AptOfflineQtInstall(QtGui.QDialog):
         self.ui.progressStatusDescription.setText(text)
 
     def updateProgress(self,progress,total):
-        # NOTE: inactive
-        # TODO: implement progress here
-        return
+        try:
+            # try parsing numbers and updating progressBar
+            percent = (float(progress)/float(total))*100
+            self.ui.statusProgressBar.setValue (percent)
+        except:
+             ''' nothing to do '''
 
     def finishedWork(self):
         self.enableActions()

-- 
Offline APT Package Manager



More information about the Apt-offline-devel mailing list