Mercurial > sat_legacy_website
diff sat_website/utils.py @ 1:a49aa1b823f6
added SàT archive download link (detect the last version)
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 29 Jul 2012 01:52:27 +0200 |
parents | |
children | 31d196cf3b34 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sat_website/utils.py Sun Jul 29 01:52:27 2012 +0200 @@ -0,0 +1,40 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +""" +SàT website: Salut à Toi's presentation website +Copyright (C) 2012 Jérôme Poisson (goffi@goffi.org) + +This file is part of SàT website. + +SàT website is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Foobar 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 Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with Foobar. If not, see <http://www.gnu.org/licenses/>. +""" + +from os.path import basename,realpath,join +from django.conf import settings + +def get_latest_sat(): + """Return a tuple with download path of latest SàT version, and version number""" + try: + path = settings.SAT_LINK_PATH + real_path = realpath(path) + filename = basename(real_path) + version = filename[4:-8] #filename must be in the form of sat-version.tar.bz2 + if hasattr(settings, "SAT_DL_PATH"): + dl_path = settings.SAT_DL_PATH + else: + dl_path = join(settings.SAT_DL_PREFIX, filename) + except AttributeError: + return (None, None) + + return (dl_path, version)