def compile_mapfile(name, srs, stylesheets, *layers):

    with open(name + ".mml", 'w') as mapfile:
        mapfile.write(json.dumps(compile_mml(srs, stylesheets, *layers), indent=4))
    carto = sh.Command(settings.CARTO_HOME + "/bin/carto")
    carto(name + '.mml', _out=name + '.xml')
Compile from Carto to Mapnik
dataset/ETHPy150Open hydroshare/hydroshare2/ga_resources/drivers/__init__.py/compile_mapfile