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

###
### Copyright 2002-2003 Ximian, Inc.
###
### This program is free software; you can redistribute it and/or modify
### it under the terms of the GNU General Public License, version 2,
### 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.
###

try:
    import sys
    import os

    rug_dir = "/usr/share/rug"

    # This is where we look for binary extensions (like the fast
    # unmarshaller).
    rug_lib_dir = "/usr/lib64/rug"

    rug_version = "2.4.4"

    # FIXME: This has a special check to allow us to run rug in-place
    # without having done a "make install".  We might want to take this
    # out at some point.

    if not (os.path.isfile("./rcmain.py") \
            or (os.path.isdir(rug_dir) and os.path.isfile(rug_dir + "/rcmain.py"))):
        print "ERROR: The Red Carpet Command Line Client (rug) doesn't appear to be"
        print "ERROR: installed properly.  Please check your installation."
        sys.exit(1)


    sys.path.append(rug_dir)
    sys.path.append(rug_lib_dir)
    import rcmain

    if "--rug-profile" in sys.argv:
        import profile
        sys.stderr.write("*** Profiling Enabled ***\n")
        sys.argv = filter(lambda x:x != "--rug-profile", sys.argv)
        profile.run("rcmain.main(rug_version, rug_dir)")
    else:
        rcmain.main(rug_version, rug_dir)
except KeyboardInterrupt:
    # Just quietly exit if we got a ^C
    print
    sys.exit(0)
    

