#!/usr/bin/env python
#-*- coding: utf-8 -*-
import codecs
import json

import requests
from fabric.api import local, task


@task
def build():
    "Build the website"
    local('python build.py')


@task
def download():
    "Download the GeoJSON map"
    req = requests.get('https://gist.github.com/brunobord/6206708/raw/map.geojson')
    data = json.loads(req.text)
    with codecs.open('map.geojson', mode="w", encoding="utf-8") as geojson:
        geojson.write(json.dumps(data, indent=3))


@task
def all():
    "Do the whole shebang"
    build()
    download()


@@ -115,16 +115,25 @@
 al, task
+, run, cd
 %0A%0A%0A@task
@@ -494,24 +494,145 @@
 ndent=3))%0A%0A%0A
+@task%0Adef update():%0A    %22Update the website%22%0A    with cd('vhosts/jehaisleprintemps/bayonne/'):%0A        run('git pull')%0A%0A%0A
 @task%0Adef al
@@ -690,9 +690,21 @@
 nload()%0A
+    update()
 %0A

update on hosts.