Output prettified, config updated

This commit is contained in:
Balthasar Reuter
2015-06-20 01:06:49 +02:00
parent a6ceb2b3cc
commit 45f5bea844

View File

@@ -5,9 +5,9 @@ from gui import GUI_PyGame as GuiModule
import os import os
from datetime import datetime from datetime import datetime
from time import sleep
import subprocess import subprocess
import thread import thread
from time import sleep
##################### #####################
### Configuration ### ### Configuration ###
@@ -16,16 +16,18 @@ import thread
# Screen size # Screen size
display_size = (1024, 768) display_size = (1024, 768)
# Directory name # Directory for slideshow pictures
directory = datetime.now().strftime("%Y-%m-%d") slideshow_directory = "slideshow/"
# Display time for slideshow pictures # Source directory, can also be remote.
# Leave empty to disable sync
source_directory = "2015-06-18"
# Display time (in seconds) for slideshow pictures
display_time = 3 display_time = 3
# Waiting time between synchronizations # Waiting time (in seconds) between synchronizations
sync_time = 60 sync_time = 20
#keep_running = True
############### ###############
### Classes ### ### Classes ###
@@ -81,7 +83,6 @@ class Slideshow:
def teardown(self): def teardown(self):
self.display.teardown() self.display.teardown()
#keep_running = False
exit(0) exit(0)
@@ -89,20 +90,23 @@ class Slideshow:
### Functions ### ### Functions ###
################# #################
def routine_command(cmd, interval): def sync_folders(source_directory, target_directory, wait_time):
while True: while True:
print("Running routine") print("[" + datetime.now().strftime("%H:%M:%S") + "] Sync "
+ source_directory + " --> " + target_directory)
cmd = "rsync -rtu " + source_directory + " " + target_directory
output = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) output = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
print("Output is " + output) sleep(wait_time)
sleep(interval)
def main(): def main():
thread.start_new_thread(routine_command, ("rsync -rt " + directory + "/ slideshow/", 3)) # Start a thread for syncing files
if len(source_directory) > 0:
thread.start_new_thread(sync_folders, (source_directory, slideshow_directory, sync_time) )
show = Slideshow(display_size, display_time, directory, True) # Start the slideshow
show.run() slideshow = Slideshow(display_size, display_time, slideshow_directory, True)
slideshow.run()
sync.join()
return 0 return 0
if __name__ == "__main__": if __name__ == "__main__":