added a fallback for rendering the website locally, where /var/www/stream does not exist
This commit is contained in:
parent
5364009530
commit
353f5a0acc
@ -2,14 +2,23 @@
|
|||||||
# -*- coding: utf-8 -*- #
|
# -*- coding: utf-8 -*- #
|
||||||
|
|
||||||
from pelican import signals
|
from pelican import signals
|
||||||
from os import listdir
|
from os import listdir, path
|
||||||
from os.path import isfile, join
|
import time
|
||||||
# import os
|
from datetime import datetime
|
||||||
|
|
||||||
|
def getCreationTime(img):
|
||||||
|
creationtime = time.ctime(path.getctime(img))
|
||||||
|
date = datetime(creationtime).strftime('%y%m%d')
|
||||||
|
print('creationtime', date)
|
||||||
|
return date
|
||||||
|
|
||||||
def getStream(generator):
|
def getStream(generator):
|
||||||
for page in generator.pages:
|
for page in generator.pages:
|
||||||
dir = "/var/www/stream"
|
dir = "/var/www/stream"
|
||||||
images = [f for f in listdir(dir) if isfile(join(dir, f))]
|
if path.exists(dir):
|
||||||
|
images = [(getCreationTime(dir+'/'+f), f) for f in listdir(dir) if path.isfile(path.join(dir, f))]
|
||||||
|
else: # if the website is generated locally
|
||||||
|
images = ['placeholder.png']
|
||||||
print('>>> The stream is streaming!', images)
|
print('>>> The stream is streaming!', images)
|
||||||
page.stream = images
|
page.stream = images
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user