update email config section as discussed on ML

This commit is contained in:
steffen123 2010-08-22 01:30:33 +02:00
parent 96f547b3df
commit 09f3205e77
3 changed files with 72 additions and 73 deletions

View File

@ -256,6 +256,20 @@ class Layout:
return temp + "\n" return temp + "\n"
class Email:
def __init__(self, node):
self.node = node
self.host= node.getAttribute("host")
self.username = node.getAttribute("username")
self.password = node.getAttribute("password")
self.useSsl = node.getAttribute("useSsl")
self.folder = node.getAttribute("folder")
self.fetchType = node.getAttribute("fetchType")
def __str__(self):
return " fetchType=%s\n host = %s\n username = %s\n password = %s\n useSsl = %s\n folder = %s\n" \
% (self.fetchType, self.host, self.username, self.password, self.useSsl, self.folder)
class Site: class Site:
def __init__(self, node): def __init__(self, node):
def normalizePath(path): def normalizePath(path):
@ -284,12 +298,17 @@ class Site:
self.xshift = node.getAttribute("xshift") self.xshift = node.getAttribute("xshift")
self.yshift = node.getAttribute("yshift") self.yshift = node.getAttribute("yshift")
self.layout = {} self.layout = {}
self.emails = {}
print _("Loading site"), self.site_name print _("Loading site"), self.site_name
for layout_node in node.getElementsByTagName('layout'): for layout_node in node.getElementsByTagName('layout'):
lo = Layout(layout_node) lo = Layout(layout_node)
self.layout[lo.max] = lo self.layout[lo.max] = lo
for email_node in node.getElementsByTagName('email'):
email = Email(email_node)
self.emails[email.fetchType] = email
# Site defaults # Site defaults
self.xpad = 1 if self.xpad == "" else int(self.xpad) self.xpad = 1 if self.xpad == "" else int(self.xpad)
@ -467,21 +486,6 @@ class Import:
return " interval = %s\n callFpdbHud = %s\n hhArchiveBase = %s\n saveActions = %s\n fastStoreHudCache = %s\n" \ return " interval = %s\n callFpdbHud = %s\n hhArchiveBase = %s\n saveActions = %s\n fastStoreHudCache = %s\n" \
% (self.interval, self.callFpdbHud, self.hhArchiveBase, self.saveActions, self.fastStoreHudCache) % (self.interval, self.callFpdbHud, self.hhArchiveBase, self.saveActions, self.fastStoreHudCache)
class Email:
def __init__(self, node):
self.node = node
self.host= node.getAttribute("host")
self.username = node.getAttribute("username")
self.password = node.getAttribute("password")
self.useSsl = node.getAttribute("useSsl")
self.folder = node.getAttribute("folder")
self.siteName = node.getAttribute("siteName")
self.fetchType = node.getAttribute("fetchType")
def __str__(self):
return " siteName=%s\n fetchType=%s\n host = %s\n username = %s\n password = %s\n useSsl = %s\n folder = %s\n" \
% (self.siteName, self.fetchType, self.host, self.username, self.password, self.useSsl, self.folder)
class HudUI: class HudUI:
def __init__(self, node): def __init__(self, node):
self.node = node self.node = node
@ -716,11 +720,6 @@ class Config:
imp = Import(node = imp_node) imp = Import(node = imp_node)
self.imp = imp self.imp = imp
for email_node in doc.getElementsByTagName("email"):
email = Email(node = email_node)
if email.siteName!="": #FIXME: Why on earth is this needed?
self.emails[email.siteName+"_"+email.fetchType]=email
for hui_node in doc.getElementsByTagName('hud_ui'): for hui_node in doc.getElementsByTagName('hud_ui'):
hui = HudUI(node = hui_node) hui = HudUI(node = hui_node)
self.ui = hui self.ui = hui
@ -767,9 +766,12 @@ class Config:
return site_node return site_node
def getEmailNode(self, siteName, fetchType): def getEmailNode(self, siteName, fetchType):
for emailNode in self.doc.getElementsByTagName("email"): siteNode = self.get_site_node(siteName)
if emailNode.getAttribute("siteName") == siteName and emailNode.getAttribute("fetchType") == fetchType: for emailNode in siteNode.getElementsByTagName("email"):
if emailNode.getAttribute("fetchType") == fetchType:
print "found emailNode"
return emailNode return emailNode
break
#end def getEmailNode #end def getEmailNode
def getGameNode(self,gameName): def getGameNode(self,gameName):

View File

