From 28306ae7f687d23a2d7558ba3ac1b4034c0e62e5 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 21 Mar 2021 20:13:16 +0100 Subject: [PATCH] readme, days --- readme.md | 16 ++++++++++++++-- vatsched.py | 12 ++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index 82fddeb..b58beae 100644 --- a/readme.md +++ b/readme.md @@ -3,7 +3,19 @@ Scheduling overview for Vatsim Germany's Forum. Output as a jpg. -Using the following python dependancies +Using the following python dependencies * imgkit, which in turn depends on wkhtmltopdf * dateutil -* requests \ No newline at end of file +* requests + +Setup: + +1. If necessary, change path to wkhtmltoimage in vatsched.py lines 92-94. +2. Setup image outputs in sched.py: + * List all stations as a python list. Use "--" to insert visual breaks in the table. + * List all dates as a python list as datetime objects. There are functions available to help with regularly occuring events: + * EveryXDaysFromStartdate (String startdate, int x, int numberofdays = 1) - Returns a python list of datetime objects. For regularly recurring events. Define a startdate and an interval in days for the event. numberofdays defines how many upcoming days will be returned. + * EveryXWeeksFromStartdate (String startdate, int x, int numberofdays = 1) - Returns a python list of datetime objects. For regularly recurring events. Define a startdate and an interval in weeks for the event. numberofdays defines how many upcoming days will be returned. This just an alias for EveryXDaysFromStardate with the input for x being x*7. + * EveryWeekday (int weekday, int numberofdays) - Returns a list of datetime objects. This to be used for weekly events. Define a day of the week and the number of days to be displayed. Monday = 0. + * WholeWeek (int shift = 0) - Returns a list of 7 datetime objects for consecutive days. Will start with today + shift days. + * Define output filename \ No newline at end of file diff --git a/vatsched.py b/vatsched.py index b9e2fa9..53cbcdf 100644 --- a/vatsched.py +++ b/vatsched.py @@ -4,15 +4,18 @@ from datetime import datetime, timedelta abbreviations = {} -def EveryXWeeksFromStartdate(startdate, x, numberofdates = 1): +def EveryXDaysFromStartdate(startdate, x, numberofdates = 1): startdate = parse(startdate) days = [] while (len(days) < numberofdates): - startdate += timedelta(days=x*7) + startdate += timedelta(days=x) if(datetime.today() <= startdate): days.append(startdate) return days +def EveryXWeeksFromStartdate(startdate, x, numberofdates = 1): + return EveryXDaysFromStartdate(startdate, x * 7, numberofdates) + def EveryWeekday(weekday, numberofdates=1): startdate = datetime.today() + timedelta((weekday - datetime.today().weekday()) % 7) days = [] @@ -85,9 +88,10 @@ def createImage(displaydates, stations, filename): text = maketable(stations, displaydates, relbookings) css = 'layout.css' - config = imgkit.config(wkhtmltoimage='C:/Program Files/wkhtmltopdf/bin/wkhtmltoimage.exe') options = {'width': (100 + 75 * len(displaydates)), 'disable-smart-width': ''} - imgkit.from_string(text, filename, css=css, config=config, options=options) +# config = imgkit.config(wkhtmltoimage='C:/Program Files/wkhtmltopdf/bin/wkhtmltoimage.exe') + config = imgkit.config(wkhtmltoimage='/usr/bin/wkhtmltoimage') + imgkit.from_string(text, filename, css=css, options=options, config=config) return def fetchData(startdate = datetime.today(), enddate = (datetime.today() + timedelta(1))):