~jonobacon/ubuntu-accomplishments-daemon/ubuntu-accomplishments-daemon

« back to all changes in this revision

Viewing changes to bin/trophyinfo

  • Committer: Jono Bacon
  • Date: 2012-04-08 22:11:10 UTC
  • Revision ID: jono@ubuntu.com-20120408221110-3ihxpctu5kryp460
Creating ubuntu package

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
 
# This file is in the public domain
5
 
### END LICENSE
6
 
import sys
7
 
import os
8
 
 
9
 
import gettext
10
 
from gettext import gettext as _
11
 
 
12
 
 
13
 
gettext.textdomain('trophyinfo')
14
 
# Add project root directory (enable symlink and trunk execution)
15
 
PROJECT_ROOT_DIRECTORY = os.path.abspath(
16
 
    os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))))
17
 
 
18
 
python_path = [',']
19
 
if os.path.abspath(__file__).startswith('/opt'):
20
 
    syspath = sys.path[:] # copy to avoid infinite loop in pending objects
21
 
    for path in syspath:
22
 
        opt_path = path.replace('/usr', '/opt/extras.ubuntu.com/trophyinfo')
23
 
        python_path.insert(0, opt_path)
24
 
        sys.path.insert(0, opt_path)
25
 
if (os.path.exists(os.path.join(PROJECT_ROOT_DIRECTORY, 'accomplishments'))
26
 
    and PROJECT_ROOT_DIRECTORY not in sys.path):
27
 
    python_path.insert(0, PROJECT_ROOT_DIRECTORY)
28
 
    sys.path.insert(0, PROJECT_ROOT_DIRECTORY)
29
 
if python_path:
30
 
    os.putenv(
31
 
        'PYTHONPATH', 
32
 
        "%s:%s" % (os.getenv('PYTHONPATH', ''), 
33
 
        ':'.join(python_path))) # for subprocesses
34
 
 
35
 
 
36
 
from accomplishments.main import main
37
 
 
38
 
 
39
 
main()