1 |
douglas |
1178 |
#!/usr/local/bin/python |
2 |
|
|
# Wesabe |
3 |
|
|
# |
4 |
|
|
# Douglas Thrift |
5 |
|
|
# |
6 |
|
|
# $Id$ |
7 |
|
|
|
8 |
|
|
import common |
9 |
|
|
from M2Crypto import m2urllib2, SSL |
10 |
|
|
|
11 |
|
|
class Wesabe(object): |
12 |
|
|
def __init__(self, username, password, debug): |
13 |
|
|
context = SSL.Context() |
14 |
|
|
|
15 |
|
|
context.set_verify(SSL.verify_peer | SSL.verify_fail_if_no_peer_cert, depth = 9) |
16 |
|
|
context.load_verify_locations('/etc/ssl/cert.pem') |
17 |
|
|
|
18 |
|
|
self.opener = m2urllib2.build_opener(context) |
19 |
|
|
|
20 |
|
|
def upload(self, name, filename, data, balance = None): |
21 |
|
|
print name, filename, balance |
22 |
|
|
|
23 |
|
|
if __name__ == '__main__': |
24 |
|
|
parser = common.OptionParser() |
25 |
|
|
options = parser.parse_args()[0] |
26 |
|
|
|
27 |
|
|
config, banks = common.config(parser, options, '.wesabe') |
28 |
|
|
wesabe = Wesabe(config.get('wesabe', 'username'), common.decode(config.get('wesabe', 'password')), True)#options.debug) |
29 |
|
|
|
30 |
|
|
for bank, accounts in banks.iteritems(): |
31 |
|
|
bank = common.bank(bank, options, config) |
32 |
|
|
|
33 |
|
|
for account in accounts: |
34 |
|
|
name, account = account.rsplit(' ', 1) |
35 |
|
|
|
36 |
|
|
wesabe.upload(name, *bank.download(account)) |