summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2019-11-19 09:58:56 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2019-11-19 09:58:56 (GMT)
commitddb925a6c044c1c7898359cf464489a8e6fadd5f (patch)
treee532702a82a34a4f62ab20825c4f96935aa94935
parentb8120ad7c1a2cd281e6e7681e59bb2345ac1d270 (diff)
downloadmisc-fred-ddb925a6c044c1c7898359cf464489a8e6fadd5f.zip
misc-fred-ddb925a6c044c1c7898359cf464489a8e6fadd5f.tar.gz
misc-fred-ddb925a6c044c1c7898359cf464489a8e6fadd5f.tar.bz2
add hobo script to shot all themes
-rw-r--r--bin/shot_them_all.py38
1 files changed, 38 insertions, 0 deletions
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')