-
Notifications
You must be signed in to change notification settings - Fork 0
/
controltest.py
42 lines (34 loc) · 1.24 KB
/
controltest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from time import sleep
from datetime import datetime
from sh import gphoto2 as gp
import signal, os, subprocess
picID = "PiShots"
triggerCommand = ["--capture-image-and-download"]
folder_name = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
save_location = "/home/pi/Desktop/Gphoto/images/" + folder_name
secondary_location = "/home/pi/Desktop/Gphoto/images/" + datetime.now().strftime("%Y-%m-%d %H:%M:%S")
def createSaveFolder():
try:
os.makedirs(save_location)
os.chdir(save_location)
except:
os.makedirs(secondary_location)
print("Created new Folder.")
os.chdir(secondary_location)
def captureImages():
print("Try")
gp(triggerCommand)
print("Downloaded")
def renameImages(ID):
for filename in os.listdir("."):
if len(filename) < 14:
if filename.endswith(".jpg"):
os.rename(filename, (datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ID + ".jpg"))
print("Renamed the JPG.")
elif filename.endswith(".arw"):
os.rename(filename, (datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ID + ".arw"))
print("Renamed the ARW.")
createSaveFolder()
while True:
captureImages()
renameImages(picID)