Commit dde71efb authored by Jadyn Jäger's avatar Jadyn Jäger 🦄

First stuff seems to be working. TODO: Add parameters for more control over...

First stuff seems to be working. TODO: Add parameters for more control over the infos you get and to enable usage in other scripts... (Master Password?!)
parents
__pycache__
#!/usr/bin/python3
import logging
from fints.client import FinTS3PinTanClient
import datetime
import json
import getpass
import secureStore
import sys
def setup():
bankingInfo = {}
print('bankingCLI setup')
bankingInfo['blz'] = input('Your banks BLZ: ')
bankingInfo['username'] = input('Your onlinebanking-username: ')
bankingInfo['pin'] = getpass.getpass('Your onlinebanking-PIN: ')
bankingInfo['url'] = input('Your banks fints url: ')
secureStore.writeFile('~/.bankingCLI', getpass.getpass('Choose a master password: '), json.dumps(bankingInfo))
print('Setup done')
logging.basicConfig(level=100)
if len(sys.argv) > 1:
if sys.argv[1] == "setup":
setup()
exit()
if secureStore.fileExsists('~/.bankingCLI'):
bankingInfo = secureStore.readFile('~/.bankingCLI', getpass.getpass('Master password:'))
if bankingInfo == None:
print("Wrong password!")
exit()
bankingInfo = json.loads(bankingInfo)
else:
print('run banking.py setup')
finTS = FinTS3PinTanClient(
bankingInfo['blz'],
bankingInfo['username'],
bankingInfo['pin'],
bankingInfo['url'],
product_id=None
)
try:
if finTS.init_tan_response:
print('Please use your banking app or banks website to enter your tan')
exit()
accounts = finTS.get_sepa_accounts()
info = finTS.get_information()
except:
print('ERROR, please check if your banking details are correct')
exit()
if __name__ == "__main__":
if len(sys.argv) == 1:
print('Your balences are:')
for account in accounts:
balance = finTS.get_balance(account)
print(account.iban + ": " + str(balance.amount.amount) + " " + balance.amount.currency)
print("Transactions in the past 90 days:")
today = datetime.datetime.now().date()
past = today - datetime.timedelta(90)
transactions = finTS.get_transactions(account, past, today)
for transaction in transactions:
print(str(transaction.data['date']) + " " + str(transaction.data['amount'].amount) + " " + transaction.data['amount'].currency + "\t" + transaction.data['purpose'])
# BankingCLI
## Used Python Packages
* fints
* simple-crypt
from simplecrypt import encrypt, decrypt
import os
def readFile(path, password):
f = open(os.path.expanduser(path), "rb")
try:
return decrypt(password, f.read())
except:
return None
def writeFile(path, password, text):
f = open(os.path.expanduser(path), "wb+")
f.write(encrypt(password, text))
f.close()
os.chmod(os.path.expanduser(path), 384)
def fileExsists(path):
return os.path.isfile(os.path.expanduser(path))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment