add hobo script to shot all themes

This commit is contained in:
Frédéric Péters 2019-11-19 10:58:56 +01:00
parent b8120ad7c1
commit ddb925a6c0
1 changed files with 38 additions and 0 deletions

38
bin/shot_them_all.py Normal file
View File

@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
#
# hobo-manage tenant_command runscript shot_them_all.py -d hobo.fred.local.0d.be
#
# Take desktop/mobile shots of all themes from publik-base-theme, tailored for
# my local installation.
import os
import json
import time
from selenium import webdriver
from hobo.theme.utils import set_theme
from hobo.deploy.signals import notify_agents
import sys
if not os.path.exists('shots'):
os.mkdir('shots')
options = webdriver.ChromeOptions()
options.add_argument('headless')
browser = webdriver.Chrome(chrome_options=options)
themes_data = json.load(open('/home/fred/src/eo/publik-base-theme/themes.json'))
for theme in themes_data['themes']:
theme_id = theme['id']
sys.stderr.write("%-25s" % theme_id)
set_theme(theme_id)
notify_agents(None)
for i in range(20): # 20 seconds
sys.stderr.write('.')
time.sleep(1)
os.system('sudo service memcached restart')
browser.get('https://auquo.fred.local.0d.be/contactez-nous/inscription-sur-les-listes/')
browser.set_window_size(1200, 1000)
browser.save_screenshot('shots/%s-desktop.png' % theme_id)
browser.set_window_size(480, 1000)
browser.save_screenshot('shots/%s-mobile.png' % theme_id)
sys.stderr.write(u' 📸 \n')