def pulse(self, owner): super(KDEFetchProgressAdapter, self).pulse(owner) at_item = min(self.current_items + 1, self.total_items) if self.current_cps > 0: self.label.setText(_("Downloading additional package files...") + _("File %s of %s at %sB/s" % (at_item, self.total_items, apt_pkg.size_to_str(self.current_cps)))) else: self.label.setText(_("Downloading additional package files...") + _("File %s of %s" % (at_item, self.total_items))) self.progress.setValue(100 * self.current_bytes / self.total_bytes) KApplication.kApplication().processEvents() return True
def pulse(self, owner): super(KDEFetchProgressAdapter, self).pulse(owner) at_item = min(self.current_items + 1, self.total_items) if self.current_cps > 0: self.label.setText( _("Downloading additional package files...") + _("File %s of %s at %sB/s" % (at_item, self.total_items, apt_pkg.size_to_str(self.current_cps)))) else: self.label.setText( _("Downloading additional package files...") + _("File %s of %s" % (at_item, self.total_items))) self.progress.setValue(100 * self.current_bytes / self.total_bytes) KApplication.kApplication().processEvents() return True
def __init__(self, datadir, component_data=None, parent=None): LanguageSelectorBase.__init__(self, datadir) KCModule.__init__(self, component_data, parent) self.parentApp = KApplication.kApplication() self.ui = Ui_QtLanguageSelectorGUI() self.ui.setupUi(self) self.about = MakeAboutData() self.setAboutData(self.about) self.setWindowIcon(KIcon("preferences-desktop-locale")) self.imSwitch = ImSwitch() # remove dangling ImSwitch symlinks if present self.imSwitch.removeDanglingSymlinks() self.init() # connect the signals self.connect(self.ui.listViewLanguagesInst, SIGNAL("itemSelectionChanged()"), self.checkInstallableComponents) self.connect(self.ui.listViewLanguagesUninst, SIGNAL("itemSelectionChanged()"), self.onChanged) self.connect(self.ui.ktabwidget, SIGNAL("currentChanged(int)"), self.onTabChangeRevertApply) self.connect(self.ui.listBoxDefaultLanguage, SIGNAL("itemSelectionChanged()"), self.checkInputMethods) self.connect(self.ui.checkBoxTr, SIGNAL("stateChanged(int)"), self.onChanged) self.connect(self.ui.checkBoxIm, SIGNAL("stateChanged(int)"), self.onChanged) self.connect(self.ui.checkBoxSpell, SIGNAL("stateChanged(int)"), self.onChanged) self.connect(self.ui.checkBoxFonts, SIGNAL("stateChanged(int)"), self.onChanged)
def pulse(self, owner): apt.progress.base.AcquireProgress.pulse(self, owner) self.progress.setValue((self.current_bytes + self.current_items) / float(self.total_bytes + self.total_items)) current_item = self.current_items + 1 if current_item > self.total_items: current_item = self.total_items label_text = _("Downloading additional package files...") if self.current_cps > 0: label_text += _("File %s of %s at %sB/s") % ( self.current_items, self.total_items, apt_pkg.size_to_str(self.current_cps)) else: label_text += _("File %s of %s") % (self.current_items, self.total_items) self.label.setText(label_text) KApplication.kApplication().processEvents() return True
def commit(self): # ui self.status.setText( _("Installing '%s'...") % os.path.basename(self.debfile)) # the command cmd = "/usr/bin/dpkg" argv = [cmd, "--auto-deconfigure", "-i", self.debfile] (self.child_pid, self.master_fd) = pty.fork() if self.child_pid == 0: os.environ["TERM"] = "dumb" if not "DEBIAN_FRONTEND" in os.environ: os.environ["DEBIAN_FRONTEND"] = "noninteractive" os.environ["APT_LISTCHANGES_FRONTEND"] = "none" exitstatus = subprocess.call(argv) os._exit(exitstatus) while True: #Read from pty and write to DumbTerminal try: (rlist, wlist, xlist) = select.select([self.master_fd], [], [], 0.001) if len(rlist) > 0: line = os.read(self.master_fd, 255) self.parent.konsole.insertWithTermCodes(utf8(line)) except Exception as e: #print e from errno import EAGAIN if hasattr(e, "errno") and e.errno == EAGAIN: continue break KApplication.kApplication().processEvents() # at this point we got a read error from the pty, that most # likely means that the client is dead (pid, status) = os.waitpid(self.child_pid, 0) self.exitstatus = os.WEXITSTATUS(status) self.progress.setValue(100) self.parent.closeButton.setEnabled(True) self.parent.closeButton.setVisible(True) self.parent.installationProgress.setVisible(False) QTimer.singleShot(1, self.parent.changeSize)
def showReleaseNotes(self): # FIXME: care about i18n! (append -$lang or something) self.dialogue = QDialog() uic.loadUi(self.APPDIR + "/dialog_release_notes.ui", self.dialogue) upgradeButton = self.dialogue.buttonBox.button(QDialogButtonBox.Ok) upgradeButton.setText(_("Upgrade")) upgradeButton.setIcon(KIcon("dialog-ok")) cancelButton = self.dialogue.buttonBox.button(QDialogButtonBox.Cancel) cancelButton.setIcon(KIcon("dialog-cancel")) self.dialogue.setWindowTitle(_("Release Notes")) self.dialogue.show() if self.new_dist.releaseNotesURI is not None: uri = self._expandUri(self.new_dist.releaseNotesURI) # download/display the release notes # FIXME: add some progress reporting here result = None try: release_notes = urlopen(uri) notes = release_notes.read().decode("UTF-8", "replace") self.dialogue.scrolled_notes.setText(notes) result = self.dialogue.exec_() except HTTPError: primary = "<span weight=\"bold\" size=\"larger\">%s</span>" % \ _("Could not find the release notes") secondary = _("The server may be overloaded. ") KMessageBox.sorry(None, primary + "<br />" + secondary, "") except IOError: primary = "<span weight=\"bold\" size=\"larger\">%s</span>" % \ _("Could not download the release notes") secondary = _("Please check your internet connection.") KMessageBox.sorry(None, primary + "<br />" + secondary, "") # user clicked cancel if result == QDialog.Accepted: self.progressDialogue.show() return True if __name__ == "__main__": KApplication.kApplication().exit(1) if self.useDevelopmentRelease or self.useProposed: #FIXME why does KApplication.kApplication().exit() crash but # this doesn't? sys.exit() return False
def update_interface(self): # run the base class try: InstallProgress.update_interface(self) except ValueError as e: pass # log the output of dpkg (on the master_fd) to the DumbTerminal while True: try: (rlist, wlist, xlist) = select.select([self.master_fd],[],[], 0.01) # data available, read it if len(rlist) > 0: line = os.read(self.master_fd, 255) self.parent.konsole.insertWithTermCodes(utf8(line)) else: # nothing happend within the timeout, break break except Exception as e: logging.debug("update_interface: %s" % e) break KApplication.kApplication().processEvents()
def commit(self): # ui self.status.setText(_("Installing '%s'...") % os.path.basename(self.debfile)) # the command cmd = "/usr/bin/dpkg" argv = [cmd, "--auto-deconfigure", "-i", self.debfile] (self.child_pid, self.master_fd) = pty.fork() if self.child_pid == 0: os.environ["TERM"] = "dumb" if not "DEBIAN_FRONTEND" in os.environ: os.environ["DEBIAN_FRONTEND"] = "noninteractive" os.environ["APT_LISTCHANGES_FRONTEND"] = "none" exitstatus = subprocess.call(argv) os._exit(exitstatus) while True: #Read from pty and write to DumbTerminal try: (rlist, wlist, xlist) = select.select([self.master_fd],[],[], 0.001) if len(rlist) > 0: line = os.read(self.master_fd, 255) self.parent.konsole.insertWithTermCodes(utf8(line)) except Exception as e: #print e from errno import EAGAIN if hasattr(e, "errno") and e.errno == EAGAIN: continue break KApplication.kApplication().processEvents() # at this point we got a read error from the pty, that most # likely means that the client is dead (pid, status) = os.waitpid(self.child_pid, 0) self.exitstatus = os.WEXITSTATUS(status) self.progress.setValue(100) self.parent.closeButton.setEnabled(True) self.parent.closeButton.setVisible(True) self.parent.installationProgress.setVisible(False) QTimer.singleShot(1, self.parent.changeSize)
def __init__(self, datadir, options, file="", parent=None, name=None, modal=0, fl=0): GDebiKDEDialog.__init__(self,parent) GDebiCommon.__init__(self,datadir,options,file) # load the icon self.setWindowIcon(KIcon("application-x-deb")) # first, we load all the default descriptions -- pyuic doesn't use # gettext as default (FIXME, copy code from language-selector) self.textLabel1.setText(_("Package:")) self.textLabel1_2.setText(_("Status:")) self.detailsButton.setText(_("Details")) self.tabWidget2.setTabText(0,_("Description")) self.tabWidget2.setTabText(1,_("Details")) self.tabWidget2.setTabText(2,_("Included Files")) self.cancelButton.setText(__("kdelibs","&Cancel")) self.installButton.setText(_("&Install Package")) self.downloadButton.setText(_("&Download Package")) self.DetailsVersionLabel.setText(_("<b>Version:</b>")) self.DetailsMaintainerLabel.setText(_("<b>Maintainer:</b>")) self.DetailsPriorityLabel.setText(_("<b>Priority:</b>")) self.DetailsSectionLabel.setText(_("<b>Section:</b>")) self.DetailsSizeLabel.setText(_("<b>Size:</b>")) # translation finished self.setDisabled(True) self.PackageProgressBar.setEnabled(True) self.detailsButton.hide() self.downloadButton.hide() self.installButton.setIcon(KIcon("dialog-ok")) self.cancelButton.setIcon(KIcon("dialog-cancel")) self.show() self.kapp = KApplication.kApplication() #incidently, this stops it crashing on quit, no idea why, jriddell self.kapp.processEvents() #run because openCache takes a while to do its thing self.cprogress = CacheProgressAdapter(self.PackageProgressBar) if not self.openCache(): KMessageBox.error(self, '<b>' + self.error_header + '</b><br>' + self.error_body, self.error_header) sys.exit(1) # try to open the file if file != "" and os.path.exists(file): self.open(file) else: header = _("The package file does not exist") body = _("A nonexistent file has been selected for installation. Please select an existing .deb package file.") KMessageBox.error(self, '<b>' + header + '</b><br>' + body, header) sys.exit(1) self.setEnabled(True) self.PackageProgressBar.hide() self.connect(self.cancelButton, SIGNAL("clicked()"), self.cancelButtonClicked) self.connect(self.installButton, SIGNAL("clicked()"), self.installButtonClicked) self.connect(self.downloadButton, SIGNAL("clicked()"), self.downloadButtonClicked) self.connect(self.detailsButton, SIGNAL("clicked()"), self.detailsButtonClicked)
def update_interface(self): # run the base class try: InstallProgress.update_interface(self) except ValueError as e: pass # log the output of dpkg (on the master_fd) to the DumbTerminal while True: try: (rlist, wlist, xlist) = select.select([self.master_fd], [], [], 0.01) # data available, read it if len(rlist) > 0: line = os.read(self.master_fd, 255) self.parent.konsole.insertWithTermCodes(utf8(line)) else: # nothing happend within the timeout, break break except Exception as e: logging.debug("update_interface: %s" % e) break KApplication.kApplication().processEvents()
def __init__(self, parent): QDialog.__init__(self, parent) loadUi("GDebiKDEInstallDialog.ui", self) self.setWindowTitle(_("Installing")) self.showDetailsButton.setText(__("libept","Show Details")) #FIXME check i18n self.closeButton.setText(__("kdelibs","&Close")) self.showDetailsButton.setIcon(KIcon("utilities-terminal")) self.closeButton.setIcon(KIcon("window-close")) self.closeButton.setEnabled(False) self.closeButton.setVisible(False) self.parent = parent self.konsole = None self.konsoleFrameLayout = QHBoxLayout(self.konsoleFrame) self.konsoleFrame.hide() self.newKonsole() kapp = KApplication.kApplication() kapp.processEvents()
def __init__(self, parent): QDialog.__init__(self, parent) loadUi("GDebiKDEInstallDialog.ui", self) self.setWindowTitle(_("Installing")) self.showDetailsButton.setText(__("libept", "Show Details")) #FIXME check i18n self.closeButton.setText(__("kdelibs", "&Close")) self.showDetailsButton.setIcon(KIcon("utilities-terminal")) self.closeButton.setIcon(KIcon("window-close")) self.closeButton.setEnabled(False) self.closeButton.setVisible(False) self.parent = parent self.konsole = None self.konsoleFrameLayout = QHBoxLayout(self.konsoleFrame) self.konsoleFrame.hide() self.newKonsole() kapp = KApplication.kApplication() kapp.processEvents()
def close(self): self.accept() KApplication.kApplication().exit()
def update(self, percent=None): self.progressbar.show() if percent: self.progressbar.setValue(percent) KApplication.kApplication().processEvents()
def postEventWithCallback(self, callback, *args): self.queue.put((callback, args)) app = KApplication.kApplication() app.postEvent(self, QEvent(QEvent.User))
def __init__(self, datadir, options, file="", parent=None, name=None, modal=0, fl=0): GDebiKDEDialog.__init__(self, parent) GDebiCommon.__init__(self, datadir, options, file) # load the icon self.setWindowIcon(KIcon("application-x-deb")) # first, we load all the default descriptions -- pyuic doesn't use # gettext as default (FIXME, copy code from language-selector) self.textLabel1.setText(_("Package:")) self.textLabel1_2.setText(_("Status:")) self.detailsButton.setText(_("Details")) self.tabWidget2.setTabText(0, _("Description")) self.tabWidget2.setTabText(1, _("Details")) self.tabWidget2.setTabText(2, _("Included Files")) self.cancelButton.setText(__("kdelibs", "&Cancel")) self.installButton.setText(_("&Install Package")) self.downloadButton.setText(_("&Download Package")) self.DetailsVersionLabel.setText(_("<b>Version:</b>")) self.DetailsMaintainerLabel.setText(_("<b>Maintainer:</b>")) self.DetailsPriorityLabel.setText(_("<b>Priority:</b>")) self.DetailsSectionLabel.setText(_("<b>Section:</b>")) self.DetailsSizeLabel.setText(_("<b>Size:</b>")) # translation finished self.setDisabled(True) self.PackageProgressBar.setEnabled(True) self.detailsButton.hide() self.downloadButton.hide() self.installButton.setIcon(KIcon("dialog-ok")) self.cancelButton.setIcon(KIcon("dialog-cancel")) self.show() self.kapp = KApplication.kApplication( ) #incidently, this stops it crashing on quit, no idea why, jriddell self.kapp.processEvents( ) #run because openCache takes a while to do its thing self.cprogress = CacheProgressAdapter(self.PackageProgressBar) if not self.openCache(): KMessageBox.error( self, '<b>' + self.error_header + '</b><br>' + self.error_body, self.error_header) sys.exit(1) # try to open the file if file != "" and os.path.exists(file): self.open(file) else: header = _("The package file does not exist") body = _( "A nonexistent file has been selected for installation. Please select an existing .deb package file." ) KMessageBox.error(self, '<b>' + header + '</b><br>' + body, header) sys.exit(1) self.setEnabled(True) self.PackageProgressBar.hide() self.connect(self.cancelButton, SIGNAL("clicked()"), self.cancelButtonClicked) self.connect(self.installButton, SIGNAL("clicked()"), self.installButtonClicked) self.connect(self.downloadButton, SIGNAL("clicked()"), self.downloadButtonClicked) self.connect(self.detailsButton, SIGNAL("clicked()"), self.detailsButtonClicked)