def StartInstall(self):
        # gui validation
        # Clear the consoleOutputHolder
        self.ui.rawLogHolder.setText("")

        self.filepath = str(self.ui.zipFilePath.text())

        if os.path.isfile(self.filepath) == False:
            if len(self.filepath) == 0:
                self.ui.rawLogHolder.setText(guicommon.style("Please select a zip file!", "red"))
            else:
                self.ui.rawLogHolder.setText(guicommon.style("%s does not exist." % self.filepath, "red"))
            return

        # parse args
        args = InstallerArgs(
            filename=self.filepath,
            progress_bar=self.ui.statusProgressBar,
            progress_label=self.ui.progressStatusDescription,
        )

        # setup i/o redirects before call
        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,))
 def write(self, text):
     # redirects console output to our consoleOutputHolder
     # extract chinese whisper from text
     if ".deb" in text and "synced" in text:
         try:
             text = guicommon.style("Package : ", "orange") + guicommon.style(text.split("/")[-1], "green")
         except:
             pass
         self.emit(QtCore.SIGNAL("output(QString)"), 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")
         except:
             # 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"))
Example #3
0
 def write(self, text):
     # redirects console output to our consoleOutputHolder
     # extract chinese whisper from text
     if ('.deb' in text and 'synced' in text):
         try:
             text = guicommon.style("Package : ",'orange') + guicommon.style(text.split("/")[-1],'green')
         except:
             pass
         self.emit (QtCore.SIGNAL('output(QString)'), 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')
         except:
             # 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'))
Example #4
0
 def finishedWork(self):
     self.enableActions()
     guicommon.updateInto(
         self.ui.rawLogHolder,
         guicommon.style("Finished syncing updates/packages", "green_fin"))
     self.ui.progressStatusDescription.setText("Finished Syncing")
     self.ui.cancelButton.setText("Close")
 def write(self, text):
     # redirects console output to our consoleOutputHolder
     # extract chinese whisper from text
     if apt_offline_core.AptOfflineCoreLib.guiTerminateSignal:
         # ^ so artificial, the threads still remain frozen in time I suppose
         return
         
     if ("MSG_START" in text):
         self.emit (QtCore.SIGNAL('status(QString)'), "Fetching missing meta data ...")
     elif ("MSG_END" in text):
         self.emit (QtCore.SIGNAL('status(QString)'), "Downloading packages ...")
     elif ("WARNING" in text):
         self.emit (QtCore.SIGNAL('output(QString)'), 
                                 guicommon.style(text,"red"))
     elif ("Downloading" in text):
         self.emit (QtCore.SIGNAL('output(QString)'), 
                                 guicommon.style(text,"orange"))
     elif ("done." in text):
         self.emit (QtCore.SIGNAL('output(QString)'), 
                                 guicommon.style(text,"green"))
     elif ("[" 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)
         except:
             ''' nothing to do '''
     else:
         self.emit (QtCore.SIGNAL('output(QString)'), text.strip())
 def updateLog(self,text):
     if not ('[' in text and ']' in text):
         if ('Downloaded data ' in text):
             guicommon.updateInto (self.ui.rawLogHolder,
                                 guicommon.style(text,'green_fin'))
             self.ui.progressStatusDescription.setText('Finished.')
         else:
             guicommon.updateInto (self.ui.rawLogHolder,text)
    def CreateProfile(self):
        # Is the Update requested
        self.updateChecked = self.ui.updateCheckBox.isChecked()
        # Is Upgrade requested
        self.upgradeChecked = self.ui.upgradePackagesRadioBox.isChecked()
        # Is Install Requested
        self.installChecked = self.ui.installPackagesRadioBox.isChecked()

        # Clear the consoleOutputHolder
        self.ui.consoleOutputHolder.setText("")

        self.filepath = str(self.ui.profileFilePath.text())

        if os.path.exists(os.path.dirname(self.filepath)) == False:
            if len(self.filepath) == 0:
                self.ui.consoleOutputHolder.setText(
                    guicommon.style("Please select a file to store the signature!", "red")
                )
            else:
                self.ui.consoleOutputHolder.setText(guicommon.style("Could not access  %s" % self.filepath, "red"))
            return

        # If atleast one is requested
        if self.updateChecked or self.upgradeChecked or self.installChecked:
            if self.installChecked:
                self.packageList = str(self.ui.packageList.text()).split(",")
            else:
                self.packageList = None

            # setup i/o redirects before call
            sys.stdout = self
            sys.stderr = self

            args = SetterArgs(
                filename=self.filepath,
                update=self.updateChecked,
                upgrade=self.upgradeChecked,
                install_packages=self.packageList,
                simulate=False,
            )
            returnStatus = apt_offline_core.AptOfflineCoreLib.setter(args)

            if (
                returnStatus != False
            ):  # right now it returns None, I think it doesn't return at all but sys.exits on failure
                # TODO ^ fixup this behaviour
                guicommon.updateInto(self.ui.consoleOutputHolder, guicommon.style("Completed.", "green_fin"))
                self.ui.createProfileButton.setEnabled(False)
                self.ui.cancelButton.setText("Finish")
                self.ui.cancelButton.setIcon(QtGui.QIcon())
        else:
            pass
    def CreateProfile(self):
        # Is the Update requested
        self.updateChecked = self.ui.updateCheckBox.isChecked()
        # Is Upgrade requested
        self.upgradeChecked = self.ui.upgradePackagesCheckBox.isChecked()
        # Is Install Requested
        self.installChecked = self.ui.installPackagesCheckBox.isChecked()

        # Clear the consoleOutputHolder
        self.ui.consoleOutputHolder.setText("")
        
        self.filepath = str(self.ui.profileFilePath.text())
        
        if os.path.exists(os.path.dirname(self.filepath)) == False:
            if (len(self.filepath) == 0):
                self.ui.consoleOutputHolder.setText ( \
                    guicommon.style("Please select a file to store the signature!",'red'))
            else:
                self.ui.consoleOutputHolder.setText ( \
                    guicommon.style("Could not access  %s" % self.filepath,'red'))
            return
        
        # If atleast one is requested
        if self.updateChecked or self.upgradeChecked or self.installChecked:
            if self.installChecked:
                self.packageList = str(self.ui.packageList.text()).split(",")
            else:
                self.packageList = None

            # setup i/o redirects before call
            sys.stdout = self
            sys.stderr = self
             
            args = SetterArgs(filename=self.filepath, update=self.updateChecked, upgrade=self.upgradeChecked, install_packages=self.packageList, simulate=False)
            returnStatus = apt_offline_core.AptOfflineCoreLib.setter(args)

            if(returnStatus != False):  # right now it returns None, I think it doesn't return at all but sys.exits on failure
                # TODO ^ fixup this behaviour
                guicommon.updateInto(self.ui.consoleOutputHolder, guicommon.style("Completed.","green_fin"))
                self.ui.createProfileButton.setEnabled(False)
                self.ui.cancelButton.setText("Finish")
                self.ui.cancelButton.setIcon(QtGui.QIcon())
        else:
            pass
    def CreateProfile(self):
        # Is the Update requested
        self.updateChecked = self.ui.updateCheckBox.isChecked()
        # Is Upgrade requested
        self.upgradeChecked = self.ui.upgradePackagesRadioBox.isChecked()
        # Is Install Requested
        self.installChecked = self.ui.installPackagesRadioBox.isChecked()

        # Clear the consoleOutputHolder
        self.ui.consoleOutputHolder.setText("")
        
        self.filepath = str(self.ui.profileFilePath.text())
        
        if os.path.exists(os.path.dirname(self.filepath)) == False:
            if (len(self.filepath) == 0):
                self.ui.consoleOutputHolder.setText ( \
                    guicommon.style("Please select a file to store the signature!",'red'))
            else:
                self.ui.consoleOutputHolder.setText ( \
                    guicommon.style("Could not access  %s" % self.filepath,'red'))
            return
        
        # If atleast one is requested
        if self.updateChecked or self.upgradeChecked or self.installChecked:
            if self.installChecked:
                self.packageList = str(self.ui.packageList.text()).split(",")
            else:
                self.packageList = None

            # setup i/o redirects before call
            sys.stdout = self
            sys.stderr = self
            
            args = SetterArgs(filename=self.filepath, update=self.updateChecked, upgrade=self.upgradeChecked, install_packages=self.packageList)
            returnStatus = apt_offline_core.AptOfflineCoreLib.setter(args)
            
            if(returnStatus):
                self.ui.createProfileButton.setEnabled(False)
                self.ui.cancelButton.setText("Finish")
                self.ui.cancelButton.setIcon(QtGui.QIcon())
        else:
            pass
    def StartInstall(self):
        # gui validation
        # Clear the consoleOutputHolder
        self.ui.rawLogHolder.setText("")

        self.filepath = str(self.ui.zipFilePath.text())

        if os.path.isfile(self.filepath) == False:
            if (len(self.filepath) == 0):
                self.ui.rawLogHolder.setText ( \
                    guicommon.style("Please select a zip file!",'red'))
            else:
                self.ui.rawLogHolder.setText ( \
                    guicommon.style("%s does not exist." % self.filepath,'red'))
            return

        # parse args
        args = InstallerArgs(filename=self.filepath, progress_bar=self.ui.statusProgressBar, progress_label=self.ui.progressStatusDescription )

        self.disableActions()
        self.ui.progressStatusDescription.setText("Syncing updates")
        self.worker.setArgs (args)
        self.worker.start()
Example #11
0
 def handleCancel(self):
     if self.ui.cancelButton.text() == "Cancel":
         if self.worker.isRunning():
             # Download is still in progress
             ret = QMessageBox.warning(self, "Cancel current downloads?",
                 "A download is already in progress.\nDo you want to cancel it?",
                        QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
             if ret == QMessageBox.Yes:
                 # we can't just stop threads, we need to pass message
                 apt_offline_core.AptOfflineCoreLib.guiTerminateSignal=True
                 self.updateStatus(guicommon.style("Download aborted","red"))
                 self.ui.cancelButton.setText("Close")
         else:
             self.reject()
     else:
         self.reject()
Example #12
0
 def handleCancel(self):
     if self.ui.cancelButton.text() == "Cancel":
         if self.worker.isRunning():
             # Download is still in progress
             ret = QMessageBox.warning(self, "Cancel current downloads?",
                 "A download is already in progress.\nDo you want to cancel it?",
                        QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
             if ret == QMessageBox.Yes:
                 # we can't just stop threads, we need to pass message
                 apt_offline_core.AptOfflineCoreLib.guiTerminateSignal=True
                 self.updateStatus(guicommon.style("Download aborted","red"))
                 self.enableAtStop()
                 self.ui.cancelButton.setText("Close")
         else:
             self.reject()
     else:
         self.reject()
 def write(self, text):
     # redirects console output to our consoleOutputHolder
     text = text.strip()
     if (len(text) > 2):
         guicommon.updateInto(self.ui.consoleOutputHolder, text)
Example #14
0
    def StartDownload(self):
        # Do all the download related work here and then close

        # Clear the consoleOutputHolder
        self.ui.rawLogHolder.setText("")
        
        self.filepath = str(self.ui.profileFilePath.text())

        if os.path.isfile(self.filepath) == False:
            if (len(self.filepath) == 0):
                self.ui.rawLogHolder.setText ( \
                    guicommon.style("Please select a signature file!",'red'))
            else:
                self.ui.rawLogHolder.setText ( \
                    guicommon.style("%s does not exist." % self.filepath,'red'))
            return
        
        self.zipfilepath = str(self.ui.zipFilePath.text())
        
        # First we need to determine if the input is a file path or a directory path
        if self.ui.saveDatacheckBox.isChecked() is not True: 
                #Input is a file path

                # if file already exists
                if os.path.exists(self.zipfilepath):
                        ret = QMessageBox.warning(self, "Replace archive file?", "The file %s already exists.\n" 
                                                  "Do you want to overwrite it?" % self.zipfilepath,
                                                  QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
                        if ret == QMessageBox.Yes:
                                # delete the file
                                try:
                                        #TODO: If "/" is the path, then os.unlink quietly fails crashing the GUI
                                        os.unlink(self.zipfilepath)
                                except:
                                        guicommon.updateInto (self.ui.rawLogHolder, 
                                                              guicommon.style("Could'nt write to %s!" % self.zipfilepath,'red'))
                        else:
                                return
                else:
                        if not os.access(os.path.dirname(self.zipfilepath), os.W_OK):
                                guicommon.updateInto (self.ui.rawLogHolder,
                                                      guicommon.style("%s does not have write access." % self.zipfilepath,'red'))
                                return
                targetFilePath = self.zipfilepath
                targetDirPath = None
                    
        else:
                if os.path.exists(self.zipfilepath):
                        if os.access(self.zipfilepath, os.W_OK) == False:
                                guicommon.updateInto (self.ui.rawLogHolder,
                                                      guicommon.style("%s does not have write access." % self.zipfilepath,'red'))
                        return
                else:
                        ret = QMessageBox.warning(self, "No such directory", "No such directory %s\n"
                                                  "Do you want to create it?" % self.zipfilepath,
                                                  QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
                        if ret == QMessageBox.Yes:
                                # delete the file
                                try:
                                        os.mkdir(self.zipfilepath)
                                except:
                                        guicommon.updateInto (self.ui.rawLogHolder, 
                                                              guicommon.style("Couldn't create directory %s!" % self.zipfilepath,'red'))
                                        return
                        else:
                                return
                targetFilePath = None
                targetDirPath = self.zipfilepath

        
        args = GetterArgs(filename=self.filepath, bundle_file=targetFilePath, progress_bar=self.ui.statusProgressBar, 
                        progress_label=self.ui.progressStatusDescription, proxy_host=self.advancedOptionsDialog.proxy_host,
                        proxy_port=self.advancedOptionsDialog.proxy_port, num_of_threads=self.advancedOptionsDialog.num_of_threads,
                        socket_timeout=self.advancedOptionsDialog.socket_timeout, cache_dir=self.advancedOptionsDialog.cache_dir,
                        download_dir=targetDirPath, disable_md5check=self.advancedOptionsDialog.disable_md5check,
                        deb_bugs=self.advancedOptionsDialog.deb_bugs)
        
        #returnStatus = apt_offline_core.AptOfflineCoreLib.fetcher(args)
        # TODO: deal with return status laters
        
        self.ui.cancelButton.setText("Cancel")
        self.disableAction()
        self.disableAtDownload()
        self.worker.setArgs (args)
        self.worker.start()
        
        #if (returnStatus):
        ''' TODO: do something with self.zipfilepath '''
 def finishedWork(self):
     self.enableActions()
     guicommon.updateInto (self.ui.rawLogHolder,
         guicommon.style("Finished syncting updates/packages","green_fin"))
     self.ui.progressStatusDescription.setText("Finished Syncing")
Example #16
0
 def updateLog(self,text):
     guicommon.updateInto (self.ui.rawLogHolder,text)
Example #17
0
 def write(self, text):
     # redirects console output to our consoleOutputHolder
     guicommon.updateInto(self.ui.rawLogHolder, text)
Example #18
0
    def StartDownload(self):
        # Do all the download related work here and then close

        # Clear the consoleOutputHolder
        self.ui.rawLogHolder.setText("")
        
        self.filepath = str(self.ui.profileFilePath.text())

        if os.path.isfile(self.filepath) == False:
            if (len(self.filepath) == 0):
                self.ui.rawLogHolder.setText ( \
                    guicommon.style("Please select a signature file!",'red'))
            else:
                self.ui.rawLogHolder.setText ( \
                    guicommon.style("%s does not exist." % self.filepath,'red'))
            return
        
        # TODO: check for zip file's presense
        self.zipfilepath = str(self.ui.zipFilePath.text())
        
        # if file has write permission
        if os.access(os.path.dirname(self.zipfilepath), os.W_OK) == False:
            if (len(self.zipfilepath) == 0):
                guicommon.updateInto (self.ui.rawLogHolder, 
                            guicommon.style("Please select a zip file to create archive!",'red'))
            else:
                guicommon.updateInto (self.ui.rawLogHolder, 
                    guicommon.style("%s does not have write access." % self.zipfilepath,'red'))
            return
        
        # if file already exists
        if os.path.exists(self.zipfilepath):
                ret = QMessageBox.warning(self, "Replace archive file?",
                   "The file %s already exists.\n"
                      "Do you want to overwrite it?" % self.zipfilepath,
                           QMessageBox.Yes | QMessageBox.No
                           , QMessageBox.Yes)
                if ret == QMessageBox.Yes:
                    # delete the file
                    try:
                        os.remove(self.zipfilepath)
                    except:
                        guicommon.updateInto (self.ui.rawLogHolder, 
                            guicommon.style("Could'nt write to %s!" % self.zipfilepath,'red'))
                else:
                    return
                   
        args = GetterArgs(filename=self.filepath, bundle_file= self.zipfilepath, progress_bar=self.ui.statusProgressBar, progress_label=self.ui.progressStatusDescription)
        
        #returnStatus = apt_offline_core.AptOfflineCoreLib.fetcher(args)
        # TODO: deal with return status laters
        self.worker.setArgs (args)
        self.worker.start()
        #if (returnStatus):
        ''' TODO: do something with self.zipfilepath '''
 def write(self, text):
     # redirects console output to our consoleOutputHolder
     text=text.strip()
     if (len(text)>2):
         guicommon.updateInto(self.ui.consoleOutputHolder,text)
    def CreateProfile(self):
        # Is the Update requested
        self.updateChecked = self.ui.updateCheckBox.isChecked()
        # Is Upgrade requested
        self.upgradeChecked = self.ui.upgradePackagesCheckBox.isChecked()
        # Is Install Requested
        self.installChecked = self.ui.installPackagesCheckBox.isChecked()
        
        self.installSrcChecked = self.ui.installSrcPackagesCheckBox.isChecked()
        
        self.chlogChecked = self.ui.generateChangelog.isChecked()
        self.aptBackend = self.ui.aptBackendComboBox.currentText()
        self.upgradeType = self.ui.upgradeTaskComboBox.currentText()
        self.releaseBtnChecked = self.ui.targetReleaseCheckBox.isChecked()
        
        # Clear the consoleOutputHolder
        self.ui.consoleOutputHolder.setText("")
        
        self.filepath = str(self.ui.profileFilePath.text())
        
        if os.path.exists(os.path.dirname(self.filepath)) == False:
            if (len(self.filepath) == 0):
                self.ui.consoleOutputHolder.setText ( \
                    guicommon.style("Please select a file to store the signature!",'red'))
            else:
                self.ui.consoleOutputHolder.setText ( \
                    guicommon.style("Could not access  %s" % self.filepath,'red'))
            return
        
        # If atleast one is requested
        if self.updateChecked or self.upgradeChecked or self.installChecked or self.installSrcChecked:
            if self.installChecked:
                self.packageList = str(self.ui.packageList.text()).split(",")
            else:
                self.packageList = None
                
            if self.installSrcChecked:
                self.srcPackageList = str(self.ui.srcPackageList.text()).split(",")
                self.srcBuildDeps = self.ui.srcBuildDeps
            else:
                self.srcPackageList = None
                self.srcBuildDeps = False
                
            if self.releaseBtnChecked:
                self.release = str(self.ui.targetReleaseTextInput.text())
            else:
                self.release = None
            
            # setup i/o redirects before call
            sys.stdout = self
            sys.stderr = self
            
            args = SetterArgs(filename=self.filepath, update=self.updateChecked, upgrade=self.upgradeChecked, install_packages=self.packageList, \
                              install_src_packages=self.srcPackageList, src_build_dep=self.srcBuildDeps, changelog=self.chlogChecked, \
                              release=self.release, apt_backend=self.aptBackend, simulate=False)
            returnStatus = apt_offline_core.AptOfflineCoreLib.setter(args)

            if(returnStatus != False):  # right now it returns None, I think it doesn't return at all but sys.exits on failure
                # TODO ^ fixup this behaviour
                guicommon.updateInto(self.ui.consoleOutputHolder, guicommon.style("Completed.","green_fin"))
                self.ui.createProfileButton.setEnabled(False)
                self.ui.cancelButton.setText("Finish")
                self.ui.cancelButton.setIcon(QtGui.QIcon())
        else:
            pass