Example #1
0
def RFIDThread(s):
  while True:
    rfid = nfc.getRFID(300)
    if rfid != None:
      TransactionState.lock.acquire()
      if s.state == IDLE:
        record = db.get_record(1, str(rfid))
        if record != None:
          s.startTransaction(rfid, RFID, record[-1])
      elif s.state == PRIMED:
        if rfid == s.ID and s.Type == RFID:
          s.reset()
        elif rfid == undo_card:
          s.reset()
        else:
          record = db.get_record(1, str(rfid))
          if record != None:
            s.startTransaction(rfid, RFID, record[-1])
      elif s.state == USED:
        if rfid == s.ID and s.Type == RFID:
          s.checkout()
          TransactionState.lock.release()
          time.sleep(3)
          TransactionState.lock.acquire()
          s.reset()
        elif rfid == undo_card:
          s.undo()
        else:
          record = db.get_record(1, str(rfid))
          if record != None:
            s.startTransaction(rfid, RFID, record[-1])
      TransactionState.lock.release()
      time.sleep(1)
Example #2
0
def RFIDThread(s):
    while True:
        rfid = nfc.getRFID(300)
        if rfid != None:
            TransactionState.lock.acquire()
            if s.state == IDLE:
                record = db.get_record(1, str(rfid))
                if record != None:
                    s.startTransaction(rfid, RFID, record[-1])
            elif s.state == PRIMED:
                if rfid == s.ID and s.Type == RFID:
                    s.reset()
                elif rfid == undo_card:
                    s.reset()
                else:
                    record = db.get_record(1, str(rfid))
                    if record != None:
                        s.startTransaction(rfid, RFID, record[-1])
            elif s.state == USED:
                if rfid == s.ID and s.Type == RFID:
                    s.checkout()
                    TransactionState.lock.release()
                    time.sleep(3)
                    TransactionState.lock.acquire()
                    s.reset()
                elif rfid == undo_card:
                    s.undo()
                else:
                    record = db.get_record(1, str(rfid))
                    if record != None:
                        s.startTransaction(rfid, RFID, record[-1])
            TransactionState.lock.release()
            time.sleep(1)
Example #3
0
def BarcodeThread(s, mainwin):
  while True:
    code = barcode.scan(mainwin)
    record = db.get_record(1, code)
    TransactionState.lock.acquire()
    if s.state == IDLE:
      if record != None:
        s.startTransaction(code, BARCODE, record[-1])
      else: 
        s.priceCheck(upc.lookup(code))
        TransactionState.lock.release()
        time.sleep(3)
        TransactionState.lock.acquire()
        s.reset()
    elif s.state == PRIMED:
      if code == s.ID and s.Type == BARCODE:
        s.reset()
      elif record != None:
        s.startTransaction(code, BARCODE, record[-1])
      else:
        s.addTransaction(upc.lookup(code))
    elif s.state == USED:
      if code == s.ID and s.Type == BARCODE:
        s.checkout()
        TransactionState.lock.release()
        time.sleep(3)
        TransactionState.lock.acquire()
        s.reset()
      elif record != None:
        s.startTransaction(code, BARCODE, record[-1])
      else:
        s.addTransaction(upc.lookup(code))
    TransactionState.lock.release()
Example #4
0
def BarcodeThread(s, mainwin):
    while True:
        code = barcode.scan(mainwin)
        record = db.get_record(1, code)
        TransactionState.lock.acquire()
        if s.state == IDLE:
            if record != None:
                s.startTransaction(code, BARCODE, record[-1])
            else:
                s.priceCheck(upc.lookup(code))
                TransactionState.lock.release()
                time.sleep(3)
                TransactionState.lock.acquire()
                s.reset()
        elif s.state == PRIMED:
            if code == s.ID and s.Type == BARCODE:
                s.reset()
            elif record != None:
                s.startTransaction(code, BARCODE, record[-1])
            else:
                s.addTransaction(upc.lookup(code))
        elif s.state == USED:
            if code == s.ID and s.Type == BARCODE:
                s.checkout()
                TransactionState.lock.release()
                time.sleep(3)
                TransactionState.lock.acquire()
                s.reset()
            elif record != None:
                s.startTransaction(code, BARCODE, record[-1])
            else:
                s.addTransaction(upc.lookup(code))
        TransactionState.lock.release()
Example #5
0
def lookup(upc):
    #For demo purposes only we have a special check here to see if it is
    #sprite. If it is, we use google scraping to guess.
    values = db.get_record(0,upc)
    itemsOfInterest = []
    if values != None:
        itemsOfInterest.append(('description', values[0]))
        itemsOfInterest.append(('status', 'success'))
        itemsOfInterest.append(('found', True))
        itemsOfInterest.append(('size', values[1]))
        itemsOfInterest.append(('price', values[2]))
        return dict(itemsOfInterest)

    if upc != SPRITE_UPC:
        s = ServerProxy('http://www.upcdatabase.com/xmlrpc')
        params = { 'rpc_key': RPC_KEY, 'upc': upc }
        upc_data = s.lookup(params)
        if upc_data['status'] == "success" and upc_data['found']:
            if 'description' in upc_data:
                if upc_data['description'] != '':
                    itemsOfInterest.append(('description', upc_data['description']));
            if 'size' in upc_data:
                if upc_data['size'] != '':
                    itemsOfInterest.append(('size', upc_data['size']))
            itemsOfInterest.append(('status', upc_data['status']))
            itemsOfInterest.append(('found', upc_data['found']))
            itemsOfInterest = dict(itemsOfInterest)
            itemsOfInterest['price'] = 0 #get price from database here
            db.add_product(upc, itemsOfInterest['description'],
                    itemsOfInterest['size'], itemsOfInterest['price'])
            return itemsOfInterest
        elif upc_data['status'] != "success":
            return upc_data
    res = google_guesser.guess(upc)
    if res == None:
        return None
    itemsOfInterest.append(('description', res))
    itemsOfInterest.append(('status', 'success'))
    itemsOfInterest.append(('found', True))
    itemsOfInterest.append(('price', 0))
    itemsOfInterest.append(('size','Not found'))
    answer = dict(itemsOfInterest)
    db.add_product(upc, answer['description'], answer['size'],
            answer['price'])
    return dict(itemsOfInterest)