comparison 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
comparison
equal deleted inserted replaced
0:9305c6458e2f 1:a49aa1b823f6
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 """
4 SàT website: Salut à Toi's presentation website
5 Copyright (C) 2012 Jérôme Poisson (goffi@goffi.org)
6
7 This file is part of SàT website.
8
9 SàT website is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Affero General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 Foobar is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Affero General Public License for more details.
18
19 You should have received a copy of the GNU Affero General Public License
20 along with Foobar. If not, see <http://www.gnu.org/licenses/>.
21 """
22
23 from os.path import basename,realpath,join
24 from django.conf import settings
25
26 def get_latest_sat():
27 """Return a tuple with download path of latest SàT version, and version number"""
28 try:
29 path = settings.SAT_LINK_PATH
30 real_path = realpath(path)
31 filename = basename(real_path)
32 version = filename[4:-8] #filename must be in the form of sat-version.tar.bz2
33 if hasattr(settings, "SAT_DL_PATH"):
34 dl_path = settings.SAT_DL_PATH
35 else:
36 dl_path = join(settings.SAT_DL_PREFIX, filename)
37 except AttributeError:
38 return (None, None)
39
40 return (dl_path, version)