~ubuntu-branches/ubuntu/wily/grass/wily

« back to all changes in this revision

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

Tags: 7.0.0~rc1+ds1-1~exp1
* New upstream release candidate.
* Repack upstream tarball, remove precompiled Python objects.
* Add upstream metadata.
* Update gbp.conf and Vcs-Git URL to use the experimental branch.
* Update watch file for GRASS 7.0.
* Drop build dependencies for Tcl/Tk, add build dependencies:
  python-numpy, libnetcdf-dev, netcdf-bin, libblas-dev, liblapack-dev
* Update Vcs-Browser URL to use cgit instead of gitweb.
* Update paths to use grass70.
* Add configure options: --with-netcdf, --with-blas, --with-lapack,
  remove --with-tcltk-includes.
* Update patches for GRASS 7.
* Update copyright file, changes:
  - Update copyright years
  - Group files by license
  - Remove unused license sections
* Add patches for various typos.
* Fix desktop file with patch instead of d/rules.
* Use minimal dh rules.
* Bump Standards-Version to 3.9.6, no changes.
* Use dpkg-maintscript-helper to replace directories with symlinks.
  (closes: #776349)
* Update my email to use @debian.org address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""
2
 
MODULE: debug
3
 
 
4
 
CLASSES:
5
 
 * DebugMsg
6
 
 
7
 
PURPOSE: GRASS debugging
8
 
 
9
 
         from debug import Debug as Debug
10
 
         Debug.msg (3, 'debug message')
11
 
         
12
 
AUTHORS: The GRASS Development Team
13
 
         Martin Landa <landa.martin gmail.com>
14
 
 
15
 
COPYRIGHT: (C) 2007-2008 by the GRASS Development Team
16
 
           This program is free software under the GNU General Public
17
 
           License (>=v2). Read the file COPYING that comes with GRASS
18
 
           for details.
19
 
"""
20
 
 
21
 
import os
22
 
import sys
23
 
 
24
 
import globalvar
25
 
 
26
 
class DebugMsg:
27
 
    """
28
 
    GRASS Debugging
29
 
 
30
 
    export GRASS_WX_DEBUG=[0-5]
31
 
    """
32
 
    def __init__(self):
33
 
        # default level
34
 
        self.debuglevel = 0
35
 
        # update level
36
 
        self._update_level()
37
 
 
38
 
    def _update_level(self):
39
 
        debug = os.getenv("GRASS_WX_DEBUG")
40
 
        if debug is not None:
41
 
            try:
42
 
                # only GUI debug messages [GUI:level]
43
 
                level = int (debug[-1])
44
 
            except:
45
 
                level = self.debuglevel
46
 
                
47
 
            if self.debuglevel != level:
48
 
                self.debuglevel = level
49
 
 
50
 
    def msg (self, level, message):
51
 
        self._update_level()
52
 
        if self.debuglevel > 0 and level > 0 and level <= self.debuglevel:
53
 
            print >> sys.stderr, "GUI D%d/%d: %s" % (level, self.debuglevel, message)
54
 
            sys.stderr.flush() # force flush (required for MS Windows)
55
 
        
56
 
    def get_level(self):
57
 
        """Return current GUI debug level"""
58
 
        return self.debuglevel
59
 
 
60
 
# Debug instance
61
 
Debug = DebugMsg()
62
 
 
63
 
# testing
64
 
if __name__ == "__main__":
65
 
    import gcmd
66
 
    gcmd.Command (cmd=["g.gisenv", "set=DEBUG=3"])
67
 
                
68
 
    for level in range (4):
69
 
        Debug.msg (level, "message level=%d" % level)