~ara/ubuntu/lucid/mago/fix_tests_lucid

« back to all changes in this revision

Viewing changes to mago/cmd/globals.py

  • Committer: Bazaar Package Importer
  • Author(s): Ara Pulido
  • Date: 2009-08-04 09:21:40 UTC
  • Revision ID: james.westby@ubuntu.com-20090804092140-7ggrh3nlujflk0v8
Tags: upstream-0.1
ImportĀ upstreamĀ versionĀ 0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""
 
2
This module just provides a namespace for global variables used across
 
3
multiple modules in the package
 
4
"""
 
5
import os
 
6
 
 
7
def _get_grandparent_dir(filename):
 
8
    return os.path.dirname(os.path.dirname(os.path.dirname(filename)))
 
9
 
 
10
def _get_share_dir():
 
11
    if os.path.exists(os.path.join(_get_grandparent_dir(__file__), 'setup.py')):
 
12
        # We are in the build directory.
 
13
        return _get_grandparent_dir(__file__)
 
14
    else:
 
15
        # We are in an installed prefix.
 
16
        prefix = os.path.dirname(__file__)
 
17
        while not os.path.exists(os.path.join(prefix, 'share', 'mago')):
 
18
            new_prefix = os.path.dirname(prefix)
 
19
            if new_prefix == prefix:
 
20
                return _get_grandparent_dir(__file__)
 
21
            prefix = new_prefix
 
22
        
 
23
        return os.path.join(prefix, 'share', 'mago')
 
24
 
 
25
MAGO_SHARE = os.environ.get('MAGO_SHARE', _get_share_dir())
 
26
MAGO_PATH = [os.path.curdir, MAGO_SHARE]
 
27
 
 
28
if os.environ.get('MAGO_PATH', None):
 
29
    MAGO_PATH = os.environ['MAGO_PATH'].split(':')
 
30
 
 
31
SCREENSHOTS_SHARE = "/tmp/ldtp-screenshots"