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 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 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

        self.num_of_threads=self.ui.spinThreads.value() 
        args = GetterArgs(filename=self.filepath, bundle_file= self.zipfilepath, progress_bar=self.ui.statusProgressBar, 
                        progress_label=self.ui.progressStatusDescription, num_of_threads=self.num_of_threads)
        
        #returnStatus = apt_offline_core.AptOfflineCoreLib.fetcher(args)
        # TODO: deal with return status laters
        
        self.ui.cancelButton.setText("Cancel")
        self.disableAction()
        self.worker.setArgs (args)
        self.worker.start()
        #if (returnStatus):
        ''' TODO: do something with self.zipfilepath '''
    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")
Exemple #8
0
 def updateLog(self,text):
     guicommon.updateInto (self.ui.rawLogHolder,text)
 def write(self, text):
     # redirects console output to our consoleOutputHolder
     guicommon.updateInto(self.ui.rawLogHolder, text)
 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
 def write(self, text):
     # redirects console output to our consoleOutputHolder
     text=text.strip()
     if (len(text)>2):
         guicommon.updateInto(self.ui.consoleOutputHolder,text)