def checkPath(path, conID): if(os.path.exists(path)): print("Using " + path + " as vpn config path.") infoDialog("This Tool will look for your VPN Connection settings at " + path + ". If you need to change this, use the Tool Menu. (Connection -> Tool Settings)") else: print("Error: File not found at " + path) nmPath = questionDialog("No file found at " + path + "\nPlease specify the NetworkManager path for VPN-Connection-Settings on your system.", defaultPath) path = nmPath + conID if not os.path.exists(path): errorDialog("Error: no VPN configfile found at " + path + ". Please make sure you entered the right values and created the PP VPN connection in NetworkManager and rerun this tool!") exit("Error: Setup failed (invalid VPN config file)") return path
def saveButtonClicked(self, widget): if self.get_title() == title + '*': self.mysql.saveChanges() dialog = dialogs.infoDialog(self, 'Books Saved', 'Saved Changes') self.set_title(title) dialog.run() dialog.destroy()
def initConfig(): # try to read tool configuration mainconfig = configparser.RawConfigParser() confpath = os.path.expanduser(defaultFile) if (os.path.exists(confpath) == False): print("\nConfigfile", confpath, "not found. Running Config Setup...") infoDialog("The configuration was not found at " + defaultFile + ". Starting Setup-Process...") conID = setID() path = defaultPath + conID # validate vpn config path and set editor path = checkPath(path, conID) vpntype = setvpnType() editor = setEditor() # write config file mainconfig.add_section('General') mainconfig.set('General', 'path', path) mainconfig.set('General', 'connection', conID) mainconfig.set('General', 'type', vpntype) mainconfig.set('General', 'editor', editor) if mainconfig.get('General', 'type') == "openvpn": mainconfig.add_section('Openvpn') mainconfig.set('Openvpn', 'certfolder', setOvpnFolder()) with open(confpath, 'w') as configfile: mainconfig.write(configfile) infoDialog("The configuration was written to \n" + confpath) print("Reading configuration...") checkConfig(mainconfig, confpath) return mainconfig
def newButtonClicked(self, widget): dialog = dialogs.newBookDialog(self) done = False bookTitle = '' author = '' done = '' typ = '' tags = [] while not done: response = dialog.run() if response == Gtk.ResponseType.CANCEL: dialog.destroy() return bookTitle = dialog.titleBox.get_text() author = dialog.authorBox.get_text() done = dialog.doneCombo.get_active() typ = dialog.typeCombo.get_active() tags = dialog.tagBox.get_text().split(',') if bookTitle == '' or author == '': info = dialogs.infoDialog(self, 'Enter Values', 'Please Fill out all Fields') info.run() info.destroy() else: done = True authorId = self.mysql.getAuthorId(author) if authorId is None: authorId = self.mysql.insertAuthor(author) if done == 0: done = True else: done = False if typ == 0: typ = 'fiction' else: typ = 'non-fiction' bookId = self.mysql.insertBook(bookTitle, authorId, done, typ) tagIds = [] for tag in tags: tagId = self.mysql.getTagId(tag) if tagId is None: tagId = self.mysql.insertTag(tag) tagIds.append(tagId) for tagId in tagIds: self.mysql.tagBook(bookId, tagId) if len(tags) == 0: self.bookList.append([bookId, bookTitle, author, done, typ, '']) else: self.bookList.append( [bookId, bookTitle, author, done, typ, ','.join(tags)]) self.set_title(title + '*') dialog.destroy()