Accéder au contenu.
Menu Sympa

devel - Re: [Devel] Soumission d'évènements dans l'Ag enda

Objet : devel-adl

Archives de la liste

Re: [Devel] Soumission d'évènements dans l'Ag enda


Chronologique Discussions 
  • From: Thomas Petazzoni <thomas.petazzoni AT enix.org>
  • To: gulliver-ca AT listes.gulliver.eu.org
  • Cc: Developpement de l'Agenda du Libre <devel AT agendadulibre.org>
  • Subject: Re: [Devel] Soumission d'évènements dans l'Ag enda
  • Date: Sun, 25 Sep 2005 22:29:35 +0200
  • List-archive: <http://lolut.utbm.info/pipermail/devel>
  • List-id: Developpement de l'Agenda du Libre <devel.agendadulibre.org>

Salut,

Thomas Petazzoni a écrit :

> Pour faciliter la soumission dans l'Agenda du Libre de la permanence
> Gulliver du vendredi soir, j'ai écrit le petit script Python joint. Il
> suffit de lui passer en argument la date de la permanence, par exemple:

Évidemment, c'est au moment où on annonce la chose qu'on s'aperçoit que
le script n'est pas correct.

> curl.setopt (curl.URL,
> 'http://humanoidz.org/~thomas/agenda/submit.php')

L'erreur est là, il fallait mettre
'http://www.agendadulibre.org/submit.php'.

Le script joint est la bonne version.

Désolé du bruit.

Bonne soirée,

Thomas
--
PETAZZONI Thomas - thomas.petazzoni AT enix.org
http://{thomas,sos,kos}.enix.org - Jabber: thomas.petazzoni AT jabber.dk
http://{agenda,livret}dulibre.org
Fingerprint : 0BE1 4CF3 CEA4 AC9D CC6E 1624 F653 CB30 98D3 F7A7
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-

# Copyright (C) 2005 Thomas Petazzoni <thomas.petazzoni AT enix.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#
# This program allows to submit an event to the Agenda du Libre
# website. It is very useful for regular events, that always have the
# same description, hours, location, etc.
#
# Usage:
#           ./adl-submit.py YYYY-MM-DD
#


#
# Configuration part
#

title  = "Permanence Logiciels Libres"
city   = "Rennes"
region = "6" # Bretagne

start_hour = 20
start_min  = 0
end_hour   = 23
end_min    = 0

description = """<p><a href=\"http://www.gulliver.eu.org\";>Gulliver</a> organise chaque semaine une permanence <i>Logiciels Libres</i> ouverte à tous, membres de l'association ou non.</p>

<p>Durant cette permanence, vous pourrez trouver des réponses aux questions que vous vous posez au sujet du Logiciel Libre, ainsi que de l'aide pour résoudre vos problèmes d'installation, de configuration et d'utilisation de Logiciels Libres. N'hésitez pas à apporter votre ordinateur, afin que les autres participants puissent vous aider.</p>

<p>Une connexion Internet est disponible sur place, ainsi que les mises à jour pour les distributions GNU/Linux les plus courantes.</p>"""

url     = "http://www.gulliver.eu.org";
contact = "contact AT gulliver.eu.org"

#
# Code
#

def usage():
    print "Usage: ./adl-submit.py YYYY-MM-DD"
    sys.exit(1)

import sys
import pycurl
import StringIO
import re

if len(sys.argv) != 2:
    usage()

regexp = re.compile(r'([0-9]{4})-0?(1?[0-9])-([0-9]{2})')
regexp_result = regexp.search(sys.argv[1])
if regexp_result is None:
    usage()

year  = regexp_result.groups(0)[0]
month = regexp_result.groups(0)[1]
day   = regexp_result.groups(0)[2]

if int(year) < 2005                    or \
       int(month) not in range (1, 13) or \
       int(day)   not in range (1, 32):
    usage()

curl = pycurl.Curl()
contents = StringIO.StringIO()
curl.setopt (curl.URL,
             'http://www.agendadulibre.org/submit.php')

curl.setopt(curl.HTTPPOST,  [('__event_title',        title),
                             ('__event_start_day',    day),
                             ('__event_start_month',  month),
                             ('__event_start_year',   year),
                             ('__event_start_hour',   str(start_hour)),
                             ('__event_start_minute', str(start_min)),
                             ('__event_end_day',      day),
                             ('__event_end_month',    month),
                             ('__event_end_year',     year),
                             ('__event_end_hour',     str(end_hour)),
                             ('__event_end_minute',   str(end_min)),
                             ('__event_description',  str(description)),
                             ('__event_city',         city),
                             ('__event_region',       str(region)),
                             ('__event_locality',     str(0)),
                             ('__event_url',          url),
                             ('__event_contact',      contact),
                             ('__event_save',         str(1))])

curl.setopt(curl.WRITEFUNCTION, contents.write)
curl.perform()

if curl.getinfo(curl.HTTP_CODE) != 200:
    print "Error while submitting event"
else:
    print "Event succesfully submitted"

Attachment: signature.asc
Description: OpenPGP digital signature




Archives gérées par MHonArc 2.6.16.

Haut de le page