Fixed File buttons on Bible Import

Fixed Proxy with HTTP bible
Save Proxy details in config

bzr-revno: 312
This commit is contained in:
Tim Bentley 2009-02-13 20:52:36 +00:00
parent 3202f28c1f
commit 94c66a12db
4 changed files with 55 additions and 18 deletions

View File

@ -75,18 +75,24 @@ class PluginUtils(object):
for i in range(int(newcount) , int(oldcount)):
self.config.delete_config("List Item "+str(i))
def _get_last_dir(self):
def _get_last_dir(self, num=None):
"""
Read the last directory used for plugin
"""
lastdir = self.config.get_config("Last Dir")
fld = "Last Dir"
if not num == None:
fld = fld+str(num)
lastdir = self.config.get_config(fld)
if lastdir==None:
lastdir = ""
return lastdir
def _save_last_directory(self, filename):
def _save_last_directory(self, filename, num=None):
"""
Save the last directory used for plugin
"""
"""
fld = "Last Dir"
if not num == None:
fld = fld+str(num)
path , nm = os.path.split(str(filename))
self.config.set_config("Last Dir", path)
self.config.set_config(fld, path)

View File

@ -37,6 +37,9 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
self.bibleplugin = bibleplugin
self.bibletype = None
self.barmax = 0
self.AddressEdit.setText(self.config.get_config("addressedit", ""))
self.UsernameEdit.setText(self.config.get_config("usernameedit", ""))
self.PasswordEdit.setText(self.config.get_config("passwordedit",""))
QtCore.QObject.connect(self.LocationComboBox, QtCore.SIGNAL("activated(int)"), self.onLocationComboBox)
QtCore.QObject.connect(self.TypeComboBox, QtCore.SIGNAL("activated(int)"), self.onTypeComboBox)
@ -51,16 +54,16 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
@pyqtSignature("")
def on_BooksFileButton_clicked(self):
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir())
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir(1))
self.BooksLocationEdit.setText(filename)
self._save_last_directory(filename)
self._save_last_directory(filename, 1)
self.setCSV()
@pyqtSignature("")
def on_OsisFileButton_clicked(self):
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir())
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir(2))
self.OSISLocationEdit.setText(filename)
self._save_last_directory(filename)
self._save_last_directory(filename, 2)
self.setOSIS()
def on_OSISLocationEdit_lostFocus(self):
@ -84,7 +87,20 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
if self.bibletype == "CSV": # Was CSV and is not any more stops lostFocus running mad
self.bibletype = None
self.freeAll()
@pyqtSignature("")
def on_AddressEdit_lostFocus(self):
self.config.set_config("addressedit", str(self.AddressEdit.displayText()))
@pyqtSignature("")
def on_UsernameEdit_lostFocus(self):
self.config.set_config("usernameedit", str(self.UsernameEdit.displayText()))
@pyqtSignature("")
def on_PasswordEdit_lostFocus(self):
self.config.set_config("passwordedit", str(self.PasswordEdit.displayText()))
def onLocationComboBox(self):
self._checkhttp()
@ -156,7 +172,11 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
self.biblemanager.register_csv_file_bible(str(self.BibleNameEdit.displayText()), self.BooksLocationEdit.displayText(), self.VerseLocationEdit.displayText())
else:
self.setMax(1) # set a value as it will not be needed
self.biblemanager.register_http_bible(str(self.BibleComboBox.currentText()),str(self.LocationComboBox.currentText()) )
self.biblemanager.register_http_bible(str(self.BibleComboBox.currentText()), \
str(self.LocationComboBox.currentText()), \
str(self.AddressEdit.displayText()), \
str(self.UsernameEdit .displayText()), \
str(self.PasswordEdit.displayText()))
self.BibleNameEdit.setText(str(self.BibleComboBox.currentText()))
self.biblemanager.save_meta_data(str(self.BibleNameEdit.displayText()), str(self.VersionNameEdit.displayText()), str(self.CopyrightEdit.displayText()), str(self.PermisionEdit.displayText()))

View File

@ -19,6 +19,7 @@ import logging
from openlp.plugins.bibles.lib.bibleDBimpl import BibleDBImpl
from openlp.plugins.bibles.lib.common import BibleCommon
from openlp.core.lib import Receiver
class BibleCSVImpl(BibleCommon):
@ -38,6 +39,7 @@ class BibleCSVImpl(BibleCommon):
fbooks=open(booksfile, 'r')
fverse=open(versesfile, 'r')
count = 0
for line in fbooks:
#log.debug( line)
p = line.split(",")
@ -45,6 +47,12 @@ class BibleCSVImpl(BibleCommon):
p2 = p[2].replace('"', '')
p3 = p[3].replace('"', '')
self.bibledb.create_book(p2, p3, int(p1))
count += 1
if count % 3 == 0: #Every x verses repaint the screen
Receiver().send_message("openlpprocessevents")
count = 0
count = 0
book_ptr = None
for line in fverse:
#log.debug( line)
@ -56,4 +64,7 @@ class BibleCSVImpl(BibleCommon):
book_ptr = book.name
dialogobject.incrementBar(book.name) # increament the progress bar
self.bibledb.add_verse(book.id, p[1], p[2], p3)
count += 1
if count % 3 == 0: #Every x verses repaint the screen
Receiver().send_message("openlpprocessevents")
count = 0

View File

@ -70,7 +70,7 @@ class BibleManager():
nhttp = BibleHTTPImpl()
nhttp.set_bible_source(biblesource.value) # tell The Server where to get the verses from.
self.bibleHTTPCache[bname] = nhttp
proxy = self.bibleDBCache[bname].get_meta("proxy") # look to see if lazy load bible exists and get create getter.
proxy = self.bibleDBCache[bname].get_meta("proxy").value # look to see if lazy load bible exists and get create getter.
nhttp.set_proxy(proxy) # tell The Server where to get the verses from.
else:
self.bibleHTTPCache[bname] = None # makes the Full / partial code easier.
@ -81,12 +81,12 @@ class BibleManager():
def process_dialog(self, dialogobject):
self.dialogobject = dialogobject
def register_http_bible(self, biblename, biblesource, mode="lazy", proxyurl=None, proxyid=None, proxypass=None):
def register_http_bible(self, biblename, biblesource, proxyurl=None, proxyid=None, proxypass=None):
"""
Return a list of bibles from a given URL.
The selected Bible can then be registered and LazyLoaded into a database
"""
log.debug( "register_HTTP_bible %s,%s,%s,%s,%s,%s", biblename, biblesource, proxyurl, proxyid, proxypass, mode)
log.debug( "register_HTTP_bible %s,%s,%s,%s,%s", biblename, biblesource, proxyurl, proxyid, proxypass)
if self._is_new_bible(biblename):
nbible = BibleDBImpl(self.biblePath, biblename, self.config) # Create new Bible
nbible.create_tables() # Create Database
@ -96,12 +96,12 @@ class BibleManager():
nhttp.set_bible_source(biblesource)
self.bibleHTTPCache[biblename] = nhttp
nbible.save_meta("WEB", biblesource) # register a lazy loading interest
if proxyurl != None:
if proxyurl != None and proxyurl != "":
nbible.save_meta("proxy", proxyurl) # store the proxy URL
nhttp.set_proxy(proxyurl)
if proxyid != None:
if proxyid != None and proxyid != "":
nbible.save_meta("proxyid", proxyid) # store the proxy userid
if proxypass != None:
if proxypass != None and proxypass != "":
nbible.save_meta("proxypass", proxypass) # store the proxy password