Beispiel #1
0
 def setUp(self):
     #logging.basicConfig(level=logging.DEBUG)
     logging.basicConfig(level=logging.ERROR)
     self.config = db_config()
     self.session_manager = nupay.SessionManager(self.config)
     with self.session_manager.create_session() as session:
         session.bootstrap_db()
Beispiel #2
0
    def __init__(self, cipher):
        threading.Thread.__init__(self)
        self._logger = logging.getLogger(__name__)
        self.matemat = matemat.Matemat()
        self.token_reader = nupay.USBTokenReader()
        self._collector = nupay.MQTTCollector(cipher=cipher,
                                              server='localhost',
                                              topic='/collected/matmat',
                                              client_id='matemat')

        while True:
            try:
                self.matemat.writeLCD('connecting...')
                self.session_manager = nupay.SessionManager(
                    collectors=[self._collector])
                break
            except nupay.SessionConnectionError as e:
                self.report("upay unavailable", wait=3)
Beispiel #3
0
import ConfigParser
import sys
import nupay

config = ConfigParser.RawConfigParser()
config.read(sys.argv[1])

tokens = nupay.read_tokens_from_file(sys.argv[2])

with nupay.SessionManager(config).create_session() as session:
    session.validate_tokens(tokens)
    print("Your balance is %.02f Eur" % session.credit)
Beispiel #4
0
import ConfigParser
import sys
import logging

import nupay
logging.basicConfig(level=logging.DEBUG)
config = ConfigParser.RawConfigParser()
config_file = sys.argv[1]
config.read(config_file)

nupay.SessionManager(config).bootstrap_db()
Beispiel #5
0
 def test_create_session_manager(self):
     self.session_manager = nupay.SessionManager(self.config)
Beispiel #6
0
 def test_create_session(self):
     self.session_manager = nupay.SessionManager(self.config)
     with self.session_manager.create_session() as session:
         self.assertIsInstance(session, nupay.Session)
Beispiel #7
0
import nupay
import time
import logging
import ConfigParser
import sys

logging.basicConfig(level=logging.DEBUG)
config = ConfigParser.RawConfigParser()
config.read(sys.argv[1])

token_reader = nupay.USBTokenReader()
session_manager = nupay.SessionManager(config)

while True:
    print("Waiting for purse")
    
    while True: 
        try:
            tokens = token_reader.read_tokens()
            break
        except nupay.NoTokensAvailableError:
            time.sleep(1)

    print("Read %d tokens"%len(tokens))

    with session_manager.create_session() as session:
        session.validate_tokens(tokens)
        print("Your balance is %.02f Eur"%session.credit)

    print("Waiting for medium to vanish")