Пример #1
0
def record():
    if gp.checkConnection():
        length = request.args.get('captureLength', type=int)
        print("length: " + str(length))
        gp.record(str(length))
        return 'OK'
    return 'Connection Error'
Пример #2
0
def takePhotos():
    if gp.checkConnection():
        count = request.args.get('count', type=int)
        gp.takePhotos(count)
        return 'OK'
    else:
        return render_template('error.html',
                               error="Check GoPro Connection for SSH!")
Пример #3
0
def index():
    gp.connect("pi", "raspberrypizero.local", "raspberry")
    print(gp.checkConnection())
    if gp.checkConnection():
        if gp.checkGPConnection():
            return render_template('index.html')
        else:
            return render_template('error.html',
                                   error="Check GoPro Connection!")
    else:
        return render_template('error.html',
                               error="Check Pi Zero Connection for SSH!")
Пример #4
0
def single():
    try:
        os.system("rm " + os.getcwd() + "/dls/single/single.jpg")
    except FileNotFoundError:
        print("File not found.")
    gp.connect("pi", "raspberrypizero.local", "raspberry")
    if gp.checkConnection():
        print("connection ok")
        gp.takeOne()
        path = os.getcwd()
        return send_file(path + "/dls/single/single.jpg",
                         as_attachment=True,
                         cache_timeout=0)
    else:
        return render_template('error.html', error="Check GoPro Connection!")
Пример #5
0
def downloadAll():
    gp.downloadAll()
    # Download location
    dls = str(os.getcwd()) + "/dls/data.zip"
    baseDir = os.getcwd()
    print(dls)
    # Prepare send_file
    result = send_file(dls, as_attachment=True)
    try:
        # Remove /dls folder.
        shutil.rmtree(os.getcwd() + '/dls')
        os.system("cd " + baseDir + "; mkdir dls")
    except Exception as error:
        print("Error deleting files")
        print(error)
    print("returning file.")
    # Return folder.
    return result
Пример #6
0
def res():
    if gp.checkConnection():
        choice = request.args.get('res', type=str)
        print(choice)
        gp.changeResolution(choice)
        return 'OK'
Пример #7
0
def connect():
    # Connect to GoPro.
    gp.connect("pi", "raspberrypizero.local", "raspberry")
    if (gp.checkConnection()):
        return 'OK'
    return 'Connection Error'
Пример #8
0
def turnOff():
    gp.turnOff()
    return 'OK'
Пример #9
0
def turnOn():
    gp.turnOn()
    return 'OK'
Пример #10
0
def checkConnection():
    print(gp.checkConnection())
    if not gp.checkConnection():
        return render_template('error.html')
    else:
        return 'ok'