@ -72,19 +72,14 @@ class GuiImapFetcher (threading.Thread):
siteName=columns[0].get_text() siteName=columns[0].get_text()
fetchType=columns[1].get_text() fetchType=columns[1].get_text()
code=siteName+"_"+fetchType
for email in self.config.emails: toSave=self.config.supported_sites[siteName].emails[fetchType]
toSave=self.config.emails[email]
break
toSave.siteName=siteName
toSave.fetchType=fetchType
toSave.host=columns[2].get_text() toSave.host=columns[2].get_text()
toSave.username=columns[3].get_text() toSave.username=columns[3].get_text()
if columns[4].get_text()=="***": if columns[4].get_text()=="***":
toSave.password=self.passwords[code] toSave.password=self.passwords[siteName+fetchType]
else: else:
toSave.password=columns[4].get_text() toSave.password=columns[4].get_text()
@ -101,16 +96,17 @@ class GuiImapFetcher (threading.Thread):
def importAllClicked(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 siteName in self.config.supported_sites:
try: for fetchType in self.config.supported_sites[siteName].emails:
result=ImapFetcher.run(self.config.emails[email], self.db) try:
self.statusLabel.set_label(_("Finished import without error.")) result=ImapFetcher.run(self.config.supported_sites[siteName].emails[fetchType], self.db)
except IMAP4.error as error: self.statusLabel.set_label(_("Finished import without error."))
if str(error)=="[AUTHENTICATIONFAILED] Authentication failed.": except IMAP4.error as error:
self.statusLabel.set_label(_("Login to mailserver failed: please check mailserver, username and password")) if str(error)=="[AUTHENTICATIONFAILED] Authentication failed.":
except gaierror as error: self.statusLabel.set_label(_("Login to mailserver failed: please check mailserver, username and password"))
if str(error)=="[Errno -2] Name or service not known": except gaierror as error:
self.statusLabel.set_label(_("Could not connect to mailserver: check mailserver and use SSL settings and internet connectivity")) if str(error)=="[Errno -2] Name or service not known":
self.statusLabel.set_label(_("Could not connect to mailserver: check mailserver and use SSL settings and internet connectivity"))
#def importAllClicked #def importAllClicked
def get_vbox(self): def get_vbox(self):
@ -128,38 +124,42 @@ class GuiImapFetcher (threading.Thread):
self.rowVBox = gtk.VBox() self.rowVBox = gtk.VBox()
self.mainVBox.add(self.rowVBox) self.mainVBox.add(self.rowVBox)
for email in self.config.emails: for siteName in self.config.supported_sites:
config=self.config.emails[email] for fetchType in self.config.supported_sites[siteName].emails:
box=gtk.HBox(homogeneous=True) config=self.config.supported_sites[siteName].emails[fetchType]
box=gtk.HBox(homogeneous=True)
for field in (config.siteName, config.fetchType):
label=gtk.Label(field) for field in (siteName, config.fetchType):
box.add(label) label=gtk.Label(field)
box.add(label)
for field in (config.host, config.username):
for field in (config.host, config.username):
entry=gtk.Entry()
entry.set_text(field)
box.add(entry)
entry=gtk.Entry() entry=gtk.Entry()
entry.set_text(field) self.passwords[siteName+fetchType]=config.password
entry.set_text("***")
box.add(entry) box.add(entry)
entry=gtk.Entry() entry=gtk.Entry()
self.passwords[email]=config.password entry.set_text(config.folder)
entry.set_text("***") box.add(entry)
box.add(entry)
sslBox = gtk.combo_box_new_text()
entry=gtk.Entry() sslBox.append_text(_("Yes"))
entry.set_text(config.folder) sslBox.append_text(_("No"))
box.add(entry) if config.useSsl:
sslBox.set_active(0)
sslBox = gtk.combo_box_new_text() else:
sslBox.append_text(_("Yes")) sslBox.set_active(1)
sslBox.append_text(_("No")) box.add(sslBox)
sslBox.set_active(0)
box.add(sslBox) #TODO: "run just this one" button
#TODO: "run just this one" button self.rowVBox.pack_start(box, expand=False)
#print
self.rowVBox.pack_start(box, expand=False)
#print
self.mainVBox.show_all() self.mainVBox.show_all()
#end def displayConfig #end def displayConfig

View File

@ -156,6 +156,7 @@ Left-Drag to Move"
xshift="0" xshift="0"
yshift="0" yshift="0"
supported_games="holdem,razz,omahahi,omahahilo,studhi,studhilo"> supported_games="holdem,razz,omahahi,omahahilo,studhi,studhilo">
<email fetchType="request-summary" host="YOUR_EMAIL_SERVER" username="YOUR_EMAIL_USERNAME" password="YOUR_EMAIL_PASSWORD" useSsl="True" folder="INBOX"/>
<layout max="8" width="792" height="546" fav_seat="0"> <layout max="8" width="792" height="546" fav_seat="0">
<location seat="1" x="684" y="61"> </location> <location seat="1" x="684" y="61"> </location>
<location seat="2" x="689" y="239"> </location> <location seat="2" x="689" y="239"> </location>
@ -708,10 +709,6 @@ Left-Drag to Move"
<!-- <database db_name="fpdb" db_server="mysql" db_ip="localhost" db_user="fpdb" db_pass="YOUR MYSQL PASSWORD"></database> --> <!-- <database db_name="fpdb" db_server="mysql" db_ip="localhost" db_user="fpdb" db_pass="YOUR MYSQL PASSWORD"></database> -->
<database db_ip="localhost" db_server="sqlite" db_name="fpdb.db3" db_user="fpdb" db_pass="fpdb"/> <database db_ip="localhost" db_server="sqlite" db_name="fpdb.db3" db_user="fpdb" db_pass="fpdb"/>
</supported_databases> </supported_databases>
<email>
<email siteName="PokerStars" fetchType="request-summary" host="YOUR_EMAIL_SERVER" username="YOUR_EMAIL_USERNAME" password="YOUR_EMAIL_PASSWORD" useSsl="True" folder="INBOX"/>
</email>
</FreePokerToolsConfig> </FreePokerToolsConfig>
<!-- IMPORTANT: Please note that fpdb stores your email password in clear text. <!-- IMPORTANT: Please note that fpdb stores your email password in clear text.
So do not post a config containing a password on the Internet or anywhere else without removing the password! --> So do not post a config containing a password on the Internet or anywhere else without removing the password! -->