1#!/usr/bin/env python
2###############################################################################
3#                                                                             #
4#    groopmExceptions.py                                                      #
5#                                                                             #
6#    Like it says on the box                                                  #
7#                                                                             #
8#    Copyright (C) Michael Imelfort                                           #
9#                                                                             #
10###############################################################################
11#                                                                             #
12#          .d8888b.                                    888b     d888          #
13#         d88P  Y88b                                   8888b   d8888          #
14#         888    888                                   88888b.d88888          #
15#         888        888d888 .d88b.   .d88b.  88888b.  888Y88888P888          #
16#         888  88888 888P"  d88""88b d88""88b 888 "88b 888 Y888P 888          #
17#         888    888 888    888  888 888  888 888  888 888  Y8P  888          #
18#         Y88b  d88P 888    Y88..88P Y88..88P 888 d88P 888   "   888          #
19#          "Y8888P88 888     "Y88P"   "Y88P"  88888P"  888       888          #
20#                                             888                             #
21#                                             888                             #
22#                                             888                             #
23#                                                                             #
24###############################################################################
25#                                                                             #
26#    This program is free software: you can redistribute it and/or modify     #
27#    it under the terms of the GNU General Public License as published by     #
28#    the Free Software Foundation, either version 3 of the License, or        #
29#    (at your option) any later version.                                      #
30#                                                                             #
31#    This program is distributed in the hope that it will be useful,          #
32#    but WITHOUT ANY WARRANTY; without even the implied warranty of           #
33#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
34#    GNU General Public License for more details.                             #
35#                                                                             #
36#    You should have received a copy of the GNU General Public License        #
37#    along with this program. If not, see <http://www.gnu.org/licenses/>.     #
38#                                                                             #
39###############################################################################
40
41__author__ = "Michael Imelfort"
42__copyright__ = "Copyright 2012/2013"
43__credits__ = ["Michael Imelfort"]
44__license__ = "GPL3"
45__version__ = "0.2.1"
46__maintainer__ = "Michael Imelfort"
47__email__ = "mike@mikeimelfort.com"
48__status__ = "Released"
49
50###############################################################################
51
52#------------------------------------------------------------------------------
53# BIN MANAGER
54class GMBinException(BaseException): pass
55class BinNotFoundException(GMBinException): pass
56class ModeNotAppropriateException(GMBinException): pass
57
58#------------------------------------------------------------------------------
59# SOM MANAGER
60class GMSOMException(BaseException): pass
61class SOMDataNotFoundException(GMSOMException): pass
62class SOMFlavourException(GMSOMException): pass
63class SOMTypeException(GMSOMException): pass
64class RegionsDontExistException(GMSOMException): pass
65
66#------------------------------------------------------------------------------
67# ARG PARSER
68class GMARGException(BaseException): pass
69class ExtractModeNotAppropriateException(GMARGException): pass
70
71###############################################################################
72###############################################################################
73###############################################################################
74###############################################################################
75
76import traceback
77class Tracer:
78    def __init__(self, oldstream):
79        self.oldstream = oldstream
80        self.count = 0
81        self.lastStack = None
82
83    def write(self, s):
84        newStack = traceback.format_stack()
85        if newStack != self.lastStack:
86            self.oldstream.write("".join(newStack))
87            self.lastStack = newStack
88        self.oldstream.write(s)
89
90    def flush(self):
91        self.oldstream.flush()
92
93###############################################################################
94###############################################################################
95###############################################################################
96###############################################################################
97