2 # -*- coding: utf-8 -*-
4 # This file is part of my.gpodder.org.
6 # my.gpodder.org is free software: you can redistribute it and/or modify it
7 # under the terms of the GNU Affero General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or (at your
9 # option) any later version.
11 # my.gpodder.org is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
14 # License for more details.
16 # You should have received a copy of the GNU Affero General Public License
17 # along with my.gpodder.org. If not, see <http://www.gnu.org/licenses/>.
24 # Make sure the local "mygpo" package is in our PATH
25 sys
.path
.insert(0, os
.path
.join(os
.path
.dirname(__file__
), '..'))
27 from mygpo
.settings
import *
29 # All allowed procedure names should be listed here
30 VALID_PROCEDURES
= ('update_suggestion', 'update_toplist')
32 if len(sys
.argv
) != 2 or sys
.argv
[-1] not in VALID_PROCEDURES
:
33 print >>sys
.stderr
, """
35 """ % (sys
.argv
[0], '|'.join(VALID_PROCEDURES
))
37 procedure_name
= sys
.argv
[-1]
39 connection
= MySQLdb
.connect(host
=DATABASE_HOST
, user
=DATABASE_USER
, \
40 passwd
=DATABASE_PASSWORD
, db
=DATABASE_NAME
)
42 cur
= connection
.cursor()
43 cur
.callproc(procedure_name
, ())
47 except MySQLdb
.Error
, e
:
48 print >>sys
.stderr
, 'MySQL Error %d: %s' % (e
.args
[0], e
.args
[1])