Error handling for sync command
This commit is contained in:
@@ -10,7 +10,7 @@ from time import sleep, clock
|
|||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from gui import GUI_PyGame as GuiModule
|
from gui import GUI_PyGame as GuiModule
|
||||||
from camera import CameraException, Camera_cv as CameraModule
|
from camera import CameraException, Camera_gPhoto as CameraModule
|
||||||
from events import Rpi_GPIO as GPIO
|
from events import Rpi_GPIO as GPIO
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
|
|||||||
11
slideshow.py
11
slideshow.py
@@ -21,13 +21,13 @@ slideshow_directory = "slideshow/"
|
|||||||
|
|
||||||
# Source directory, can also be remote.
|
# Source directory, can also be remote.
|
||||||
# Leave empty to disable sync
|
# Leave empty to disable sync
|
||||||
source_directory = "2015-06-18"
|
source_directory = "pi@photobooth:photobooth/" + datetime.now().strftime("%Y-%m-%d")
|
||||||
|
|
||||||
# Display time (in seconds) for slideshow pictures
|
# Display time (in seconds) for slideshow pictures
|
||||||
display_time = 3
|
display_time = 3
|
||||||
|
|
||||||
# Waiting time (in seconds) between synchronizations
|
# Waiting time (in seconds) between synchronizations
|
||||||
sync_time = 20
|
sync_time = 60
|
||||||
|
|
||||||
###############
|
###############
|
||||||
### Classes ###
|
### Classes ###
|
||||||
@@ -94,8 +94,11 @@ def sync_folders(source_directory, target_directory, wait_time):
|
|||||||
while True:
|
while True:
|
||||||
print("[" + datetime.now().strftime("%H:%M:%S") + "] Sync "
|
print("[" + datetime.now().strftime("%H:%M:%S") + "] Sync "
|
||||||
+ source_directory + " --> " + target_directory)
|
+ source_directory + " --> " + target_directory)
|
||||||
cmd = "rsync -rtu " + source_directory + " " + target_directory
|
try:
|
||||||
output = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
|
cmd = "rsync -rtu " + source_directory + " " + target_directory
|
||||||
|
output = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print("ERROR executing '" + e.cmd + "':\n" + e.output)
|
||||||
sleep(wait_time)
|
sleep(wait_time)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Reference in New Issue
Block a user