#!/usr/bin/env python # # Copyright (C) 2005 Red Hat, Inc. # # 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., 675 Mass Ave, Cambridge, MA 02139, USA. # if __name__ == '__main__': import sys from sabayon import util from sabayon import userdb util.init_gettext () is_sabayon_session = False if len (sys.argv) >= 2: if sys.argv[1] == "-s": is_sabayon_session = True sys.argv = sys.argv[:1] + sys.argv[2:] if len (sys.argv) == 1: user_name = util.get_user_name () profile_name = userdb.get_database().get_profile (user_name) if not profile_name: sys.stderr.write (_("No profile for user '%s' found\n") % user_name) sys.exit (1) elif len (sys.argv) == 2: profile_name = sys.argv[1] else: sys.stderr.write (_("Usage: %s []\n") % sys.argv[0]) sys.exit (1) from sabayon import userprofile def dprint (fmt, *args): util.debug_print (util.DEBUG_ADMINTOOL, fmt % args) dprint ("Applying profile '%s' for user '%s'", profile_name, util.get_user_name ()) profile = userprofile.UserProfile (profile_name) profile.apply (is_sabayon_session) dprint ("Finished applying profile '%s' for user '%s'", profile_name, util.get_user_name ())