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)): for i in range(int(newcount) , int(oldcount)):
self.config.delete_config("List Item "+str(i)) 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 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: if lastdir==None:
lastdir = "" lastdir = ""
return lastdir return lastdir
def _save_last_directory(self, filename): def _save_last_directory(self, filename, num=None):
""" """
Save the last directory used for plugin 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)) 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.bibleplugin = bibleplugin
self.bibletype = None self.bibletype = None
self.barmax = 0 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.LocationComboBox, QtCore.SIGNAL("activated(int)"), self.onLocationComboBox)
QtCore.QObject.connect(self.TypeComboBox, QtCore.SIGNAL("activated(int)"), self.onTypeComboBox) QtCore.QObject.connect(self.TypeComboBox, QtCore.SIGNAL("activated(int)"), self.onTypeComboBox)
@ -51,16 +54,16 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
@pyqtSignature("") @pyqtSignature("")
def on_BooksFileButton_clicked(self): 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.BooksLocationEdit.setText(filename)
self._save_last_directory(filename) self._save_last_directory(filename, 1)
self.setCSV() self.setCSV()
@pyqtSignature("") @pyqtSignature("")
def on_OsisFileButton_clicked(self): 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.OSISLocationEdit.setText(filename)
self._save_last_directory(filename) self._save_last_directory(filename, 2)
self.setOSIS() self.setOSIS()
def on_OSISLocationEdit_lostFocus(self): def on_OSISLocationEdit_lostFocus(self):
@ -85,6 +88,19 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
self.bibletype = None self.bibletype = None
self.freeAll() 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): def onLocationComboBox(self):
self._checkhttp() 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()) self.biblemanager.register_csv_file_bible(str(self.BibleNameEdit.displayText()), self.BooksLocationEdit.displayText(), self.VerseLocationEdit.displayText())
else: else:
self.setMax(1) # set a value as it will not be needed 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.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())) 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.bibleDBimpl import BibleDBImpl
from openlp.plugins.bibles.lib.common import BibleCommon from openlp.plugins.bibles.lib.common import BibleCommon
from openlp.core.lib import Receiver
class BibleCSVImpl(BibleCommon): class BibleCSVImpl(BibleCommon):
@ -38,6 +39,7 @@ class BibleCSVImpl(BibleCommon):
fbooks=open(booksfile, 'r') fbooks=open(booksfile, 'r')
fverse=open(versesfile, 'r') fverse=open(versesfile, 'r')
count = 0
for line in fbooks: for line in fbooks:
#log.debug( line) #log.debug( line)
p = line.split(",") p = line.split(",")
@ -45,6 +47,12 @@ class BibleCSVImpl(BibleCommon):
p2 = p[2].replace('"', '') p2 = p[2].replace('"', '')
p3 = p[3].replace('"', '') p3 = p[3].replace('"', '')
self.bibledb.create_book(p2, p3, int(p1)) 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 book_ptr = None
for line in fverse: for line in fverse:
#log.debug( line) #log.debug( line)
@ -56,4 +64,7 @@ class BibleCSVImpl(BibleCommon):
book_ptr = book.name book_ptr = book.name
dialogobject.incrementBar(book.name) # increament the progress bar dialogobject.incrementBar(book.name) # increament the progress bar
self.bibledb.add_verse(book.id, p[1], p[2], p3) 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 = BibleHTTPImpl()
nhttp.set_bible_source(biblesource.value) # tell The Server where to get the verses from. nhttp.set_bible_source(biblesource.value) # tell The Server where to get the verses from.
self.bibleHTTPCache[bname] = nhttp 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. nhttp.set_proxy(proxy) # tell The Server where to get the verses from.
else: else:
self.bibleHTTPCache[bname] = None # makes the Full / partial code easier. self.bibleHTTPCache[bname] = None # makes the Full / partial code easier.
@ -81,12 +81,12 @@ class BibleManager():
def process_dialog(self, dialogobject): def process_dialog(self, dialogobject):
self.dialogobject = 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. Return a list of bibles from a given URL.
The selected Bible can then be registered and LazyLoaded into a database 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): if self._is_new_bible(biblename):
nbible = BibleDBImpl(self.biblePath, biblename, self.config) # Create new Bible nbible = BibleDBImpl(self.biblePath, biblename, self.config) # Create new Bible
nbible.create_tables() # Create Database nbible.create_tables() # Create Database
@ -96,12 +96,12 @@ class BibleManager():
nhttp.set_bible_source(biblesource) nhttp.set_bible_source(biblesource)
self.bibleHTTPCache[biblename] = nhttp self.bibleHTTPCache[biblename] = nhttp
nbible.save_meta("WEB", biblesource) # register a lazy loading interest 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 nbible.save_meta("proxy", proxyurl) # store the proxy URL
nhttp.set_proxy(proxyurl) nhttp.set_proxy(proxyurl)
if proxyid != None: if proxyid != None and proxyid != "":
nbible.save_meta("proxyid", proxyid) # store the proxy userid 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 nbible.save_meta("proxypass", proxypass) # store the proxy password