1 |
– |
#!/usr/local/bin/python |
1 |
|
# Wesabe |
2 |
|
# |
3 |
|
# Douglas Thrift |
4 |
|
# |
5 |
|
# $Id$ |
6 |
|
|
7 |
< |
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 |
7 |
> |
import dtwesabe |
8 |
|
|
9 |
|
def main(calendar, config, banks, debug): |
10 |
< |
wesabe = Wesabe(config.get('username'), config.getpassword('password'), debug) |
10 |
> |
wesabe = dtwesabe.Wesabe(config.getusername(), config.getpassword()) |
11 |
> |
accounts = {} |
12 |
> |
|
13 |
> |
for account in wesabe.accounts(): |
14 |
> |
if account.account_number is not None: |
15 |
> |
accounts[account.account_number] = account |
16 |
|
|
17 |
|
for module in config.getlist('banks'): |
18 |
|
bank = banks.bank(module) |
19 |
|
|
20 |
< |
for name, account in bank.accounts(): |
21 |
< |
wesabe.upload(account, *bank.download(account)) |
20 |
> |
for name, number in bank.accounts(): |
21 |
> |
account = accounts[number] |
22 |
> |
|
23 |
> |
wesabe.upload(number, account.account_type, account.financial_institution.id, *bank.download(number)) |