#!/usr/bin/python3 ############################################################################### # # # Pakfire - The IPFire package management system # # Copyright (C) 2017 Pakfire development team # # # # 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 3 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, see . # # # ############################################################################### import os import sys # Catch ImportError and show a more user-friendly message about what went wrong try: import pakfire.cli except ImportError as e: # Try to load at least the i18n support, but when this fails as well we can # go with an English error message. try: from pakfire.i18n import _ except ImportError: _ = lambda x: x print(_("There has been an error when trying to import one or more of the" " modules, that are required to run Pakfire.")) print(_("Please check your installation of Pakfire.")) print() print(_("The error that lead to this:")) print(" ", e) print() # Exit immediately. sys.exit(1) basename2cls = { "pakfire" : pakfire.cli.Cli, "pakfire-builder" : pakfire.cli.CliBuilder, "pakfire-client" : pakfire.cli.CliClient, "pakfire-daemon" : pakfire.cli.CliDaemon, "pakfire-key" : pakfire.cli.CliKey, "builder" : pakfire.cli.CliBuilderIntern, } # Get the basename of the program basename = os.path.basename(sys.argv[0]) # Check if the program was called with a weird basename. # If so, we exit immediately. if basename not in basename2cls: sys.exit(127) cli = basename2cls[basename]() ret = cli.run() sys.exit(ret)