summaryrefslogtreecommitdiff
path: root/bin/kiwi-i18n
blob: ab0465d66e7ea90e903045ff0b90f85276487272 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python
#
# Copyright (C) 2005 by Async Open Source
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser 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 Lesser 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.

import os
import sys

# Required version of Python
#REQUIRED_VERSION = (2, 1)

# Directory name, defaults to name of binary, it is relative to ..
# a, __init__.py and main.py is expected to be found there.
DIRNAME = 'kiwi'

# Application name, defaults to capitalized name of binary
APPNAME = None

# Do not modify code below this point
dirname = DIRNAME or os.path.split(sys.argv[0])[1]
appname = APPNAME or dirname.capitalize()

# if sys.hexversion < int('%02x%02x0000' % REQUIRED_VERSION, 16):
#     raise SystemExit("ERROR: Python %s or higher is required to run %s, "
#                      "%s found" % ('.'.join(map(str, REQUIRED_VERSION)),
#                                    appname,
#                                    sys.version.split()[0]))

# Figure out the directy which is the prefix
# path-of-current-file/..
currentdir = os.path.dirname(os.path.abspath(sys.argv[0]))
basedir = os.path.abspath(os.path.join(currentdir, '..'))

# Add the base directory where the application is installed in to sys.path
if os.path.exists(os.path.join(basedir, 'lib')):
    pythondir = os.path.join(basedir, 'lib',
                             'python%d.%d' % sys.version_info[:2],
                             'site-packages')
    if not os.path.exists(pythondir):
        raise SystemExit("ERROR: Could not find required directory: %s" %
                         pythondir)
elif not os.path.exists(os.path.join(basedir, dirname)):
    raise SystemExit("ERROR: Could not find required directory: %s" %
                     os.path.join(basedir, dirname))
else:
    pythondir = basedir

sys.path.insert(0, pythondir)

main_module = 'kiwi.i18n.i18n'
try:
    module = __import__(main_module, globals(), locals(), 'main')
except Exception, e:
    raise SystemExit("ERROR: Failed to import required module %s\n\n"
                     "Exception raised during import:\n %s: %s\n" %
                     (main_module, e.__class__.__name__, e))

main = getattr(module, 'main', None)
if not main or not callable(main):
    raise SystemExit("ERROR: Could not find callable 'main' in module %s" %
                     main_module)

try:
    sys.exit(main(sys.argv))
except KeyboardInterrupt:
    raise SystemExit