Mercurial > hg > bnpparibas
comparison bnpparibas.py @ 9:225885e803b4
Fixes
author | Daniele Nicolodi <daniele@grinta.net> |
---|---|
date | Mon, 11 Jan 2016 19:44:36 +0100 |
parents | 90f4e0bd0c2d |
children | 636ea715af1e |
comparison
equal
deleted
inserted
replaced
8:e8e76dcdec5c | 9:225885e803b4 |
---|---|
4 import json | 4 import json |
5 import os.path | 5 import os.path |
6 import requests | 6 import requests |
7 import smtplib | 7 import smtplib |
8 import sqlite3 | 8 import sqlite3 |
9 import subprocess | |
10 import sys | |
9 import textwrap | 11 import textwrap |
10 import time | 12 import time |
11 | 13 |
12 from contextlib import contextmanager | 14 from contextlib import contextmanager |
13 from email.mime.text import MIMEText | 15 from email.mime.text import MIMEText |
14 from email.utils import format_datetime, localtime, parseaddr | 16 from email.utils import format_datetime, localtime, parseaddr |
15 from io import BytesIO | 17 from io import BytesIO |
16 from pprint import pprint | 18 from pprint import pprint |
17 from urllib.parse import urljoin | 19 from urllib.parse import urljoin |
18 | 20 |
19 from bs4 import BeautifulSoup | |
20 from html2text import HTML2Text | 21 from html2text import HTML2Text |
21 from PIL import Image | 22 from PIL import Image |
22 | 23 |
23 | 24 |
24 URL = 'https://mabanque.bnpparibas/' | 25 URL = 'https://mabanque.bnpparibas/' |
103 self.homedir = homedir | 104 self.homedir = homedir |
104 | 105 |
105 def encrypt(self, message, sender, recipient): | 106 def encrypt(self, message, sender, recipient): |
106 sender = parseaddr(sender)[1] | 107 sender = parseaddr(sender)[1] |
107 recipient = parseaddr(recipient)[1] | 108 recipient = parseaddr(recipient)[1] |
108 cmd = [ "gpg", "--homedir", self.homedir, "--sign", "--encrypt" | 109 cmd = [ "gpg", "--homedir", self.homedir, "--sign", "--encrypt", |
109 "--batch", "--no-options", "--yes", "--armor", | 110 "--batch", "--no-options", "--yes", "--armor", |
110 "--local-user", sender, "--recipient", recipient, ] | 111 "--local-user", sender, "--recipient", recipient, ] |
111 p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 112 p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
112 encdata, err = p.communicate(input=message.encode('utf-8')) | 113 encdata, err = p.communicate(input=message.encode('utf-8')) |
113 if p.returncode: | 114 if p.returncode: |
303 r = self.session.get(url, params={'identifiant': mid}) | 304 r = self.session.get(url, params={'identifiant': mid}) |
304 v = self.validate(r) | 305 v = self.validate(r) |
305 return v['data'] | 306 return v['data'] |
306 | 307 |
307 | 308 |
308 def main(conffile): | 309 def main(): |
310 conffile = sys.argv[1] | |
309 conf = loadconf(conffile) | 311 conf = loadconf(conffile) |
310 | 312 |
311 db = sqlite3.connect(conf['DATABASE']) | 313 db = sqlite3.connect(conf['DATABASE']) |
312 db.execute('''CREATE TABLE IF NOT EXISTS messages (id TEXT PRIMARY KEY)''') | 314 db.execute('''CREATE TABLE IF NOT EXISTS messages (id TEXT PRIMARY KEY)''') |
313 db.execute('''CREATE TABLE IF NOT EXISTS transactions (id INTEGER PRIMARY KEY)''') | 315 db.execute('''CREATE TABLE IF NOT EXISTS transactions (id INTEGER PRIMARY KEY)''') |
384 curs.execute('''INSERT INTO messages (id) VALUES (?)''', (m['id'], )) | 386 curs.execute('''INSERT INTO messages (id) VALUES (?)''', (m['id'], )) |
385 db.commit() | 387 db.commit() |
386 | 388 |
387 | 389 |
388 if __name__ == '__main__': | 390 if __name__ == '__main__': |
389 import sys | 391 main() |
390 main(sys.argv[1]) |