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

« back to all changes in this revision

Viewing changes to bin/webbar

  • Committer: App Bot
  • Author(s): Lucas R. Martins
  • Date: 2012-07-02 23:22:40 UTC
  • Revision ID: appbot@holba.ch-20120702232240-j6bffe4bs4l0ia1e
Tags: 12.06.2-public3
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 Lucas R. Martins <lukasrms@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
 
19
import os
 
20
 
 
21
import gettext
 
22
from gettext import gettext as _
 
23
gettext.textdomain('webbar')
 
24
 
 
25
# Add project root directory (enable symlink and trunk execution)
 
26
PROJECT_ROOT_DIRECTORY = os.path.abspath(
 
27
    os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))))
 
28
 
 
29
python_path = []
 
30
if os.path.abspath(__file__).startswith('/opt'):
 
31
    syspath = sys.path[:] # copy to avoid infinite loop in pending objects
 
32
    for path in syspath:
 
33
        opt_path = path.replace('/usr', '/opt/extras.ubuntu.com/webbar')
 
34
        python_path.insert(0, opt_path)
 
35
        sys.path.insert(0, opt_path)
 
36
if (os.path.exists(os.path.join(PROJECT_ROOT_DIRECTORY, 'webbar'))
 
37
    and PROJECT_ROOT_DIRECTORY not in sys.path):
 
38
    python_path.insert(0, PROJECT_ROOT_DIRECTORY)
 
39
    sys.path.insert(0, PROJECT_ROOT_DIRECTORY)
 
40
if python_path:
 
41
    os.putenv('PYTHONPATH', "%s:%s" % (os.getenv('PYTHONPATH', ''), ':'.join(python_path))) # for subprocesses
 
42
 
 
43
import webbar
 
44
webbar.main()