#! /usr/bin/env python # PyKota Print Quota Warning sender # # PyKota - Print Quotas for CUPS and LPRng # # (c) 2003, 2004, 2005, 2006, 2007 Jerome Alet # 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; either version 2 of the License, or # (at your option) any later version. # # 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # $Id$ # # THIS IS AN UPGRADE SCRIPT FOR OLD PYKOTA DATABASES TO THE 1.03 VERSION # import sys import os try : import pg except ImportError : sys.stderr.write("The PyGreSQL Python module doesn't seem to be available. ABORTED.\n") sys.exit(-1) def dump_old_database() : """Dumps the existing PyKota database to a file, to avoir loosing data. Returns 1 if dump is successfull, 0 if it isn't. """ pipeinput = os.popen("pg_dump -C -D -N -U postgres -f pykota-dump.sql pykota") dummy = pipeinput.read() return (pipeinput.close() is None) or 0 def create_new_database() : """Creates the empty database.""" pipeinput = os.popen("psql -U postgres template1