#!/usr/bin/env /usr/bin/python

### -*- Mode: Python -*-
###
### open-carpet
###
### Copyright (C) 2003, 2004 Ximian, Inc.
###
### This program is free software; you can redistribute it and/or
### modify it under the terms of version 2 of the GNU General Public
### License as published by the Free Software Foundation.
###
### 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.

open_carpet_py_path    = "/usr/share/open-carpet"

open_carpet_name      = "Open Carpet"
open_carpet_version   = "0.3"
open_carpet_copyright = "Copyright (C) 2003, 2004 Ximian, Inc.  All Rights Reserved."

#############################################################################

import sys

if open_carpet_py_path:
    sys.path.insert(0, open_carpet_py_path)

try:
    import redcarpet
except ImportError:
    sys.stderr.write("Unable to find libredcarpet python bindings.\n")
    sys.exit(1)

#############################################################################

exit_after_banner = 0
if "--version" in sys.argv:
    exit_after_banner = 1

#############################################################################

print open_carpet_name, open_carpet_version
print open_carpet_copyright

if exit_after_banner:
    sys.exit(0)

#############################################################################

import os
import oc_serverconf

if len(sys.argv) == 1:
    target = "."
else:
    target = sys.argv[1]

target = os.path.abspath(target)

sconf = oc_serverconf.ServerConf()

try:
    sconf.read(target, default_filename="server.conf")
except IOError, e:
    print "ERROR: %s" % e
    
