guwno
This commit is contained in:
parent
bbdcd27c6d
commit
35405b4909
6 changed files with 37 additions and 21 deletions
|
@ -435,13 +435,13 @@ class IBFetcher(object):
|
|||
|
||||
return wallet
|
||||
|
||||
def login(self, username, password):
|
||||
def login(self, username, password, interactive=False):
|
||||
sms_re = r'Silne uwierzytelnienie do logowania. Kod SMS: (.*)'
|
||||
smsgw_message = None
|
||||
try:
|
||||
smsgw_message = self.smsgw_request(sms_re)
|
||||
except Exception as exc:
|
||||
self.logger.warning('Couldn\'t create smsgw service, will go interactive', exc)
|
||||
self.logger.warning('Couldn\'t create smsgw service, will go interactive', exc_info=exc)
|
||||
|
||||
login1_page = self._get("main/index")
|
||||
self._wait(3)
|
||||
|
@ -482,7 +482,7 @@ class IBFetcher(object):
|
|||
}
|
||||
else:
|
||||
data = {
|
||||
"sms": input('fetching shit')
|
||||
"sms": input('[?] OTP: ')
|
||||
}
|
||||
|
||||
wallet_page = self._post("main/index", data)
|
||||
|
@ -544,6 +544,7 @@ def release():
|
|||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-n', '--no-action', action="store_true", help='do not commit any database changes')
|
||||
parser.add_argument('-i', '--interactive', action="store_true", help='ask interactively for credentials')
|
||||
parser.add_argument('-c', '--cached', action="store_true", help='use cached data (test)')
|
||||
parser.add_argument('-l', '--load', action='append', help='process specified files (test)')
|
||||
parser.add_argument('--print-schema', action="store_true", help='print table schema and quit')
|
||||
|
@ -600,8 +601,8 @@ if __name__ == "__main__":
|
|||
else:
|
||||
logging.debug("Normal run - will connect to the bank")
|
||||
fetcher = IBFetcher()
|
||||
if "IB_LOGIN" not in config.keys() or "IB_PASSWORD" not in config.keys():
|
||||
wallet = fetcher.login(input("[?] ID: "), input("[?] Password: "))
|
||||
if "IB_LOGIN" not in config.keys() or "IB_PASSWORD" not in config.keys() or args.interactive:
|
||||
wallet = fetcher.login(input("[?] ID: "), input("[?] Password: "), args.interactive)
|
||||
else:
|
||||
logging.debug("Using saved credentials")
|
||||
wallet = fetcher.login(config["IB_LOGIN"], config["IB_PASSWORD"])
|
||||
|
|
|
@ -126,7 +126,7 @@ class IBRow(RawTransfer):
|
|||
self.to_account = IBParser.parse_account_number(row['beneficiaryNrb'])
|
||||
|
||||
direction = row['kind']
|
||||
if direction == 'OUT':
|
||||
if direction == 'OUT' or direction == 'CARD_TRANS':
|
||||
self.type = 'OUT'
|
||||
self.amount = -self.amount
|
||||
if row['operationType'] == 'SELF':
|
||||
|
@ -138,20 +138,24 @@ class IBRow(RawTransfer):
|
|||
elif direction == 'FEE':
|
||||
self.type = 'BANK_FEE'
|
||||
self.amount = -self.amount
|
||||
if self.to_name != self.from_name:
|
||||
if self.to_name != self.from_name and 'Prowizja za przelew natychmiastowy' not in self.title:
|
||||
# TODO FIXME: false for instant transfer fees
|
||||
raise IBParseError("Invalid to_name/from_name (%r / %r)" % (
|
||||
self.to_name, self.from_name))
|
||||
if self.from_account not in self.OWN_ACCOUNTS or self.to_account not in self.OWN_ACCOUNTS:
|
||||
if self.from_account not in self.OWN_ACCOUNTS and self.to_account not in self.OWN_ACCOUNTS:
|
||||
# if self.from_account not in self.OWN_ACCOUNTS or self.to_account not in self.OWN_ACCOUNTS:
|
||||
raise IBParseError("Wrong to_account/from_account on bank fee transfer (%r / %r)" % (
|
||||
self.to_account, self.from_account
|
||||
))
|
||||
# TODO FIXME: false for instant transfer fees
|
||||
# To account seems to always be main account
|
||||
self.to_account = self.from_account
|
||||
# self.to_account = self.from_account
|
||||
else:
|
||||
raise IBParseError(
|
||||
"Can't parse direction specifier \"{}\"".format(direction))
|
||||
|
||||
if None in (self.type, self.to_account, self.from_account, self.to_name, self.from_name):
|
||||
print(row)
|
||||
raise IBParseError(
|
||||
"Something went wrong - one of the mandatory values empty",
|
||||
self.type, self.to_account, self.from_account,
|
||||
|
@ -179,6 +183,7 @@ class IBParser(object):
|
|||
"((?:[A-Za-z]{2})?[0-9]{2})[ ]?([0-9]{4})[ ]?([0-9]{4})[ ]?([0-9]{4})[ ]?([0-9]{4})[ ]?([0-9]{4})[ ]?([0-9]{4})", # 26 digits, optional country code - Poland
|
||||
"((?:[A-Za-z]{2})?[0-9]{2})[ ]?([A-Z]{4})[ ]?([0-9]{4})[ ]?([0-9]{4})[ ]?([0-9]{4})[ ]?([0-9]{2})", # 22 characters including BIC bank code - Ireland
|
||||
"((?:[A-Za-z]{2})?[0-9]{2})[ ]?([A-Z]{4})[ ]?([0-9]{4})[ ]?([0-9]{4})[ ]?([0-9]{2})", # 18 characters including BIC bank code - Netherlands
|
||||
"((?:[A-Za-z]{2})?[0-9]{14})", # 14 characters including BIC bank code - Belgium
|
||||
"((?:[A-Za-z]{2})?[0-9]{2})[ ]?([0-9]{4})[ ]?([0-9]{4})[ ]?([0-9]{4})[ ]?([0-9]{4})[ ]?([0-9]{2})", # 22 digits - Germany
|
||||
"^([0-9]{5})$", # 5 digits - weird special hax for Benevity (UK?)
|
||||
]
|
||||
|
@ -268,7 +273,6 @@ class IBFetcher(object):
|
|||
apilogin_resp = self._post('/login', data={
|
||||
'token': login_token,
|
||||
})
|
||||
|
||||
auth_token = apilogin_resp.history[0].cookies['Authentication-Token']
|
||||
self.token = auth_token
|
||||
|
||||
|
@ -481,6 +485,14 @@ if __name__ == "__main__":
|
|||
account_number, balance, currency))
|
||||
|
||||
log_summary("Done: %r", stats)
|
||||
try:
|
||||
if stats.get('PL91195000012006000648890004',{}).get('added'):
|
||||
msg = 'holla holla get dolla: {1[0]} {1[1]} (+{0})'.format(stats.get('PL91195000012006000648890004',{}).get('added'), balances.get('PL91195000012006000648890004'))
|
||||
requests.post('http://hackerspace.pl:43288/moonspeak/1/notification', params={
|
||||
'target': '#hackerspace-pl-members', 'message': msg,
|
||||
})
|
||||
except Exception as exc:
|
||||
print(exc)
|
||||
|
||||
if not args.no_lock:
|
||||
release()
|
||||
|
|
|
@ -12,27 +12,29 @@ configparser==3.5.0
|
|||
enum34==1.1.6
|
||||
Flask==0.12.2
|
||||
Flask-Caching==1.3.3
|
||||
Flask-Gravatar==0.4.1
|
||||
Flask-Gravatar==0.4.2
|
||||
Flask-Login==0.4.1
|
||||
Flask-OAuthlib==0.9.4
|
||||
Flask-SQLAlchemy==2.0
|
||||
Flask-WTF==0.10.3
|
||||
futures==3.2.0
|
||||
#futures==3.2.0
|
||||
isort==4.3.4
|
||||
itsdangerous==0.24
|
||||
Jinja2==2.10
|
||||
kombu==3.0.24
|
||||
lazy-object-proxy==1.3.1
|
||||
Mako==1.0.0
|
||||
MarkupSafe==1.0
|
||||
MarkupSafe==1.1.0
|
||||
mccabe==0.6.1
|
||||
oauthlib==2.0.7
|
||||
prometheus-client==0.1.1
|
||||
psycopg2==2.5.4
|
||||
prometheus-flask-exporter==0.8.0
|
||||
pylint==1.8.2
|
||||
python-ldap==2.4.18
|
||||
python-memcached==1.53
|
||||
python-ldap
|
||||
#python-ldap==2.4.18
|
||||
python-memcached
|
||||
#python-memcached==1.53
|
||||
pytz==2014.10
|
||||
requests==2.5.1
|
||||
requests-oauthlib==0.8.0
|
||||
|
|
|
@ -33,7 +33,7 @@ from flask import Flask, redirect
|
|||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_login import LoginManager, AnonymousUserMixin, login_required, current_user
|
||||
from flask_caching import Cache
|
||||
from flaskext.gravatar import Gravatar
|
||||
from flask_gravatar import Gravatar
|
||||
from spaceauth import SpaceAuth
|
||||
|
||||
app = Flask(__name__)
|
||||
|
@ -89,7 +89,7 @@ def create_app():
|
|||
metrics = UWsgiPrometheusMetrics(group_by='url_rule')
|
||||
|
||||
metrics.init_app(app)
|
||||
metrics.register_endpoint('/varz', app)
|
||||
#metrics.register_endpoint('/varz', app)
|
||||
|
||||
# Register blueprints
|
||||
import webapp.views
|
||||
|
|
|
@ -52,5 +52,6 @@ joined as (
|
|||
)
|
||||
select
|
||||
dt, mi, mr, mp,
|
||||
sum(mr + mi + mp) over (order by dt asc rows between unbounded preceding and current row)
|
||||
--sum(mr + mi + mp) over (order by dt asc rows between unbounded preceding and current row)
|
||||
(mr + mi + mp) as sum
|
||||
from joined;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# FIXME we need to upgrade Flask_SQLAlchemy to get rid of deprecation warnings
|
||||
import warnings
|
||||
from flask.exthook import ExtDeprecationWarning
|
||||
warnings.simplefilter("ignore", ExtDeprecationWarning)
|
||||
#import warnings
|
||||
#from flask.exthook import ExtDeprecationWarning
|
||||
#warnings.simplefilter("ignore", ExtDeprecationWarning)
|
||||
import logging
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
import webapp
|
||||
|
|
Loading…
Reference in a new issue