readme, days
This commit is contained in:
16
readme.md
16
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
|
||||
* 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
|
12
vatsched.py
12
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))):
|
||||
|
Reference in New Issue
Block a user