<commit_before>#!/usr/bin/env python
# Created by <EMAIL>, 2015

from gui import GUI_PyGame as GuiModule

import os
from datetime import datetime
from time import sleep
import subprocess
import thread

#####################
### Configuration ###
#####################

# Screen size
display_size = (1024, 768)

# Directory name
directory = datetime.now().strftime("%Y-%m-%d")

# Display time for slideshow pictures
display_time = 3

# Waiting time between synchronizations
sync_time = 60

#keep_running = True

###############
### Classes ###
###############

class Slideshow:
    def __init__(self, display_size, display_time, directory, recursive=True):
        self.directory    = directory
        self.recursive    = recursive
        self.filelist     = []
        self.display      = GuiModule("Slideshow", display_size)
        self.display_time = display_time

    def scan(self):
        filelist = []

        if self.recursive:
            # Recursively walk all entries in the directory
            for root, dirnames, filenames in os.walk(self.directory):
                for filename in filenames:
                    filelist.append(os.path.join(root, filename))
        else:
            # Add all entries in the directory
            for item in os.listdir(self.directory):
                filename = os.path.join(self.directory, item)
                if os.path.isfile(filename):
                    filelist.append(filename)

        self.filelist = filelist

    def handle_event(self, event):
        if event.type == 0:
            self.teardown()
        elif event.type == 1:
            self.handle_keypress(event.value)

    def handle_keypress(self, key):
        # Exit the application
        if key == ord('q'):
            self.teardown()

    def run(self):
        while True:
            self.scan()
            for filename in self.filelist:
                self.display.clear()
                self.display.show_picture(filename)
                self.display.apply()
                sleep(self.display_time)
                r, e = self.display.check_for_event()
                if r:
                    self.handle_event(e)

    def teardown(self):
        self.display.teardown()
        #keep_running = False
        exit(0)


#################
### Functions ###
#################

def routine_command(cmd, interval):
    while True:
        print("Running routine")
        output = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
        print("Output is " + output)
        sleep(interval)

def main():
    thread.start_new_thread(routine_command, ("rsync -rt " + directory + "/ slideshow/", 3))
    
    show = Slideshow(display_size, display_time, directory, True)
    show.run()

    sync.join()
    return 0<commit_msg>Output prettified, config updated<commit_after>#!/usr/bin/env python
# Created by <EMAIL>, 2015

from gui import GUI_PyGame as GuiModule

import os
from datetime import datetime
import subprocess
import thread
from time import sleep

#####################
### Configuration ###
#####################

# Screen size
display_size = (1024, 768)

# Directory for slideshow pictures
slideshow_directory = "slideshow/"

# 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

# Waiting time (in seconds) between synchronizations
sync_time = 20

###############
### Classes ###
###############

class Slideshow:
    def __init__(self, display_size, display_time, directory, recursive=True):
        self.directory    = directory
        self.recursive    = recursive
        self.filelist     = []
        self.display      = GuiModule("Slideshow", display_size)
        self.display_time = display_time

    def scan(self):
        filelist = []

        if self.recursive:
            # Recursively walk all entries in the directory
            for root, dirnames, filenames in os.walk(self.directory):
                for filename in filenames:
                    filelist.append(os.path.join(root, filename))
        else:
            # Add all entries in the directory
            for item in os.listdir(self.directory):
                filename = os.path.join(self.directory, item)
                if os.path.isfile(filename):
                    filelist.append(filename)

        self.filelist = filelist

    def handle_event(self, event):
        if event.type == 0:
            self.teardown()
        elif event.type == 1:
            self.handle_keypress(event.value)

    def handle_keypress(self, key):
        # Exit the application
        if key == ord('q'):
            self.teardown()

    def run(self):
        while True:
            self.scan()
            for filename in self.filelist:
                self.display.clear()
                self.display.show_picture(filename)
                self.display.apply()
                sleep(self.display_time)
                r, e = self.display.check_for_event()
                if r:
                    self.handle_event(e)

    def teardown(self):
        self.display.teardown()
        exit(0)


#################
### Functions ###
#################

def sync_folders(source_directory, target_directory, wait_time):
    while True:
        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)
        sleep(wait_time)

def main():
    # Start a thread for syncing files
    if len(source_directory) > 0:
        thread.start_new_thread(sync_folders, (source_directory, slideshow_directory, sync_time) )
    
    # Start the slideshow
    slideshow = Slideshow(display_size, display_time, slideshow_directory, True)
    slideshow.run()

    return 0
{'fraction_non_alphanumeric': 0.12964519926013116, 'fraction_numerical': 0.007734992433159576, 'mean_word_length': 2.3044444444444445, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4459048', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1638, 'n_words': 416}