~ubuntu-app-review-contributors/ubuntu-app-reviews/aplomb

« back to all changes in this revision

Viewing changes to bin/aplomb

  • Committer: App Bot
  • Author(s): Sam Hewitt
  • Date: 2012-07-04 10:47:42 UTC
  • Revision ID: appbot@holba.ch-20120704104742-zlh4oeq2fivvs0sb
Tags: 12.07.13
New release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
 
3
### BEGIN LICENSE
 
4
# Copyright (C) 2012 Sam Hewitt <hewittsamuel@gmail.com>
 
5
# This program is free software: you can redistribute it and/or modify it 
 
6
# under the terms of the GNU General Public License version 3, as published 
 
7
# by the Free Software Foundation.
 
8
 
9
# This program is distributed in the hope that it will be useful, but 
 
10
# WITHOUT ANY WARRANTY; without even the implied warranties of 
 
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
 
12
# PURPOSE.  See the GNU General Public License for more details.
 
13
 
14
# You should have received a copy of the GNU General Public License along 
 
15
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
### END LICENSE
 
17
 
 
18
import sys, os, locale
 
19
 
 
20
TEXTDOMAIN = 'aplomb'
 
21
LOCALEDIR = '/opt/extras.ubuntu.com/aplomb/share/locale'
 
22
#LOCALEDIR = '/usr/aplomb/share/locale'
 
23
from locale import gettext as _
 
24
locale.bindtextdomain(TEXTDOMAIN, LOCALEDIR)
 
25
locale.textdomain(TEXTDOMAIN)
 
26
 
 
27
# Add project root directory (enable symlink and trunk execution)
 
28
PROJECT_ROOT_DIRECTORY = os.path.abspath(
 
29
    os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))))
 
30
 
 
31
python_path = []
 
32
if os.path.abspath(__file__).startswith('/opt'):
 
33
    syspath = sys.path[:] # copy to avoid infinite loop in pending objects
 
34
    for path in syspath:
 
35
        opt_path = path.replace('/usr', '/opt/extras.ubuntu.com/aplomb')
 
36
        python_path.insert(0, opt_path)
 
37
        sys.path.insert(0, opt_path)
 
38
if (os.path.exists(os.path.join(PROJECT_ROOT_DIRECTORY, 'aplomb'))
 
39
    and PROJECT_ROOT_DIRECTORY not in sys.path):
 
40
    python_path.insert(0, PROJECT_ROOT_DIRECTORY)
 
41
    sys.path.insert(0, PROJECT_ROOT_DIRECTORY)
 
42
if python_path:
 
43
    os.putenv('PYTHONPATH', "%s:%s" % (os.getenv('PYTHONPATH', ''), 
 
44
        ':'.join(python_path))) # for subprocesses
 
45
 
 
46
import aplomb
 
47
aplomb.main()