def __init__(self, parent): qt.QListView.__init__(self, parent) self.setRootIsDecorated(1) self.setSorting(-1) self.addColumn(kdecore.i18n('Name')) self.addColumn(kdecore.i18n('Value')) self.setColumnAlignment(1, qt.Qt.AlignRight) self.setColumnWidth(0, 100) self.setAllColumnsShowFocus(True) self.actions = actions = kdeui.KActionCollection(self) self.viewItemAction = \ util.buildAction('view_item', 'View', 'viewmag', '', 'View this item', actions) self.viewSourceAction = \ util.buildAction('view_source', 'View Source', 'source_py', '', 'View item source code', actions) self.separateAction = kdeui.KActionSeparator() self.saveAction = \ util.buildAction('save_item', 'Save', 'filesave', '', 'Save item', actions) self.popMenu = pop = qt.QPopupMenu(self) self.viewItemAction.plug(pop) self.viewSourceAction.plug(pop) self.separateAction.plug(pop) self.saveAction.plug(pop) sigAct = util.sigActivated self.connect(self, util.sigListContext, self.contextMenu) self.connect(self.viewItemAction, sigAct, self.viewItem) self.connect(self.viewSourceAction, sigAct, self.viewItemNodeSource) self.connect(self.saveAction, sigAct, self.saveItemNode)
def handler(self, signal, data): if len(data) > 1: args = data[1:] else: args = None if signal == "finished": command = str(data[0]) self.emit(PYSIGNAL("stepFinished(QString)"), (command,)) elif signal == "started": command = data[0] self.emit(PYSIGNAL("stepStarted(QString)"), (command,)) elif signal == "progress": print "progress" elif signal == "error": print "Error: ", str(data) elif signal == "status": if data[0] == "downloading": self.emit(PYSIGNAL("statusDownloading(int, int)"), (data[1], data[2])) elif data[0] == "installing": self.emit(PYSIGNAL("statusInstalling(QString, int, int)"), (data[1], data[2], data[3])) elif data[0] == "configuring": self.emit(PYSIGNAL("statusConfiguring()"), ()) elif signal == "warning": print "Warning: ", str(data) elif signal == "PolicyKit" and "policy.no" in data: message = i18n("You are not authorized for this operation.") KMessageBox.sorry(None, message, i18n("Error")) else: print "Got notification : %s with data : %s" % (signal, data)
def __init__(self, parent): QVBox.__init__(self, parent) widgets.HLine(i18n("Device:"), self) box = QWidget(self) g = QGridLayout(box, 2, 2, 6) g.setColStretch(0, 1) g.setColStretch(1, 10) lab = QLabel(i18n("Device:"), box) lab.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) g.addWidget(lab, 0, 0) self.device = QComboBox(False, box) self.device.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum) g.addWidget(self.device, 0, 1) self.remote_label = QLabel("", box) g.addWidget(self.remote_label, 1, 0) hb = QHBox(box) hb.setSpacing(3) hb.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum) self.remote = QComboBox(True, hb) hb.setStretchFactor(self.remote, 4) self.remote_scan = QPushButton(i18n("Scan"), hb) hb.setStretchFactor(self.remote_scan, 1) g.addWidget(hb, 1, 1)
def handleEvent(self,event): target = event.target().nodeName().string() try: #if checkbox is clicked, call SpecialList's slot if target == "INPUT": inputElement = DOM.HTMLInputElement(event.target()) name = inputElement.name().string() checked = inputElement.checked() # call parent to handle click event (in fact, parent emits this as a signal and its parent handles the signal) self.parent.slotCheckboxClicked(name, checked) elif target == "A": link = event.target().attributes().getNamedItem(DOM.DOMString("href")).nodeValue().string() if link == "#selectall": state = event.target().firstChild().nodeValue().string() reverseSelection = False if state == i18n("Select all packages in this category"): event.target().firstChild().setNodeValue(DOM.DOMString(i18n("Reverse package selections"))) else: reverseSelection = True event.target().firstChild().setNodeValue(DOM.DOMString(i18n("Select all packages in this category"))) # let the list do the rest self.parent.slotSelectAll(reverseSelection) else: self.parent.slotHomepageClicked(link) except Exception, e: print "Exception: " + str(e)
def copyItem(src, dst, progress): basename = os.path.basename(dst) dirname = os.path.dirname(dst) if basename in ignoreList: return if not os.path.exists(dirname): os.makedirs(dirname) if os.path.isfile(src): try: shutil.copy2(src, dst) except: progress.go( unicode(i18n("file '%s' cannot be copied")) % unicode(src), progress.WARNING, os.path.getsize(src)) else: progress.go( unicode(i18n("file '%s' copied")) % unicode(src), progress.OK, os.path.getsize(src)) elif os.path.isdir(src): if not os.path.exists(dst): os.makedirs(dst) files = os.listdir(src) for item in files: newdst = os.path.join(dst, item) newsrc = os.path.join(src, item) copyItem(newsrc, newdst, progress)
def __init__(self, parent, fileLocation): QWidget.__init__(self, parent) self.pspec = spec.SpecFile() self.fileLocation = fileLocation self.xmlUtil = XmlUtil(fileLocation) self.pspec.read(self.fileLocation) # code and design buttons self.pbDesign = KPushButton(i18n("Design"), self) self.pbDesign.setToggleButton(True) self.pbDesign.setOn(True) self.pbDesign.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) self.pbCode = KPushButton(i18n("Code"), self) self.pbCode.setToggleButton(True) self.pbCode.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) # top of the widget - buttons and spacer mainLayout = QVBoxLayout(self, 5, 5) topLayout = QHBoxLayout(mainLayout) topLayout.addWidget(self.pbDesign) topLayout.addWidget(self.pbCode) topSpacer = QSpacerItem(200,20, QSizePolicy.Expanding) topLayout.addItem(topSpacer) # a widget stack controlled by "design" and "code" buttons self.widgetStack = QWidgetStack(self) mainLayout.addWidget(self.widgetStack) # toolbox of "source", "package(s)" and history self.toolBox = QToolBox(self.widgetStack) self.toolBox.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) # source section of toolbox self.sourcePage = sourceWidget(self.toolBox, self.fileLocation, self.xmlUtil) # packages section of toolbox self.packagePage = packageWidget(self.toolBox, self.fileLocation, self.xmlUtil) # history section of toolbox self.historyPage = historyWidget(self.toolBox, self.xmlUtil) # inclusion to toolbox self.toolBox.addItem(self.sourcePage, i18n("Source")) self.toolBox.addItem(self.packagePage, i18n("Package(s)")) self.toolBox.addItem(self.historyPage, i18n("History")) self.widgetStack.addWidget(self.toolBox, 0) self.editor = ed("xml", self.widgetStack) self.widgetStack.addWidget(self.editor, 1) # connections self.connect(self.pbDesign, SIGNAL("clicked()"), self.pbDesignClicked) self.connect(self.pbCode, SIGNAL("clicked()"), self.pbCodeClicked) self.changeCount = 0 self.change = False if self.fileLocation != None: self.fill()
def notify(self, event, **keywords): cEvent = QCustomEvent(CustomEvent.PisiNotify) data = None if event == pisi.ui.downloading: data = i18n("downloading") elif event == pisi.ui.installing: data = i18n("installing") elif event == pisi.ui.configuring: data = i18n("configuring") elif event == pisi.ui.extracting: data = i18n("extracting") elif event == pisi.ui.removing: data = i18n("removing") elif event == pisi.ui.installed: data = "installed" elif event == pisi.ui.removed: data = "removed" elif event == pisi.ui.upgraded: data = "upgraded" elif event == pisi.ui.packagestogo: data = keywords["order"] else: return cEvent.setData(data) QThread.postEvent(self.receiver,cEvent)
def __init__(self, parent, fileLocation): QWidget.__init__(self, parent) self.pspec = spec.SpecFile() self.fileLocation = fileLocation self.xmlUtil = XmlUtil(fileLocation) self.pspec.read(self.fileLocation) # code and design buttons self.pbDesign = KPushButton(i18n("Design"), self) self.pbDesign.setToggleButton(True) self.pbDesign.setOn(True) self.pbDesign.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) self.pbCode = KPushButton(i18n("Code"), self) self.pbCode.setToggleButton(True) self.pbCode.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) # top of the widget - buttons and spacer mainLayout = QVBoxLayout(self, 5, 5) topLayout = QHBoxLayout(mainLayout) topLayout.addWidget(self.pbDesign) topLayout.addWidget(self.pbCode) topSpacer = QSpacerItem(200, 20, QSizePolicy.Expanding) topLayout.addItem(topSpacer) # a widget stack controlled by "design" and "code" buttons self.widgetStack = QWidgetStack(self) mainLayout.addWidget(self.widgetStack) # toolbox of "source", "package(s)" and history self.toolBox = QToolBox(self.widgetStack) self.toolBox.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) # source section of toolbox self.sourcePage = sourceWidget(self.toolBox, self.fileLocation, self.xmlUtil) # packages section of toolbox self.packagePage = packageWidget(self.toolBox, self.fileLocation, self.xmlUtil) # history section of toolbox self.historyPage = historyWidget(self.toolBox, self.xmlUtil) # inclusion to toolbox self.toolBox.addItem(self.sourcePage, i18n("Source")) self.toolBox.addItem(self.packagePage, i18n("Package(s)")) self.toolBox.addItem(self.historyPage, i18n("History")) self.widgetStack.addWidget(self.toolBox, 0) self.editor = ed("xml", self.widgetStack) self.widgetStack.addWidget(self.editor, 1) # connections self.connect(self.pbDesign, SIGNAL("clicked()"), self.pbDesignClicked) self.connect(self.pbCode, SIGNAL("clicked()"), self.pbCodeClicked) self.changeCount = 0 self.change = False if self.fileLocation != None: self.fill()
def monitor(self, fileName): """Start monitoring a file.""" try: tailer = Tail(fileName) except: KMessageBox.error(self, str(i18n("Cannot open file for monitoring:\n%s")) % fileName, makeCaption("Error")) return mon = Monitor(self.tab, tailer) base = os.path.basename(fileName) self.monitors.append(mon) self.tab.addTab(mon, base) self.tab.showPage(mon) self.tab.setTabToolTip(mon, fileName) self.currentPage = mon self.setCaption(makeCaption(base)) self.displayStatus(False, str(i18n("Monitoring %s")) % fileName) self.connect(self.timer, SIGNAL("timeout()"), mon.follow) self.saveFileList() self.connect(mon, SIGNAL("copyAvailable(bool)"), self.onCopyAvailable) self.closeAction.setEnabled(True) self.copyAction.setEnabled(False) self.clearAction.setEnabled(True) self.selectAllAction.setEnabled(True) self.addBookmarkAction.setEnabled(True) self.findAction.setEnabled(True) self.findNextAction.setEnabled(True) self.findPrevAction.setEnabled(True)
def __init__(self, parent): QVBox.__init__(self, parent) widgets.HLine(i18n("Network:"), self) box = QWidget(self) g = QGridLayout(box, 2, 2, 6) group = QButtonGroup() self.group = group group.setExclusive(True) self.connect(group, SIGNAL("clicked(int)"), self.slotClicked) self.r1 = QRadioButton(i18n("Automatic query (DHCP)"), box) g.addMultiCellWidget(self.r1, 0, 0, 0, 1) group.insert(self.r1, 0) self.r2 = QRadioButton(i18n("Manual"), box) g.addWidget(self.r2, 1, 0, g.AlignTop) group.insert(self.r2, 1) g2 = QGridLayout(2, 2, 6) g.addLayout(g2, 1, 1) lab = QLabel(i18n("Address:"), box) g2.addWidget(lab, 0, 0) self.address = widgets.Edit(box) g2.addWidget(self.address, 0, 1) lab = QLabel(i18n("Gateway:"), box) g2.addWidget(lab, 1, 0) self.gateway = widgets.Edit(box) g2.addWidget(self.gateway, 1, 1) self.slotSwitch("auto")
def slotComar(self, sock): try: reply = self.comar.com.read_cmd() except: if not self.wait_comar(): self.comar.com_lock.unlock() self.parent.showErrorMessage(i18n("Can't connect to Comar daemon")) self.parent.resetState() self.parent.refreshState() else: self.comar = ComarIface.ComarIface(self) return if reply.command == "notify": (notification, script, data) = (reply.notify, reply.script, reply.data) data = unicode(data) if notification == "System.Manager.error": self.comar.com_lock.unlock() self.parent.showErrorMessage(data) self.parent.resetState() self.parent.refreshState() elif notification == "System.Manager.notify": self.parent.pisiNotify(data) elif notification == "System.Manager.progress": self.parent.displayProgress(data) elif notification == "System.Manager.finished": self.comar.com_lock.unlock() self.parent.finished(data) elif notification == "System.Manager.updatingRepo": pass else: print "Got notification : %s , for script : %s , with data : %s" % (notification, script, data) # This is paranoia. We dont know what happened but we cancel what ever is being done, gracefully. If # some misbehaviour is seen, comar.log is always there to look. elif reply.command == "error": self.comar.com_lock.unlock() self.parent.finished("System.Manager.cancelled") return elif reply.command == "denied": self.comar.com_lock.unlock() self.parent.finished("System.Manager.cancelled") self.parent.showErrorMessage(i18n("You do not have permission to do this operation.")) elif reply.command == "fail": if reply.data == "System.Manager.cancelled": self.comar.com_lock.unlock() self.parent.finished(reply.data) return self.comar.com_lock.unlock() self.parent.finished() self.parent.resetState() self.parent.refreshState() self.parent.showErrorMessage(unicode(reply.data)) # if an error occured communicating with comar and components are not ready we quit if not pisi.context.componentdb.list_components(): self.parent.repoNotReady() else: # paranoia self.comar.com_lock.unlock() pass
def setupBusses(self): try: self.sysBus = dbus.SystemBus() self.sesBus = dbus.SessionBus() except dbus.DBusException: KMessageBox.error(None, i18n("Unable to connect to DBus."), i18n("DBus Error")) return False return True
def showHideBrowser(self): if self.infoBrowser.isShown(): self.showButton.setText(i18n("Show more information >>")) self.infoBrowser.hide() else: self.showButton.setText(i18n("Show less information <<")) self.infoBrowser.show() self.adjustSize()
def clearAllCached(self): if KMessageBox.Yes == KMessageBox.warningYesNo(self, i18n("All the cached packages will be deleted. Are you sure? "), i18n("Warning"), KGuiItem(i18n("Delete"), "trashcan_empty"), KStdGuiItem.cancel() ): self.parent.command.clearCache(0)
def monitor(self, fileName): try: tailer = Tail(fileName) except: KMessageBox.error(self, str(i18n("Cannot open file for monitoring:\n%s")) % fileName, i18n("Error - lovi")) return self.tab.addTab(Monitor(tailer), os.path.basename(fileName))
def initMenus(self): fileMenu = QPopupMenu(self) self.openAction.plug(fileMenu) fileMenu.insertSeparator() self.quitAction.plug(fileMenu) self.menuBar().insertItem(i18n("&File"), fileMenu) helpMenu = self.helpMenu("") self.menuBar().insertItem(i18n("&Help"), helpMenu)
def comarError(self, exception): if "urlopen error" in exception.message or "Socket Error" in exception.message: KMessageBox.error(None, i18n("Network error. Please check your network connections and try again."), i18n("COMAR Error")) elif "Access denied" in exception.message: message = i18n("You are not authorized for this operation.") KMessageBox.sorry(None, message, i18n("Error")) else: KMessageBox.error(None, QString.fromUtf8(str(exception)), i18n("COMAR Error")) self.errHandler()
def monitor(self, fileName): try: tailer = Tail(fileName) except: KMessageBox.error( self, str(i18n("Cannot open file for monitoring:\n%s")) % fileName, i18n("Error - lovi")) return self.tab.addTab(Monitor(tailer), os.path.basename(fileName))
def __init__(self, *args): apply(KMainWindow.__init__, (self,) + args) self.lastDir = "/var/log" self.setGeometry(0, 0, 600, 400) # self.grid = QGridLayout(self, 1, 1) self.tab = QTabWidget(self) self.tab.addTab(QMultiLineEdit(self.tab), "Tab") self.layout().addWidget(self.tab, 0, 0) self.setCaption(str(i18n("%s - lovi")) % str(i18n("(none)"))) self.initActions() self.initMenus()
def __init__(self, *args): apply(KMainWindow.__init__, (self, ) + args) self.lastDir = "/var/log" self.setGeometry(0, 0, 600, 400) # self.grid = QGridLayout(self, 1, 1) self.tab = QTabWidget(self) self.tab.addTab(QMultiLineEdit(self.tab), "Tab") self.layout().addWidget(self.tab, 0, 0) self.setCaption(str(i18n("%s - lovi")) % str(i18n("(none)"))) self.initActions() self.initMenus()
def buildAction(name, label, icon, accel, tip, collection): """ buildAction(...) -> create and configure a KAction child """ action = kdeui.KAction(collection, name) action.setShortcut(kdecore.KShortcut(accel)) action.setIconSet(loadIconSet(icon)) action.setIcon(icon) action.setText(kdecore.i18n(label)) action.setToolTip(kdecore.i18n(tip)) collection.insert(action) return action
def __init__(self, section): if section != noProxy: self.name = unicode(section) else: self.name = i18n("No Proxy") self.section = section self.comment = "" if config.has_section(self.section): # General properties self.type = config.get(self.section, "type") self.isActive = config.getboolean(self.section, "isActive") self.cleanProperties() if config.has_option(self.section, "user"): self.user = config.get(self.section, "user") if config.has_option(self.section, "pasw"): self.pasw = config.get(self.section, "pasw") # Protocol dependent properties if self.type == direct: self.comment = comment_direct elif self.type == globl: self.has_globl_port = config.has_option(self.section, "globl_port") self.globl_host = config.get(self.section, "globl_host") if self.has_globl_port: self.globl_port = config.get(self.section, "globl_port") self.comment = comment_globl + " " + self.globl_host elif self.type == indiv: self.comment = i18n("Protocols: ") self.has_http = config.has_option(self.section, "http_host") self.has_ftp = config.has_option(self.section, "ftp_host") self.has_ssl = config.has_option(self.section, "ssl_host") self.has_socks = config.has_option(self.section, "socks_host") if self.has_http: self.http_host = config.get(self.section, "http_host") self.http_port = config.get(self.section, "http_port") self.comment += " " + comment_http + ":" + self.http_host if self.has_ftp: self.ftp_host = config.get(self.section, "ftp_host") self.ftp_port = config.get(self.section, "ftp_port") self.comment += " " + comment_ftp + ":" + self.ftp_host if self.has_ssl: self.ssl_host = config.get(self.section, "ssl_host") self.ssl_port = config.get(self.section, "ssl_port") self.comment += " " + comment_ssl + ":" + self.ssl_host if self.has_socks: self.socks_host = config.get(self.section, "socks_host") self.socks_port = config.get(self.section, "socks_port") self.comment += " " + comment_socks + ":" + self.socks_host elif self.type == auto: self.auto_url = config.get(self.section, "auto_url") self.comment = comment_auto else: self.isActive = False self.cleanProperties()
def designWillOpen(self): qApp.setOverrideCursor(KCursor.workingCursor()) try: self.syncFromCode() except Exception, err: qApp.restoreOverrideCursor() KMessageBox.sorry( self, i18n("Specification is not valid or well-formed: %s" % err), i18n("Invalid XML Code") ) self.pbDesign.setOn(False) self.pbCode.setOn(True) return
def __init__(self, parent, name, link_name, is_new=0): QMainWindow.__init__(self, parent) self.name = name self.link_name = link_name self.setCaption(i18n("Configure network connection")) self.setMinimumSize(620, 420) vb = QVBox(self) vb.setMargin(6) vb.setSpacing(6) self.setCentralWidget(vb) tab = QTabWidget(vb) self.basic = BasicTab(tab) tab.addTab(self.basic, i18n("Basic")) #self.auth = AuthTab(tab) #tab.addTab(self.auth, "Authentication") hb = QHBox(vb) hb.setSpacing(12) but = QPushButton(i18n("Cancel"), hb) self.connect(but, SIGNAL("clicked()"), self.slotCancel) but = QPushButton(i18n("Accept"), hb) self.connect(but, SIGNAL("clicked()"), self.slotAccept) self.w_name = self.basic.name.edit self.w_device = self.basic.device.device self.w_address = self.basic.address.address.edit self.w_gateway = self.basic.address.gateway.edit self.w_remote = self.basic.device.remote.edit self.device_list = {} self.show() self.w_name.setText(unicode(name)) self.comar = comar.Link() self.comar.call_package("Net.Link.modes", link_name, id=3) if is_new: self.device = i18n("No device") self.comar.call_package("Net.Link.deviceList", link_name, id=1) else: self.comar.call_package("Net.Link.getAddress", link_name, [ "name", name ], id=2) self.comar.call_package("Net.Link.connectionInfo", link_name, [ "name", name ], id=4) self.notifier = QSocketNotifier(self.comar.sock.fileno(), QSocketNotifier.Read) self.connect(self.notifier, SIGNAL("activated(int)"), self.slotComar)
def updateRepoSettings(self): # FIXME there should be a better way to do this newRepoName = str(self.repo.repoName.text()) newRepoAddress = str(self.repo.repoAddress.text()) if not newRepoName.endswith("xml"): KMessageBox.error(self,i18n('Repository address is wrong!'), i18n("Pisi Error")) return else: pisi.api.remove_repo(self.oldRepoName) pisi.api.add_repo(newRepoName,newRepoAddress) self.updateListView() self.repo.close()
def notify(self, event, **keywords): cEvent = QCustomEvent(CustomEvent.PisiNotify) data = None if event == pisi.ui.installing: data = i18n("installing") elif event == pisi.ui.configuring: data = i18n("configuring") elif event == pisi.ui.extracting: data = i18n("extracting") elif event == pisi.ui.removing: data = i18n("removing") if data: cEvent.setData(data) QThread.postEvent(self.receiver,cEvent)
def processNewRepo(self): repoName = str(self.repo.repoName.text()) repoAddress = str(self.repo.repoAddress.text()) if not repoAddress.endswith("xml"): KMessageBox.error(self,i18n('<qt>Repository address should end with xml suffix.<p>Please try again.</qt>'), i18n("Pisi Error")) return else: self.parent.command.addRepo(repoName,repoAddress) self.repo.close() confirm = KMessageBox.questionYesNo(self,i18n('<qt>Do you want to update repository <b>%1</b></qt>').arg(repoName),i18n("Pisi Question")) if confirm == KMessageBox.Yes: self.parent.command.updateRepo(repoName)
def slotOpen(self, id=-1): fileName = KFileDialog.getOpenFileName(self.lastDir, "*", self, str(i18n("Open Log File"))) print fileName if not fileName.isEmpty(): self.lastDir = os.path.dirname(str(fileName)) self.monitor(str(fileName))
def slotFile(self): self.realLoc = KFileDialog.getOpenFileName(QString.null, QString.null, self, i18n("Select COMAR Script")) if not self.realLoc or str(self.realLoc).strip() == "": return self.leFile.setText(os.path.split(str(self.realLoc))[1])
def displayException(parent, title, exception): """ displayException(parent, title, exception) -> show an error message box """ text = kdecore.i18n(title) details = '%s\n%r' % (exception, exception,) kdeui.KMessageBox.detailedError(parent, text, details)
def addNewRepo(self): self.repo = RepoDialog.RepoDialog(self) self.repo.setCaption(i18n("Add New Repository")) self.repo.setModal(True) self.connect(self.repo.okButton, SIGNAL("clicked()"), self.processNewRepo) self.repo.show()
def main(): """Main program.""" description = str(i18n("Simple log file viewer")) version = "0.3" about = KAboutData("lovi", "lovi", version, description, KAboutData.License_GPL, "Copyright (C) 2005-2006 by Akos Polster") about.addAuthor("Akos Polster", "", "*****@*****.**") KCmdLineArgs.init(sys.argv, about) KCmdLineArgs.addCmdLineOptions([("+files", "Files to monitor")]) app = KApplication() mainWindow = MainWin(None, "lovi#") app.setMainWidget(mainWindow) # Get list of monitored files from the command line or from the cfg file args = KCmdLineArgs.parsedArgs() if args.count() > 0: for i in range(0, args.count()): mainWindow.monitor(args.arg(i)) else: cfg = app.config() cfg.setGroup("Monitor") files = cfg.readListEntry("files") for f in files: mainWindow.monitor(str(f)) mainWindow.show() app.exec_loop()
def slotOpen(self, id = -1): fileName = KFileDialog.getOpenFileName(self.lastDir, "*", self, str(i18n("Open Log File"))) print fileName if not fileName.isEmpty(): self.lastDir = os.path.dirname(str(fileName)) self.monitor(str(fileName))
def saveSettings(self): self.parent.settings.setValue(Settings.general, "ShowOnlyGuiApp", self.onlyGuiApp.isChecked()) self.parent.settings.setValue(Settings.general, "SystemTray", self.systemTray.isChecked()) self.parent.settings.setValue(Settings.general, "UpdateCheck", self.intervalCheck.isChecked()) self.parent.settings.setValue(Settings.general, "UpdateCheckInterval", self.intervalSpin.value()) self.setCacheSettings(self.useCacheCheck.isChecked(), self.useCacheSize.value()) if self.intervalCheck.isChecked(): self.parent.parent.tray.updateInterval(self.intervalSpin.value()) else: self.parent.parent.tray.updateInterval(0) if self.reposChanged: repoList = [] item = self.repoListView.firstChild() while item: repoList.append(unicode(item.text(0))) repoList.append(str(item.text(1))) item = item.nextSibling() self.reposChanged = False self.parent.command.setRepositories(repoList) self.parent.progressDialog.setCurrentOperation(i18n("<b>Applying Repository Changes</b>")) self.parent.progressDialog.show() return self.parent.refreshState()
def slotComar(self, sock): try: reply = self.comar.com.read_cmd() except: if not self.wait_comar(): self.parent.showErrorMessage(i18n("Can't connect to Comar daemon")) else: self.comar = ComarIface.ComarIface(self) return if reply[0] == self.comar.com.NOTIFY: notification, script, data = reply[2].split("\n", 2) data = unicode(data) if notification == "System.Manager.error": self.parent.showErrorMessage(data) elif notification == "System.Manager.notify": self.parent.pisiNotify(data) elif notification == "System.Manager.progress": self.parent.displayProgress(data) elif notification == "System.Manager.finished": self.parent.finished(data) elif notification == "System.Manager.updatingRepo": pass else: print "Got notification : %s , for script : %s , with data : %s" % (notification, script, data) elif reply[0] == self.comar.com.FAIL: self.parent.finished() self.parent.showErrorMessage(unicode(reply[2])) if self.parent.initialRepoCheck: self.parent.initialRepoCheck = False self.parent.repoMetadataCheck() else: pass
def checkObsoletes(self): obsoletes = pisiiface.getObsoletedList() message = i18n( "<qt>Following packages are obsoleted and are not maintained anymore in Pardus 2009 repositories. These packages are going to be removed from your system." ) message += i18n("<br><br>Do you want to continue?</qt>") if KMessageBox.Yes == KMessageBox.warningYesNoList( self.parent, message, QStringList.fromStrList(obsoletes), i18n("Warning"), KGuiItem(i18n("Continue"), "ok"), KGuiItem(i18n("Cancel"), "no"), ): return True
def displayException(parent, title, exception): """ displayException(parent, title, exception) -> show an error message box """ text = kdecore.i18n(title) details = '%s\n%r' % ( exception, exception, ) kdeui.KMessageBox.detailedError(parent, text, details)
def designWillOpen(self): qApp.setOverrideCursor(KCursor.workingCursor()) try: self.syncFromCode() except Exception, err: qApp.restoreOverrideCursor() KMessageBox.sorry(self, i18n("Specification is not valid or well-formed: %s" % err), i18n("Invalid XML Code")) self.pbDesign.setOn(False) self.pbCode.setOn(True) return
def save(): active = None for p in profiles: p.save() if p.isActive: active = p f = open(configPath,"w") config.write(f) f.close() f = open(proxyPath,"w") lines = [i18n("# Do not edit this unless you know how proxy-manager works.\n")] auth = "" if active.user: auth = active.user if active.pasw: auth += ":" + active.pasw auth += "@" line = "http_proxy=" if active.type == globl: port = "" if active.globl_port: port = ":" + active.globl_port lines.append("http_proxy=" + auth + active.globl_host + port + "\n") lines.append("https_proxy=" + auth + active.globl_host + port + "\n") lines.append("ftp_proxy=" + auth + active.globl_host + port + "\n") elif active.type == globl: lines.append("http_proxy=\n") lines.append("https_proxy=\n") lines.append("ftp_proxy=\n") else: if active.http_host: line += auth + active.http_host if active.http_port: line += ":" + active.http_port lines.append(line + "\n") line = "https_proxy=" if active.ssl_host: line += auth + active.ssl_host if active.ssl_port: line += ":" + active.ssl_port lines.append(line + "\n") line = "ftp_proxy=" if active.ftp_host: line += auth + active.ftp_host if active.ftp_port: line += ":" + active.ftp_port lines.append(line + "\n") f.writelines(lines) f.close()
# -*- coding: utf-8 -*- # # Copyright (C) 2006-2007, TUBITAK/UEKAE # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. Please read the COPYING file. from os import path, mkdir import ConfigParser from kdecore import i18n # Constants comment_direct = i18n("Direct connection") comment_globl = i18n("Global proxy: ") comment_http = i18n("HTTP") comment_ftp = i18n("FTP") comment_ssl = i18n("SSL") comment_socks = i18n("SOCKS") comment_auto = i18n("Auto configuration file.") direct = "0" globl = "1" indiv = "2" auto = "3" noProxy = "noproxy" config = ConfigParser.SafeConfigParser() configDir = path.expanduser("~/.proxy/") configPath = configDir +"proxy-manager"
@param fileName File to monitor """ def monitor(self, fileName): try: tailer = Tail(fileName) except: KMessageBox.error( self, str(i18n("Cannot open file for monitoring:\n%s")) % fileName, i18n("Error - lovi")) return self.tab.addTab(Monitor(tailer), os.path.basename(fileName)) """ Main program. """ description = str(i18n("Simple log file viewer")) version = "0.1" about = KAboutData("", "", \ version, description, KAboutData.License_GPL, \ "(C) 2005 Akos Polster") about.addAuthor("Akos Polster", "", "*****@*****.**") KCmdLineArgs.init(sys.argv, about) # KCmdLineArgs.addCmdLineOptions([("+files", "File to open")]) app = KApplication() mainWindow = MainWin(None, "lovi#") mainWindow.show() app.exec_loop()