I'm new to python and am trying to write a code that will allow me to take time lapse photographs with my DSLR.
Thanks!
from time import sleep from datetime import datetime from sh import gphoto2 as gp import signal, os, subprocess shot_date = datetime.now().strftime("%Y-%m-%d") shot_time = datetime.now().strftime("%Y-%m-%d" "%H:%M:%S") pidID = "earth_test_3" clearCommand = ["--folder", "/store_00020001/DCIM/100CANON","-R", "--delete-all-files"] triggerCommand = ["--trigger-capture"] downloadCommand = ["--get-all-files"] folder_name = shot_date + picID save_location = "/home/pi/Desktop/earth_test_3/" + folder_name def createSaveFolder(): try: os.makedirs(save_location) print("New save directory created for today!") except: print("Already created this save directory for today") os.chdir(save_location) def captureImages(): gp(triggerCommand) sleep(3) gp(downloadCommand) gp(clearCommand) def renameFiles (ID): for filename in os.listdir("."): if len(filename) < 13: if filename.endswith(".JPG"): os.rename(filename, (shot_time + ID + ".JPG")) print("Sucess! JPG renamed") elif filename.endwith (".CR2"): os.rename(filename, (shot_time + ID + ".CR2")) print ("Hurray! Raw file renamed") gp(clearCommand) while True: createSaveFolder() captureImages() renameFiles(picID) sleep (60)I followed the code from a tutorial, but am receiving this error when I run it through the terminal.
Error:Traceback (most recent call last);
File "earth_test_4.py", line 3, in <module>
from sh import gphoto2 as gp
ImportError: No module named 'sh'
Any insight is much appreciated (including any better way to go about a time lapse capture!)Thanks!