GuiImapFetcher can save config
This commit is contained in:
parent
97f1f8b836
commit
59f8bb1a70
|
@ -736,6 +736,12 @@ class Config:
|
||||||
if site_node.getAttribute("site_name") == site:
|
if site_node.getAttribute("site_name") == site:
|
||||||
return site_node
|
return site_node
|
||||||
|
|
||||||
|
def getEmailNode(self, siteName, fetchType):
|
||||||
|
for emailNode in self.doc.getElementsByTagName("email"):
|
||||||
|
if emailNode.getAttribute("siteName") == siteName and emailNode.getAttribute("fetchType") == fetchType:
|
||||||
|
return emailNode
|
||||||
|
#end def getEmailNode
|
||||||
|
|
||||||
def getGameNode(self,gameName):
|
def getGameNode(self,gameName):
|
||||||
"""returns DOM game node for a given game"""
|
"""returns DOM game node for a given game"""
|
||||||
for gameNode in self.doc.getElementsByTagName("game"):
|
for gameNode in self.doc.getElementsByTagName("game"):
|
||||||
|
@ -810,6 +816,15 @@ class Config:
|
||||||
else:
|
else:
|
||||||
return(l)
|
return(l)
|
||||||
|
|
||||||
|
def editEmail(self, siteName, fetchType, newEmail):
|
||||||
|
emailNode = self.getEmailNode(siteName, fetchType)
|
||||||
|
emailNode.setAttribute("host", newEmail.host)
|
||||||
|
emailNode.setAttribute("username", newEmail.username)
|
||||||
|
emailNode.setAttribute("password", newEmail.password)
|
||||||
|
emailNode.setAttribute("folder", newEmail.folder)
|
||||||
|
emailNode.setAttribute("useSsl", newEmail.useSsl)
|
||||||
|
#end def editEmail
|
||||||
|
|
||||||
def edit_layout(self, site_name, max, width = None, height = None,
|
def edit_layout(self, site_name, max, width = None, height = None,
|
||||||
fav_seat = None, locations = None):
|
fav_seat = None, locations = None):
|
||||||
site_node = self.get_site_node(site_name)
|
site_node = self.get_site_node(site_name)
|
||||||
|
|
|
@ -31,22 +31,20 @@ class GuiImapFetcher (threading.Thread):
|
||||||
self.buttonsHBox = gtk.HBox()
|
self.buttonsHBox = gtk.HBox()
|
||||||
self.mainVBox.pack_end(self.buttonsHBox, expand=False)
|
self.mainVBox.pack_end(self.buttonsHBox, expand=False)
|
||||||
|
|
||||||
label=gtk.Label("To cancel just close this tab")
|
label=gtk.Label("To cancel just close this tab.")
|
||||||
self.buttonsHBox.add(label)
|
self.buttonsHBox.add(label)
|
||||||
|
|
||||||
self.saveButton = gtk.Button("_Save (doesn't work yet)")
|
self.saveButton = gtk.Button("_Save")
|
||||||
self.saveButton.connect('clicked', self.saveClicked)
|
self.saveButton.connect('clicked', self.saveClicked)
|
||||||
self.buttonsHBox.add(self.saveButton)
|
self.buttonsHBox.add(self.saveButton)
|
||||||
|
|
||||||
self.runAllButton = gtk.Button("_Run All")
|
self.importAllButton = gtk.Button("_Import All")
|
||||||
self.runAllButton.connect('clicked', self.runAllClicked)
|
self.importAllButton.connect('clicked', self.importAllClicked)
|
||||||
self.buttonsHBox.add(self.runAllButton)
|
self.buttonsHBox.add(self.importAllButton)
|
||||||
|
|
||||||
self.statusLabel=gtk.Label("Please edit your config if you wish and then click Run All")
|
self.statusLabel=gtk.Label("If you change the config you must save before importing")
|
||||||
self.mainVBox.pack_end(self.statusLabel, expand=False, padding=4)
|
self.mainVBox.pack_end(self.statusLabel, expand=False, padding=4)
|
||||||
|
|
||||||
self.rowVBox = gtk.VBox()
|
|
||||||
self.mainVBox.add(self.rowVBox)
|
|
||||||
|
|
||||||
self.displayConfig()
|
self.displayConfig()
|
||||||
|
|
||||||
|
@ -54,15 +52,39 @@ class GuiImapFetcher (threading.Thread):
|
||||||
#end def __init__
|
#end def __init__
|
||||||
|
|
||||||
def saveClicked(self, widget, data=None):
|
def saveClicked(self, widget, data=None):
|
||||||
pass
|
row = self.rowVBox.get_children()
|
||||||
|
columns=row[0].get_children() #TODO: make save capable of handling multiple email entries - not relevant yet as only one entry is useful atm. The rest of this tab works fine for multiple entries though
|
||||||
|
|
||||||
|
siteName=columns[0].get_text()
|
||||||
|
fetchType=columns[1].get_text()
|
||||||
|
code=siteName+"_"+fetchType
|
||||||
|
|
||||||
|
for email in self.config.emails:
|
||||||
|
toSave=self.config.emails[email]
|
||||||
|
break
|
||||||
|
toSave.siteName=siteName
|
||||||
|
toSave.fetchType=fetchType
|
||||||
|
|
||||||
|
toSave.host=columns[2].get_text()
|
||||||
|
toSave.username=columns[3].get_text()
|
||||||
|
toSave.password=columns[4].get_text()
|
||||||
|
toSave.folder=columns[5].get_text()
|
||||||
|
|
||||||
|
if columns[6].get_active() == 0:
|
||||||
|
toSave.useSsl="True"
|
||||||
|
else:
|
||||||
|
toSave.useSsl="False"
|
||||||
|
|
||||||
|
self.config.editEmail(siteName, fetchType, toSave)
|
||||||
|
self.config.save()
|
||||||
#def saveClicked
|
#def saveClicked
|
||||||
|
|
||||||
def runAllClicked(self, widget, data=None):
|
def importAllClicked(self, widget, data=None):
|
||||||
self.statusLabel.set_label("Starting import. Please wait.") #FIXME: why doesnt this one show?
|
self.statusLabel.set_label("Starting import. Please wait.") #FIXME: why doesnt this one show?
|
||||||
for email in self.config.emails:
|
for email in self.config.emails:
|
||||||
result=ImapFetcher.run(self.config.emails[email], self.db)
|
result=ImapFetcher.run(self.config.emails[email], self.db)
|
||||||
self.statusLabel.set_label("Finished import without error.")
|
self.statusLabel.set_label("Finished import without error.")
|
||||||
#def runAllClicked
|
#def importAllClicked
|
||||||
|
|
||||||
def get_vbox(self):
|
def get_vbox(self):
|
||||||
"""returns the vbox of this thread"""
|
"""returns the vbox of this thread"""
|
||||||
|
@ -74,7 +96,10 @@ class GuiImapFetcher (threading.Thread):
|
||||||
for text in ("Site", "Fetch Type", "Mailserver", "Username", "Password", "Mail Folder", "Use SSL"):
|
for text in ("Site", "Fetch Type", "Mailserver", "Username", "Password", "Mail Folder", "Use SSL"):
|
||||||
label=gtk.Label(text)
|
label=gtk.Label(text)
|
||||||
box.add(label)
|
box.add(label)
|
||||||
self.rowVBox.pack_start(box, expand=False)
|
self.mainVBox.pack_start(box, expand=False)
|
||||||
|
|
||||||
|
self.rowVBox = gtk.VBox()
|
||||||
|
self.mainVBox.add(self.rowVBox)
|
||||||
|
|
||||||
for email in self.config.emails:
|
for email in self.config.emails:
|
||||||
config=self.config.emails[email]
|
config=self.config.emails[email]
|
||||||
|
@ -90,10 +115,11 @@ class GuiImapFetcher (threading.Thread):
|
||||||
sslBox.set_active(0)
|
sslBox.set_active(0)
|
||||||
box.add(sslBox)
|
box.add(sslBox)
|
||||||
|
|
||||||
#TODO: useSsl
|
#TODO: "run just this one" button
|
||||||
|
|
||||||
self.rowVBox.pack_start(box, expand=False)
|
self.rowVBox.pack_start(box, expand=False)
|
||||||
#print
|
#print
|
||||||
|
|
||||||
self.rowVBox.show_all()
|
self.mainVBox.show_all()
|
||||||
#end def displayConfig
|
#end def displayConfig
|
||||||
#end class GuiImapFetcher
|
#end class GuiImapFetcher
|
||||||
|
|
Loading…
Reference in New Issue
Block a user