From 4d4c2bd530145b86767c2254406a317b744fabb9 Mon Sep 17 00:00:00 2001 From: marcusferl Date: Sat, 12 Mar 2022 23:59:01 +0100 Subject: [PATCH] update --- README.md | 8 ++++++++ config.py | 2 +- digit_converter.py | 3 --- eventboard.py | 34 ++++++++-------------------------- zitate.txt | 4 ++++ 5 files changed, 21 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 7555459..f463a00 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,14 @@ Migration von JavaScript zu Python +

Funktionen

+ + ### Config diff --git a/config.py b/config.py index 9ab30f5..34b77b4 100644 --- a/config.py +++ b/config.py @@ -1,4 +1,4 @@ -host = 'Device IP' # ur device ip, where u upload the matrix.ino +host = 'Device_Ip' # ur device ip, where u upload the matrix.ino #Edit the Events, decide what u wanna show on you Led Matrix garbage = 'true' diff --git a/digit_converter.py b/digit_converter.py index 3948e9f..b9d51fd 100644 --- a/digit_converter.py +++ b/digit_converter.py @@ -1,7 +1,6 @@ # Digit converter import json - def digit_convert(filename): with open(filename, 'r') as file: data = json.load(file) @@ -12,11 +11,9 @@ def digit_convert(filename): with open('events.json', 'w') as file: json.dump(data, file, indent=2) - if len(i['date']['month']) != 2: i['date']['month'] = str('{:02d}'.format(i['date']['month'])) with open('events.json', 'w') as file: json.dump(data, file, indent=2) - digit_convert('events.json') \ No newline at end of file diff --git a/eventboard.py b/eventboard.py index b30e124..ad49e2e 100644 --- a/eventboard.py +++ b/eventboard.py @@ -8,8 +8,7 @@ import json from datetime import date import requests import config -import datetime -import random + # Get current Date def get_current_date(): @@ -17,9 +16,8 @@ def get_current_date(): day = str('{:02d}'.format(currentDate.day)) month = str('{:02d}'.format(currentDate.month)) year = str(currentDate.year) - tomorrow_date = date.today() + datetime.timedelta(days=1) - tomorrow = str('{:02d}'.format(tomorrow_date.day)) - return [day, month, year, tomorrow] + return [day, month, year] + # Raw data from Json file def read_JSON(filename): @@ -28,13 +26,6 @@ def read_JSON(filename): f.close() return data -# Creat default Message -def default_message(): - lines = [] - with open('zitate.txt', 'r') as file: - for l in file: - lines.append(l) - return random.choice(lines) # Returns the Garbage def create_Message(): @@ -44,9 +35,7 @@ def create_Message(): for i in read_JSON('muell.json'): day = i['date']['day'] month = i['date']['month'] - if day == get_current_date()[3] and month == get_current_date()[1]: - message = message + ' Morgen: ' + i['name'] - elif int(day) == int(get_current_date()[0]) and month == get_current_date()[1]: + if day == get_current_date()[0] and month == get_current_date()[1]: message = message + ' ' + i['name'] if config.events == 'true': @@ -54,9 +43,7 @@ def create_Message(): for i in read_JSON(filename): day = i['date']['day'] month = i['date']['month'] - if day == get_current_date()[3] and month == get_current_date()[1]: - message = message + ' Morgen: ' + i['name'] - elif int(day) == int(get_current_date()[0]) and month == get_current_date()[1]: + if day == get_current_date()[0] and month == get_current_date()[1]: message = message + ' ' + i['name'] if config.holidays == 'true': @@ -64,19 +51,14 @@ def create_Message(): for i in read_JSON(filename): day = i['date']['day'] month = i['date']['month'] - if day == get_current_date()[3] and month == get_current_date()[1]: - message = message + ' Morgen: ' + i['name'] - elif int(day) == int(get_current_date()[0]) and month == get_current_date()[1]: + if day == get_current_date()[0] and month == get_current_date()[1]: message = message + ' ' + i['name'] - - if len(message) < 5: - message = default_message() - - return message + # Send Message to the Device def matrixRequest(): requests.get('http://' + config.host + config.get_request + str(create_Message())) + # Main matrixRequest() diff --git a/zitate.txt b/zitate.txt index d0e59a7..84b875c 100644 --- a/zitate.txt +++ b/zitate.txt @@ -115,7 +115,11 @@ Nur wer sein Ziel kennt, findet den Weg. - Laozi Der Langsamste, der sein Ziel nur nicht aus den Augen verliert, geht immer noch geschwinder als der, der ohne Ziel herumirrt. - Gotthold Ephraim Lessing Ziele zu setzen ist der erste Schritt das unsichtbare in das sichtbare zu verwandeln. - Tony Robbins Der Mensch arbeitet immer fuer ein Ziel. Wer jedoch keine eigenen Ziele hat, arbeitet fuer die von Anderen. - Brian Tracy +<<<<<<< HEAD Fordert man sich nicht unablaessig selber heraus, verdorrt man. - Lido Lee Iacocca +======= +Fordert man sich nicht unablaessig selber heraus, verdorrt man. - Lido ‚Lee‘ Iacocca +>>>>>>> 046c2bb (update) Man muss das Unmoegliche versuchen, um das moegliche zu erreichen. - Hermann Hesse Nichts verschafft mehr Ruhe, als ein gefasster Entschluss. - Charles Maurice de Talleyrand Erst Ziele geben unserem Leben einen Sinn.— C.H. Parkhurst