Mercurial > sat_legacy_website
comparison sat_website/utils.py @ 39:d2c45f4ba57e
add downloads.html
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 27 Jan 2015 18:23:39 +0100 |
parents | 31d196cf3b34 |
children | dfe7139dae0a |
comparison
equal
deleted
inserted
replaced
38:e501f5ff7191 | 39:d2c45f4ba57e |
---|---|
18 | 18 |
19 You should have received a copy of the GNU Affero General Public License | 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/>. | 20 along with Foobar. If not, see <http://www.gnu.org/licenses/>. |
21 """ | 21 """ |
22 | 22 |
23 from os.path import basename,realpath,join | 23 from os.path import basename, realpath, join |
24 from django.conf import settings | 24 from django.conf import settings |
25 from collections import OrderedDict | |
25 | 26 |
26 def get_latest_sat(): | 27 |
27 """Return a tuple with download path of latest SàT version, and version number""" | 28 def get_projects_infos(infos): |
28 try: | 29 """Return a dict binding project names to a tuple containing: |
29 path = settings.SAT_LINK_PATH | 30 - the external download path |
30 real_path = realpath(path) | 31 - the version number |
31 filename = basename(real_path) | 32 - a short description about the project archive |
32 version = filename[4:-8] #filename must be in the form of sat-version.tar.bz2 | 33 |
33 if hasattr(settings, "SAT_DL_PATH"): | 34 @param infos: dict binding project names to a short description |
34 dl_path = settings.SAT_DL_PATH | 35 |
35 else: | 36 @return: dict {unicode: (unicode, unicode, unicode) |
36 dl_path = join(settings.SAT_DL_PREFIX, filename) | 37 """ |
37 except AttributeError: | 38 result = OrderedDict() |
38 return (None, None) | 39 for dir, name in settings.PROJECTS_NAMES: |
39 | 40 if not name: |
40 return (dl_path, version) | 41 name = dir |
42 path = join(dir, name) + settings.ARCHIVE_SUFFIX # e.g urwid-satext/urwid_satext.tar.bz2 | |
43 int_path = join(settings.PROJECTS_INTERNAL_PATH, path) # this is a symbolic link | |
44 # base name of the real path MUST look like: <project>-<version><ARCHIVE_SUFFIX> | |
45 version = basename(realpath(int_path))[len(name) + 1:-len(settings.ARCHIVE_SUFFIX)] | |
46 ext_path = join(settings.PROJECTS_EXTERNAL_PATH, path) | |
47 result[name] = (ext_path, version, infos[name] if name in infos else '') | |
48 | |
49 return result | |
41 | 50 |
42 def get_libervia_demo_url(): | 51 def get_libervia_demo_url(): |
43 """Return the URL to Libervia online demo""" | 52 """Return the URL to Libervia online demo""" |
44 return settings.LIBERVIA_DEMO_URL | 53 return settings.LIBERVIA_DEMO_URL |
45 | 54 |