Exemple #1
0
    def auth_test(self,username=None,password=None):
        u = username or self.username
        if not u:
            raise LoginException("missing username",bank=self)
        p = password or self.password
        if not u:
            raise LoginException("missing password",bank=self)

        builder = Builder(self)
        query = builder.authQuery(username=u,password=p)
        res = builder.doQuery(query)
        ofx = BeautifulStoneSoup(res)

        try:
            sonrs = ofx.find('sonrs')
            code = int(sonrs.find('code').contents[0].strip())
        except:
            raise LoginException("parse error: %s" % res,bank=self)

        try:
            status = sonrs.find('message').contents[0].strip()
        except Exception:
            status = ''

        if code == 0:
            return 1

        security.set_password(
            self.keyring_id(),
            ''
        )
        raise LoginException(status,code=code,bank=self)
Exemple #2
0
 def query_from_institution( institution ):
     builder = Builder( institution )
     query = builder.acctQuery()
     resp = builder.doQuery( query )
     resp_handle = StringIO.StringIO(resp)
     accounts = []
     for a in OfxParser.parse(resp_handle).accounts:
         accounts.append( Account.from_ofxparser(institution,a) )
     return accounts
Exemple #3
0
 def download(self,days=60):
     days_ago = datetime.datetime.now() - datetime.timedelta( days=days )
     from_date = time.strftime("%Y%m%d",days_ago.timetuple())
     builder = Builder(self.institution) 
     query = None
     if self.is_brokerage_account():
         query = builder.invstQuery(self.broker_id,self.number,from_date)
     elif self.is_bank_account():
         query = builder.baQuery(self.number,from_date,self.account_type,self.routing_number)
     elif self.is_credit_card_account():
         query = builder.ccQuery(self.number,from_date)
         
     if query is None:
         return 
     response = builder.doQuery(query)
     return StringIO.StringIO(response)