]> git.ipfire.org Git - people/stevee/pakfire.git/blame - scripts/pakfire-multicall.py
Reorder arguments when linking debugedit.
[people/stevee/pakfire.git] / scripts / pakfire-multicall.py
CommitLineData
47a4cb89
MT
1#!/usr/bin/python
2
47a4cb89
MT
3import os
4import sys
5
3eca2587
MT
6import logging
7log = logging.getLogger("pakfire")
8
60845a36
MT
9try:
10 from pakfire.cli import *
11 from pakfire.i18n import _
12
13except ImportError, e:
14 # Catch ImportError and show a more user-friendly message about what
15 # went wrong.
16
17 # Try to load at least the i18n support, but when this fails as well we can
18 # go with an English error message.
19 try:
20 from pakfire.i18n import _
21 except ImportError:
22 _ = lambda x: x
23
24 # XXX Maybe we can make a more beautiful message here?!
25 print _("There has been an error when trying to import one or more of the"
26 " modules, that are required to run Pakfire.")
1c5de927 27 print _("Please check your installation of Pakfire.")
60845a36
MT
28 print
29 print _("The error that lead to this:")
30 print " ", e
31 print
32
33 # Exit immediately.
34 sys.exit(1)
47a4cb89
MT
35
36basename2cls = {
9b875540
MT
37 "pakfire" : Cli,
38 "pakfire-builder" : CliBuilder,
39 "pakfire-server" : CliServer,
40 "builder" : CliBuilderIntern,
47a4cb89
MT
41}
42
43# Get the basename of the program
44basename = os.path.basename(sys.argv[0])
45
46# Check if the program was called with a weird basename.
47# If so, we exit immediately.
48if not basename2cls.has_key(basename):
49 sys.exit(127)
50
47a4cb89
MT
51# Return code for the shell.
52ret = 0
53
54try:
936f6b37
MT
55 # Creating command line interface
56 cli = basename2cls[basename]()
57
47a4cb89
MT
58 cli.run()
59
60except KeyboardInterrupt:
3eca2587 61 log.critical("Recieved keyboard interupt (Ctrl-C). Exiting.")
47a4cb89
MT
62 ret = 1
63
60845a36
MT
64# Catch all errors and show a user-friendly error message.
65except Error, e:
3eca2587
MT
66 log.critical("")
67 log.critical(_("An error has occured when running Pakfire."))
68 log.error("")
60845a36 69
3eca2587
MT
70 log.error(_("Error message:"))
71 log.error(" %s: %s" % (e.__class__.__name__, e.message))
72 log.error("")
60845a36 73
3eca2587
MT
74 log.error(_("Further description:"))
75 log.error(" %s" % e)
76 log.error("")
60845a36
MT
77
78 ret = e.exit_code
79
47a4cb89
MT
80sys.exit(ret)
81