Pièce jointe « updates.py »

Téléchargement

   1 #!/usr/bin/env python
   2 # -*- coding: utf-8 -*-
   3 """
   4 updates.py - this file is part of SOGo
   5 
   6  Copyright (C) 2006-2010 Inverse inc.
   7  Copyright (C) 2011 Agence universitaire de la Francophonie - www.auf.org
   8 
   9 PHP version author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
  10 Python version author: Progfou <jean-christophe.andre@auf.org>
  11 
  12 This file is free software; you can redistribute it and/or modify
  13 it under the terms of the GNU General Public License as published by
  14 the Free Software Foundation; either version 2, or (at your option)
  15 any later version.
  16 
  17 This file is distributed in the hope that it will be useful,
  18 but WITHOUT ANY WARRANTY; without even the implied warranty of
  19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20 GNU General Public License for more details.
  21 
  22 You should have received a copy of the GNU General Public License
  23 along with this program; see the file COPYING.  If not, write to
  24 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  25 Boston, MA 02111-1307, USA.
  26 
  27 This script handles the automatic propagation of extensions pertaining
  28 to a SOGo site. It requires Python 2.5 or later.
  29 """
  30 import sys
  31 import os.path
  32 import cgi, cgitb 
  33 
  34 BASE_URL = "https://sogo.vn.auf.org/plugins"
  35 
  36 PLUGINS = {
  37     "sogo-connector@inverse.ca": {
  38         "application": "thunderbird",
  39         "version": "3.106",
  40         "filename": "sogo-connector-3.106.xpi",
  41     },
  42     "sogo-integrator@inverse.ca": {
  43         "application": "thunderbird",
  44         "version": "3.106",
  45         "filename": "sogo-integrator-3.106.xpi",
  46     },
  47     "{e2fda1a4-762b-4020-b5ad-a41df1933103}": {
  48         "application": "thunderbird",
  49         "version": "1.0b2.106i",
  50         "filename": "lightning-1.0b2.106i.xpi",
  51     },
  52 }
  53 
  54 APPLICATIONS = {
  55     "thunderbird": "<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>\
  56                     <em:minVersion>3.1.0</em:minVersion>\
  57                     <em:maxVersion>3.1.*</em:maxVersion>",
  58 }
  59 
  60 form = cgi.FieldStorage() 
  61 
  62 pluginname = form.getvalue("plugin")
  63 plugin = PLUGINS.get(pluginname, None)
  64 
  65 if plugin:
  66     platform = form.getvalue("platform")
  67     if platform and os.path.exists(os.path.join(platform, plugin["filename"])):
  68         plugin["filename"] = os.path.join(platform, plugin["filename"])
  69     elif not os.path.exists(plugin["filename"]):
  70         plugin = False
  71 
  72 if plugin:
  73     headers = [
  74         "Content-Type: text/xml; charset=utf-8",
  75         "Status: 200 OK",
  76     ]
  77     body = """<?xml version="1.0"?>
  78 <!DOCTYPE RDF>
  79 <RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  80   xmlns:em="http://www.mozilla.org/2004/em-rdf#">
  81   <Description about="urn:mozilla:extension:%(name)s">
  82     <em:updates>
  83       <Seq>
  84         <li>
  85           <Description>
  86             <em:version>%(version)s</em:version>
  87             <em:targetApplication>
  88               <Description>%(application)s
  89 		<em:updateLink>%(base_url)s/%(filename)s</em:updateLink>
  90 	      </Description>
  91             </em:targetApplication>
  92           </Description>
  93         </li>
  94       </Seq>
  95     </em:updates>
  96   </Description>
  97 </RDF>""" % { 'name': pluginname, 'version': plugin['version'], \
  98               'application': APPLICATIONS[plugin["application"]], \
  99               'base_url': BASE_URL, 'filename': plugin['filename'] }
 100 else:
 101     headers = [
 102         "Content-Type: text/plain; charset=utf-8",
 103         "Status: 404 Not found",
 104     ]
 105     body = "Plugin not found"
 106 
 107 headers.append("Content-Length: %s" % len(body))
 108 print '\r\n'.join(headers), '\r\n\r\n', body
 109 sys.exit(0)

Fichiers joints

Pour vous référer aux pièces jointes d'une page, utilisez attachment:filename, comme indiqué ci-dessous dans la liste de fichiers. N'utilisez pas l'URL du lien [get], car elle peut changer et donc être facilement cassée.
 All files | Selected Files: delete move to page copy to page

Vous n'êtes pas autorisé à joindre un fichier à cette page.