1 |
#!/usr/local/bin/python |
2 |
# Wesabe |
3 |
# |
4 |
# Douglas Thrift |
5 |
# |
6 |
# $Id$ |
7 |
|
8 |
from M2Crypto import m2urllib2, SSL |
9 |
|
10 |
class Wesabe(object): |
11 |
def __init__(self, username, password, debug): |
12 |
context = SSL.Context() |
13 |
|
14 |
context.set_verify(SSL.verify_peer | SSL.verify_fail_if_no_peer_cert, depth = 9) |
15 |
context.load_verify_locations('/etc/ssl/cert.pem') |
16 |
|
17 |
self.opener = m2urllib2.build_opener(context) |
18 |
|
19 |
def upload(self, name, filename, data, balance = None): |
20 |
print name, filename, balance |
21 |
|
22 |
def main(calendar, config, banks, debug): |
23 |
wesabe = Wesabe(config.get('username'), config.getpassword('password'), debug) |
24 |
|
25 |
for module in config.getlist('banks'): |
26 |
bank = banks.bank(module) |
27 |
|
28 |
for name, account in bank.accounts(): |
29 |
wesabe.upload(account, *bank.download(account)) |