summaryrefslogtreecommitdiff
path: root/src/flufig.py
blob: c2c58c75ce08e456ccc1e1f4b0952e8789d7b90f (plain) (blame)
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
#!/usr/bin/python
#
# flufig
#
# flufig is a simple flumotion configuration generator using
# pyhton jinja2 template engine and simplejson. flufig generates
# planet.xml and worker.xml files from configuration templates and
# a easy representation of the flow structure written in json.
#
#
# Copyright (C) 2012 Christian Pointner <equinox@spreadspace.org>
#
# This file is part of flufig.
#
# flufig is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# flufig is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with flufig. If not, see <http://www.gnu.org/licenses/>.
#

import sys
from exceptions import *
from jinja2 import Environment, FileSystemLoader

if len(sys.argv) <= 2:
    raise SystemExit("No template and or data file given")

data = [];
env = Environment(loader=FileSystemLoader('../templates/%s/' % (sys.argv[1])))
template = env.get_template('planet.xml')
planet = template.render(data)

sys.stdout.write(planet.encode("utf8"))