~ubuntu-branches/ubuntu/precise/grass/precise

« back to all changes in this revision

Viewing changes to gui/wxpython/gui_modules/grassenv.py

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Paolo Lovergine
  • Date: 2011-04-13 17:08:41 UTC
  • mfrom: (8.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110413170841-ss1t9bic0d0uq0gz
Tags: 6.4.1-1
* New upstream version.
* Now build-dep on libjpeg-dev and current libreadline6-dev.
* Removed patch swig: obsolete.
* Policy bumped to 3.9.2, without changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""
2
 
MODULE:     grassenv
3
 
 
4
 
PURPOSE:    GRASS environment variable management
5
 
 
6
 
AUTHORS:    The GRASS Development Team
7
 
            Jachym Cepicky (Mendel University of Agriculture)
8
 
            Martin Landa <landa.martin gmail.com>
9
 
 
10
 
COPYRIGHT:  (C) 2006-2007 by the GRASS Development Team
11
 
            This program is free software under the GNU General Public
12
 
            License (>=v2). Read the file COPYING that comes with GRASS
13
 
            for details.
14
 
 
15
 
"""
16
 
 
17
 
import os
18
 
import sys
19
 
 
20
 
import globalvar
21
 
 
22
 
try:
23
 
    import subprocess
24
 
except:
25
 
    CompatPath = os.path.join(globalvar.ETCWXDIR, "compat")
26
 
    sys.path.append(CompatPath)
27
 
    import subprocess
28
 
    
29
 
# import gcmd
30
 
 
31
 
def GetGRASSVariable(var):
32
 
    """Return GRASS variable or '' if variable is not defined"""
33
 
    # gisEnv = gcmd.Command(['g.gisenv'])
34
 
 
35
 
    gisEnv = subprocess.Popen(['g.gisenv' + globalvar.EXT_BIN],
36
 
                              stdin=None,
37
 
                              stdout=subprocess.PIPE,
38
 
                              stderr=None)
39
 
 
40
 
    for item in gisEnv.stdout.readlines():
41
 
        if var in item:
42
 
            return item.split('=')[1].replace("'",'').replace(';','').strip()
43
 
 
44
 
    return None