Log using the "0install" logger rather than "root"
[zeroinstall/solver.git] / zeroinstall / __init__.py
blob7dbcc2a000f294c180dc1f66ecd9a29d0dae1c8f
1 """
2 The Python implementation of the Zero Install injector is divided into five sub-packages:
4 - L{zeroinstall.cmd} contains one module for each 0install sub-command (providing the shell-scripting interface)
5 - L{zeroinstall.injector} contains most of the interesting stuff for managing feeds, keys and downloads and for selecting versions
6 - L{zeroinstall.zerostore} contains low-level code for handling the implementation cache (where unpacked packages are stored)
7 - L{zeroinstall.gtkui} contains code for making GTK user-interfaces
8 - L{zeroinstall.support} contains helper code (not really specific to Zero Install)
10 @copyright: (C) 2011, Thomas Leonard
11 @see: U{http://0install.net}
13 @var _: a function for translating strings using the zero-install domain (for use internally by Zero Install)
14 """
16 version = '1.10'
18 import sys, logging
19 if sys.version_info[0] > 2:
20 try:
21 from gi.repository import GObject as gobject
22 except ImportError:
23 import gobject
24 else:
25 import gobject
26 gobject.threads_init()
28 logger = logging.getLogger('0install')
30 # Configure some basic logging, if the caller hasn't already done so.
31 logging.basicConfig()
33 import gettext
34 from os.path import dirname, join
36 try:
37 localedir = None
38 translation = gettext.translation('zero-install', fallback = False)
39 except:
40 localedir = join(dirname(dirname(__file__)), 'share', 'locale')
41 translation = gettext.translation('zero-install',
42 localedir = localedir,
43 fallback = True)
44 try:
45 _ = translation.ugettext # Python 2
46 except AttributeError:
47 _ = translation.gettext # Python 3
49 class SafeException(Exception):
50 """An exception that can be reported to the user without a stack trace.
51 The command-line interface's C{--verbose} option will display the full stack trace."""
53 class NeedDownload(SafeException):
54 """Thrown if we tried to start a download and downloading is
55 disabled."""
56 def __init__(self, url):
57 Exception.__init__(self, _("Would download '%s'") % url)