#! /usr/bin/env python # -*- coding: UTF-8 -*- """Removes logs older than 7 days """ # Copyright 2005, 2006 EIAO Consoritum # This program is distributed under the terms of the GNU General # Public License. # # This file is part of the European Internet Accessibility Observatory # (EIAO) # # EIAO 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. # # EIAO 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 EIAO; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1301 USA __owner__ = "Morten Goodwin Olsen" __maintainer__ = "Nils Ulltveit-Moe" __version__ = '$Id$' import SOAPpy import sys import urlparse import os actualrun = True def printHelp(): """Function for print help functionality This is needed as input to any user starting the ETL server. Exits all active modules. Returns None """ print 'Usage:\npython dbcleanerclient [OPTIONS]' print 'Options:' print '-p N - port to use. 8892 as default.' print '-s Server - Server to use. Localhost as default.' if __name__ == '__main__': sys.exit(1) try: if '-p' in sys.argv: port = sys.argv[sys.argv.index('-p')+1] else: port = '8892' if '-s' in sys.argv: server = sys.argv[sys.argv.index('-s')+1] else: #from socket import gethostname #server = gethostname() #server = 'localhost' import sc sc = sc.SystemConfiguration() server,port = urlparse.urlsplit(sc.dbcleaner)[1].split(':') except IndexError: actualrun = False printHelp() if '--help' in sys.argv: actualrun = False printHelp() if actualrun: os.system('/etc/init.d/dbcleaner restart') s = SOAPpy.SOAPProxy(''.join(['http://',server,':',port,'/'])) s.removeoldlogs()