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

« back to all changes in this revision

Viewing changes to gui/wxpython/core/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
@package core.debug
 
3
 
 
4
@brief wxGUI debugging
 
5
 
 
6
Classes:
 
7
 - debug::DebugMsg
 
8
 
 
9
@code
 
10
from core.debug import Debug
 
11
Debug.msg (3, 'debug message')
 
12
@endcode
 
13
         
 
14
(C) 2007-2009, 2011 by the GRASS Development Team
 
15
 
 
16
This program is free software under the GNU General Public License
 
17
(>=v2). Read the file COPYING that comes with GRASS for details.
 
18
 
 
19
@author Martin Landa <landa.martin gmail.com>
 
20
"""
 
21
 
 
22
import os
 
23
import sys
 
24
 
 
25
import grass.script as grass
 
26
 
 
27
class DebugMsg:
 
28
    """wxGUI debugging
 
29
    
 
30
        g.gisenv set=WX_DEBUG=[0-5]
 
31
 
 
32
    """
 
33
    def __init__(self):
 
34
        # default level
 
35
        self.debuglevel = 0
 
36
        
 
37
        self.SetLevel()
 
38
 
 
39
    def SetLevel(self):
 
40
        """Initialize gui debug level
 
41
        """
 
42
        self.debuglevel = int(grass.gisenv().get('WX_DEBUG', 0))
 
43
        
 
44
    def msg(self, level, message, *args):
 
45
        """Print debug message
 
46
 
 
47
        :param level: debug level (0-5)
 
48
        :param message: message to be printed
 
49
        :param args: formatting params
 
50
        """
 
51
        # self.SetLevel()
 
52
        if self.debuglevel > 0 and level > 0 and level <= self.debuglevel:
 
53
            if args:
 
54
                sys.stderr.write("GUI D%d/%d: " % (level, self.debuglevel) + \
 
55
                    message % args + os.linesep)
 
56
            else:
 
57
                sys.stderr.write("GUI D%d/%d: " % (level, self.debuglevel) + \
 
58
                                     message + os.linesep)
 
59
            sys.stderr.flush() # force flush (required for MS Windows)
 
60
        
 
61
    def GetLevel(self):
 
62
        """Return current GUI debug level"""
 
63
        return self.debuglevel
 
64
 
 
65
# Debug instance
 
66
Debug = DebugMsg()