summaryrefslogtreecommitdiffstats
path: root/static/img/sources/integrations-graphiques/generate.py
blob: 6f87c262eff8db793ccede1893982e963db01fb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /usr/bin/env python

import os
import subprocess

captures = [
    ('https://cournonterral.test-eservices.montpellier3m.fr/',
     'cournonterral.png'),
    ('https://fabregues.eservices.montpellier3m.fr/',
     'fabregues.png'),
    ('https://marcoussis.au-quotidien.com/etat-civil/copie-d-acte-de-naissance/',
     'marcoussis.png'),
    ('https://meyzieu.au-quotidien.com/inscriptions/ramassage-des-accueils-de-loisirs-du-mercredi-inscription-mensuelle-1/',
     'meyzieu.png'),
    ('https://eservices.montpellier3m.fr/',
     'montpellier.png'),
    ('https://sussargues.test-eservices.montpellier3m.fr/',
     'sussargues.png'),
    ('https://vendargues.test-eservices.montpellier3m.fr/',
     'vendargues.png'),
    ('https://demarches.vincennes.fr/question/votre-question-jeunesse/',
     'vincennes.png'),
    ]

svg_src = open('screen-with-capture.svg').read()
for url, filename in captures:
    print url
    print 'creating capture'
    subprocess.call(['phantomjs', '--ssl-protocol=any',
        '--ignore-ssl-errors=yes', 'capture.js', url, 'captures/%s' % filename])

    print 'putting it in a mini screen'
    svg_dst = svg_src.replace('xxx.png', 'captures/%s' % filename)
    svg_path = open('/tmp/.xxx.svg', 'w')
    svg_path.write(svg_dst)
    svg_path.close()
    subprocess.call(['inkscape', '--without-gui',
        '--file', '/tmp/.xxx.svg',
        '--export-area-drawing',
        '--export-area-snap',
        '--export-png', 'screen-%s' % filename,
        '--export-width', '250'])

filenames = [x[1] for x in captures]


# gm montage screen-*.png -geometry +10+0 -tile 8x1 -background none ../screens.png
# +10+0 <- 10 is the margin
# 8x1   <- 8 is the number of images
print 'assembling mini screens'
subprocess.call(['gm', 'montage'] + ['screen-%s' % x for x in filenames] +
    ['-geometry', '+10+0', '-tile', '%sx1' % len(captures),
     '-background', 'none', '../../screens.png'])