[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:11 UTC 2010


The following commit has been merged in the apt-offline-qt branch:
commit cf4dc39299ac4ea2aaf8734de038d72243e907a3
Author: Abhishek Mishra <ideamonk at gmail.com>
Date:   Fri Aug 20 01:27:42 2010 +0530

    very basic sync functionality of install tested, no progress, no status change, just raw logs of what was synced comes up into UI on install, no post success or failure handlers yet implemented

diff --git a/apt_offline_gui/AptOfflineQtInstall.py b/apt_offline_gui/AptOfflineQtInstall.py
index 7d055e0..4567bf7 100644
--- a/apt_offline_gui/AptOfflineQtInstall.py
+++ b/apt_offline_gui/AptOfflineQtInstall.py
@@ -7,6 +7,57 @@ from apt_offline_gui.UiDataStructs import InstallerArgs
 from apt_offline_gui import AptOfflineQtCommon as guicommon
 import apt_offline_core.AptOfflineCoreLib
 
+class Worker(QtCore.QThread):
+    def __init__(self, parent = None):
+        QtCore.QThread.__init__(self, parent)
+        self.parent = parent
+        self.exiting = False
+
+    def __del__(self):
+        self.exiting = True
+        self.wait()
+
+    def run(self):
+        # setup i/o redirects before call
+        sys.stdout = self
+        sys.stderr = self
+        apt_offline_core.AptOfflineCoreLib.installer(self.args)
+
+    def setArgs (self,args):
+        self.args = args
+
+    def write(self, text):
+        # redirects console output to our consoleOutputHolder
+        # extract chinese whisper from text
+        self.emit (QtCore.SIGNAL('output(QString)'), text)
+        return
+        '''
+        # TODO: if backend sends out any progress, error or success messages,
+        #       rewrite UI handlers here
+        
+        if ("MSG_START" in text):
+            self.emit (QtCore.SIGNAL('status(QString)'), "Fetching missing meta data ...")
+            return
+        if ("MSG_END" in text):
+            self.emit (QtCore.SIGNAL('status(QString)'), "Downloading packages ...")
+            return
+            
+        if ("[" in text and "]" in text):
+            try:
+                # no more splits, we know the exact byte count now
+                progress = str(apt_offline_core.AptOfflineCoreLib.totalSize[1])
+                total = str(apt_offline_core.AptOfflineCoreLib.totalSize[0])
+                self.emit (QtCore.SIGNAL('progress(QString,QString)'), progress,total)
+                return
+            except:
+                pass
+            
+        self.emit (QtCore.SIGNAL('output(QString)'), text)
+        '''
+
+    def flush(self):
+        ''' nothing to do :D '''
+        
 class AptOfflineQtInstall(QtGui.QDialog):
     def __init__(self, parent=None):
         QtGui.QWidget.__init__(self, parent)
@@ -31,6 +82,14 @@ class AptOfflineQtInstall(QtGui.QDialog):
         QtCore.QObject.connect(self.ui.zipFilePath, QtCore.SIGNAL("textChanged(QString)"),
                         self.ControlStartInstallBox )
         
+        self.worker = Worker(parent=self)
+        QtCore.QObject.connect(self.worker, QtCore.SIGNAL("output(QString)"),
+                        self.updateLog )
+        QtCore.QObject.connect(self.worker, QtCore.SIGNAL("progress(QString,QString)"),
+                        self.updateProgress )
+        QtCore.QObject.connect(self.worker, QtCore.SIGNAL("status(QString)"),
+                        self.updateStatus )
+        
     def StartInstall(self):
         # gui validation
         # Clear the consoleOutputHolder
@@ -50,14 +109,15 @@ class AptOfflineQtInstall(QtGui.QDialog):
         # parse args
         args = InstallerArgs(filename=self.filepath, progress_bar=self.ui.statusProgressBar, progress_label=self.ui.progressStatusDescription )
 
+        self.worker.setArgs (args)
+        self.worker.start()
+        ''' old discarded imcompatible threading '''
         # setup i/o redirects before call
-        sys.stdout = self
-        sys.stderr = self
-
+        #sys.stdout = self
+        #sys.stderr = self
         # returnStatus = apt_offline_core.AptOfflineCoreLib.installer(args)
         # TODO: deal with return status laters
-        thread.start_new_thread (apt_offline_core.AptOfflineCoreLib.installer, (args,))
-
+        #thread.start_new_thread (apt_offline_core.AptOfflineCoreLib.installer, (args,))
         # TODO to be implemented later
         # self.accept()
 
@@ -73,13 +133,19 @@ class AptOfflineQtInstall(QtGui.QDialog):
             self.ui.startInstallButton.setEnabled(False)
         else:
             self.ui.startInstallButton.setEnabled(True)
-
-    def write(self, text):
-        # redirects console output to our consoleOutputHolder
+            
+    def updateLog(self,text):
         guicommon.updateInto (self.ui.rawLogHolder,text)
 
-    def flush(self):
-        ''' nothing to do :D '''
+    def updateStatus(self,text):
+        # status handler
+        self.ui.progressStatusDescription.setText(text)
+
+    def updateProgress(self,progress,total):
+        # NOTE: inactive
+        # TODO: implement progress here
+        return
+
 
 if __name__ == "__main__":
     app = QtGui.QApplication(sys.argv)

-- 
Offline APT Package Manager



More information about the Apt-offline-devel mailing list