From ddb925a6c044c1c7898359cf464489a8e6fadd5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 19 Nov 2019 10:58:56 +0100 Subject: [PATCH] add hobo script to shot all themes --- bin/shot_them_all.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 bin/shot_them_all.py diff --git a/bin/shot_them_all.py b/bin/shot_them_all.py new file mode 100644 index 0000000..51381be --- /dev/null +++ b/bin/shot_them_all.py @@ -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')