예제 #1
0
def main():
    ard.connect(baud=19200)

    print("Running...")

    while True:
        loop()
예제 #2
0
파일: demo.py 프로젝트: cathywu/SunV2
def demo():
    s = interface.connect()
    while True:
        interface.turn_on(s)
        time.sleep(5)
        interface.turn_off(s)
        time.sleep(5)
    return "Demo!"
예제 #3
0
파일: main.py 프로젝트: gpitot/web-dev
def loadData():
    print('loading')
    c = interface.connect()
    dict = bottle.request.json['searchProductsDict']
    price = dict['price']
    categories = dict['categories']
    result = interface.retrieveData(c, price, categories)
    resultHtml = content.rangeMainContent(result)
    resultJson = {'contentMain': resultHtml}
    return resultJson
예제 #4
0
파일: main.py 프로젝트: gpitot/web-dev
def adminTable():
    c = interface.connect()
    dropdowns = content.getDropdowns()
    listOfItems = interface.getItems(c)
    itemTable = content.getAllItems(listOfItems)
    return bottle.template(
        os.path.join('views', 'admin.tpl'),
        loginVisible='$(".login").hide();$("#edit").show();',
        gendersDropdownHtml=dropdowns[0],
        tagsDropdownHtml=dropdowns[1],
        sizesDropdownHtml=dropdowns[2],
        checkedArray=dropdowns[3],
        tableList=itemTable)
예제 #5
0
파일: main.py 프로젝트: gpitot/web-dev
def admin():
    c = interface.connect()
    username = bottle.request.forms['username']
    password = bottle.request.forms['password']
    hashedPass = security.pass2hash(password)
    checkPass = interface.checkPass(c, username, hashedPass)

    if checkPass:
        return adminTable()
    else:
        return bottle.template(os.path.join('views', 'admin.tpl'),
                               loginVisible='$("#edit").hide();',
                               gendersDropdownHtml='',
                               tagsDropdownHtml='',
                               sizesDropdownHtml='',
                               checkedArray='[];')
예제 #6
0
파일: main.py 프로젝트: gpitot/web-dev
def editItem():
    c = interface.connect()
    data = bottle.request.json['jsonData']
    print(data)
    checkArray = data['checklist']
    id = data['id']
    name = data['name']
    price = data['price']
    sale = data['sale']
    print(id, name, price, sale, checkArray)

    genderCheck = checkArray[0]
    tagsCheck = checkArray[1]
    sizesCheck = checkArray[2]

    unsortedTagsList = content.getCategories()
    tagsSorted = []
    for item in unsortedTagsList.values():
        for x in item:
            if len(x) > 2:
                if x[2] == 0:
                    tagsSorted.append(x[1])
    sizesList = content.getSizes()
    gendersList = content.getGenders()

    gender = []
    for g in range(0, len(genderCheck)):
        if genderCheck[g]:
            gender.append(gendersList[g])

    tags = []

    for t in range(0, len(tagsCheck)):
        if tagsCheck[t]:
            tags.append(tagsSorted[t])

    sizes = []
    for s in range(0, len(sizesCheck)):
        if sizesCheck[s]:
            sizes.append(sizesList[s])

    interface.addItem(c, id, name, tags, price, sale, sizes, gender)

    return {'success': 'yes'}
예제 #7
0
파일: main.py 프로젝트: gpitot/web-dev
def addItem():
    #UPLOAD THE ITEM to file AND RETURN THE TPL
    c = interface.connect()

    print('uploading attempt [addItem]')
    upload = bottle.request.files.get('pImg')
    id = bottle.request.forms['pId']
    print(id)
    print('upload = ', upload)
    if upload != None:
        if upload.content_type == 'image/jpeg' or upload.content_type == 'image/png':
            print('png')
            name = upload.filename
            save_path = os.path.join("images/costumes", upload.filename)
            try:
                upload.save(save_path)
            except OSError:
                name = '2' + upload.filename
                save_path = os.path.join("images/costumes", name)
            print(name)
            interface.addFileName(c, name, id)
    return adminTable()
예제 #8
0
import interface
import time

buttonPressed = True
go = False
IRdetected = False;
counter = 0
interface.connect()
interface.stop()
time.sleep(2)
interface.start()
time.sleep(2)
interface.passive()
time.sleep(2)
interface.full()
time.sleep(2)

#write the song
interface.writeSong()

while buttonPressed == True:
    time.sleep(.25)
    if interface.buttonRead() == 1:
        go = True
        buttonPressed = False
        break

time.sleep(0.25)

while go == True:
    interface.drive()
예제 #9
0
파일: demo.py 프로젝트: cathywu/SunV2
def turnOff():
    # put in pyserial here
    s = interface.connect()
    interface.turn_off(s)
    return "Turning off"
예제 #10
0
파일: demo.py 프로젝트: cathywu/SunV2
def turnOn():
    # put in pyserial here
    s = interface.connect()
    interface.turn_on(s)
    return "Turning on"
예제 #11
0
파일: demo.py 프로젝트: cathywu/SunV2
def dimOff():
    # put in pyserial here
    s = interface.connect()
    interface.dim_off(s,count=10,delay=1)
    return "Dimmed off"