Beispiel #1
0
    {
        'search_term': 'olive oil',
        'item': 'olive oil'
    },
    {
        'search_term': 'cereal',
        'item': 'cereal'
    },
    {
        'search_term': 'peanut butter',
        'item': 'peanut butter'
    },
]
os.chdir('/var/oscar')
from lib import trellodb
trello_db = trellodb.TrelloDB(trello_api, trello_db_board)
for rule in new_rules:
    trello_db.insert('description_rules', rule)

######################################## Oscar configs
oscar_yaml = open('/etc/oscar.yaml', 'w')
oscar_yaml.write('''---
port: 80
scanner_device: '{scanner_device}'

communication_method: '{communication_method}'

gmail_user: '******'
gmail_password: '******'
email_dest: '{email_dest}'
Beispiel #2
0
    ][0]
    cards = trello_api.lists.get_card(grocery_list['id'])
    card_names = [card['name'] for card in cards]

    # Add item if it's not there already
    if item not in card_names:
        print "Adding '{0}' to grocery list".format(item)
        trello_api.lists.new_card(grocery_list['id'], item)
    else:
        print "Item '{0}' is already on the grocery list; not adding".format(
            item)


trello_api = trello.TrelloApi(conf.get()['trello_app_key'])
trello_api.set_token(conf.get()['trello_token'])
trello_db = trellodb.TrelloDB(trello_api, conf.get()['trello_db_board'])

f = open(conf.get()['scanner_device'], 'rb')
while True:
    print 'Waiting for scanner data'

    # Wait for binary data from the scanner and then read it
    scan_complete = False
    scanner_data = ''
    while True:
        rlist, _wlist, _elist = select.select([f], [], [], 0.1)
        if rlist != []:
            new_data = ''
            while not new_data.endswith('\x01\x00\x1c\x00\x01\x00\x00\x00'):
                new_data = rlist[0].read(16)
                scanner_data += new_data