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'
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!")
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!")
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!")
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
def res(): if gp.checkConnection(): choice = request.args.get('res', type=str) print(choice) gp.changeResolution(choice) return 'OK'
def connect(): # Connect to GoPro. gp.connect("pi", "raspberrypizero.local", "raspberry") if (gp.checkConnection()): return 'OK' return 'Connection Error'
def turnOff(): gp.turnOff() return 'OK'
def turnOn(): gp.turnOn() return 'OK'
def checkConnection(): print(gp.checkConnection()) if not gp.checkConnection(): return render_template('error.html') else: return 'ok'