reorganization of config management
This commit is contained in:
parent
d15365fe26
commit
29400eb185
9 changed files with 135 additions and 56 deletions
|
|
@ -20,8 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
from weboob import Weboob
|
||||
from weboob.capabilities.messages import ICapMessages, ICapMessagesReply
|
||||
from weboob.tools.application import BaseApplication
|
||||
|
|
@ -30,7 +28,9 @@ class Application(BaseApplication):
|
|||
APPNAME = 'dummy'
|
||||
|
||||
def main(self, argv):
|
||||
self.weboob.load_modules()
|
||||
self.load_config()
|
||||
self.weboob.load_modules(backends=self.config.getbackends())
|
||||
|
||||
for name, backend in self.weboob.iter_backends():
|
||||
print '= Processing backend name = %s' % name
|
||||
if backend.has_caps(ICapMessages):
|
||||
|
|
@ -41,5 +41,4 @@ class Application(BaseApplication):
|
|||
print '== Backend is ICapMessagesReply => TODO'
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = Application()
|
||||
sys.exit(app.main(sys.argv))
|
||||
Application.run()
|
||||
|
|
|
|||
|
|
@ -39,14 +39,15 @@ class Application(BaseApplication):
|
|||
'smtp': 'localhost'}
|
||||
|
||||
def main(self, argv):
|
||||
if not self.config:
|
||||
self.load_config()
|
||||
if not self.myconfig:
|
||||
print >>sys.stderr, "Error: %s is not configured yet. Please call 'weboob2mail -c'" % argv[0]
|
||||
print >>sys.stderr, "Also, you need to use 'weboobcfg' to set backend configs"
|
||||
return -1
|
||||
|
||||
self.weboob.load_modules(ICapMessages)
|
||||
self.weboob.load_modules(ICapMessages, backends=self.config.getbackends())
|
||||
|
||||
self.weboob.schedule(self.config['interval'], self.process)
|
||||
self.weboob.schedule(self.myconfig['interval'], self.process)
|
||||
self.weboob.loop()
|
||||
|
||||
def process(self):
|
||||
|
|
@ -55,8 +56,8 @@ class Application(BaseApplication):
|
|||
self.send_email(name, message)
|
||||
|
||||
def send_email(self, backend_name, mail):
|
||||
domain = self.config['domain']
|
||||
recipient = self.config['recipient']
|
||||
domain = self.myconfig['domain']
|
||||
recipient = self.myconfig['recipient']
|
||||
|
||||
reply_id = ''
|
||||
if mail.get_reply_id():
|
||||
|
|
@ -110,12 +111,11 @@ class Application(BaseApplication):
|
|||
msg['In-Reply-To'] = reply_id
|
||||
|
||||
# Send the message via SMTP to localhost:25
|
||||
smtp = SMTP(self.config['smtp'])
|
||||
smtp = SMTP(self.myconfig['smtp'])
|
||||
smtp.sendmail(sender, recipient, msg.as_string())
|
||||
smtp.quit()
|
||||
|
||||
return msg['Message-Id']
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = Application()
|
||||
sys.exit(app.main(sys.argv))
|
||||
Application.run()
|
||||
|
|
|
|||
|
|
@ -25,11 +25,10 @@ from types import MethodType
|
|||
|
||||
from weboob import Weboob
|
||||
from weboob.capabilities.travel import ICapTravel
|
||||
from weboob.tools.application import BaseApplication
|
||||
from weboob.tools.application import ConsoleApplication
|
||||
|
||||
class Application(BaseApplication):
|
||||
class Travel(ConsoleApplication):
|
||||
APPNAME = 'travel'
|
||||
CONFIG = {}
|
||||
|
||||
def main(self, argv):
|
||||
self.weboob.load_modules(ICapTravel)
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
"""
|
||||
|
||||
import sys
|
||||
from weboob.frontends.travel import Application
|
||||
from weboob.frontends.travel import Travel
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = Application()
|
||||
sys.exit(app.main(sys.argv))
|
||||
Travel.run()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue