Exemple #1
0
def test(card):
    aid = ''
    t = Terminal()
    ts = Transaction()
    for aid in l:
        adf = ADF(aid, '1001')
        apdu = APDU.APDU(card)
        t.tsAmount = '00000010'
        t.tsType = const.TTI_EP_LOAD
        t.key = Key('01', '42EAF305CDE83EC62C67BCB44B946B65')
        ts.load(t, adf, apdu)
Exemple #2
0
def test(card):
    aid = ''
    t = Terminal()
    ts = Transaction()
    for aid in l:
        adf = ADF(aid,'1001')
        apdu = APDU.APDU(card)
        t.tsAmount = '00000010'
        t.tsType = const.TTI_EP_LOAD
        t.key = Key('01','42EAF305CDE83EC62C67BCB44B946B65')
        ts.load(t, adf, apdu)
Exemple #3
0
def test(card):
    aid = ''
    t = Terminal()
    ts = Transaction()
    for aid in [l[0]]:
        adf = ADF(aid, '1001')
        apdu = APDU.APDU(card)
        #t.tsAmount = '0000'+Util.generateRnd(2)
        t.tsAmount = '0009DFFF'
        t.tsType = const.TTI_EP_PURCHASE
        t.key = Key('01', '0BA5B6D33FEC6DD73A5AA6CF81E818C7')
        ts.purchase(t, adf, apdu)
Exemple #4
0
def test(card):
    aid = ''
    t = Terminal()
    ts = Transaction()
    for aid in [l[0]]:
        adf = ADF(aid,'1001')
        apdu = APDU.APDU(card)
        #t.tsAmount = '0000'+Util.generateRnd(2)
        t.tsAmount = '0009DFFF'
        t.tsType = const.TTI_EP_PURCHASE
        t.key = Key('01','0BA5B6D33FEC6DD73A5AA6CF81E818C7')
        ts.purchase(t, adf, apdu)
Exemple #5
0
    def cachedQuery(self, kind, **kwargs):
        update = kwargs.pop('_update', None)
        key = make_key(kind, **kwargs)
        res = self.get(key)

        if not res or update:
            res = Transaction(kind).query(**kwargs)
            self.updatecache(key, res, True)
        return None if type(res) == type(NoneResult) else res
Exemple #6
0
 def get(self):
     selectcookie = self.request.cookies.get("sub_selection")
     if selectcookie:
         selected = split_subreddit_list(self.request.cookies.get("sub_selection"))
     else:
         selected = ""
     
     query = Transaction('SubReddits').query()
     self.render("subselect.html", subquery = query, selected = selected)
Exemple #7
0
    def post(self):
        subname = self.request.get("subname")
        nsfw = self.request.get("nsfw") == "on"
        query, _ = CachedQuery("SELECT * FROM SubReddits WHERE name='"+subname+"'")
        
        if not query.fetch(1):
            Transaction('SubReddits').set(key_name = subname, name= subname, nsfw = nsfw)
            self.updateSub(subname, datetime.datetime(2010, 12, 31, 23, 59, 59))  

        self.redirect("/_addsub")
Exemple #8
0
 def updateSub(self, subname, lastupdate):
     """Takes a Subreddit Name and the datetime of the last update of this Subreddit and updates the pics db for this subreddit"""
     links = redditjson("/r/"+subname)
     if links == None:
         return False
     
     for link in links:
         if link[3] > to_Utc(lastupdate):
             if link[0].find('i.imgur.com') != -1:
                 tlink = link[0][:-4] + 'l' + link[0][-4:]
             else:
                 tlink = link[0]
            
             Transaction('pics').set( url = link[0], subreddit = subname, permalink = link[1], date = link[3], tlink = tlink, title = link[2])
     return True
Exemple #9
0
 def addRow(self, row, style):
     if style == 'NORDNET':
         if self.readRow == 0:
             # Header
             # Id;Bokføringsdag;Handelsdag;Oppgjørsdag;Transaksjonstype;Verdipapir;Instrumenttyp;ISIN;Antall;Kurs;Rente;
             # Avgifter;Beløp;Valuta;Kjøpsverdi;Resultat;Totalt antall;Saldo;Vekslingskurs;Transaksjonstekst;Makuleringsdato;Sluttseddelnummer
             self.fHeadList = row
         else:
             # 
             t = Transaction(id=self.getField(row, 'Id'))
             
             t.setCount(self.getField(row, 'Antall'))
             t.setPrice(self.getField(row, 'Kurs'))
             t.setTotal(self.getField(row, 'Beløp'))
             t.setFee(self.getField(row, 'Avgifter'))
             
             t.setProduct(self.getField(row, 'Verdipapir'))
             t.setType(self.getField(row, 'Transaksjonstype').replace('SALG', 'SELL').replace('KJØPT', 'BUY'))
             t.setCategory(self.getField(row, 'Instrumenttyp'))
             t.setDate(datetime.datetime.strptime(self.getField(row, 'Handelsdag'), "%Y-%m-%d").date())
             
             print(t.__dict__)
             
             self.tList.append(t)
         self.readRow += 1