Package pysql :: Module pysqlexception
[hide private]
[frames] | no frames]

Source Code for Module pysql.pysqlexception

 1  #!/usr/bin/python 
 2  # -*- coding: utf-8 -*- 
 3   
 4  """This module defines all pysql exceptions 
 5  @author: Sébastien Renard (sebastien.renard@digitalfox.org) 
 6  @license: GNU GPL V3 
 7  """ 
 8   
 9  # Python imports 
10  from time import ctime, time 
11  from re import match 
12   
13 -class PysqlException(Exception):
14 """Pysql Exceptions"""
15 - def __init__(self, exception):
16 # instance members 17 self.oraCode="" 18 self.msg="" 19 self.time=None 20 21 # TimeStamp exception 22 self.time=time() 23 24 # Sets default message 25 self.msg=unicode(exception) 26 27 # Gets ORA error code if this is an Oracle exception 28 if isinstance(exception, PysqlException): 29 self.msg=exception.msg 30 self.oraCode=exception.oraCode 31 self.time=exception.time 32 else: 33 result=match("(.*)(ORA-\d+): (.*)", unicode(exception)) 34 if result: 35 self.oraCode=result.group(2) 36 self.msg=result.group(1)+result.group(3) 37 38 # Calls father constructor 39 Exception.__init__(self, exception)
40
41 - def getTimeStamp(self):
42 """@return: exception creation timestamp as a formated string""" 43 return ctime(self.time)
44
45 - def __str__(self):
46 if self.oraCode=="": 47 return self.msg 48 else: 49 return self.oraCode +"-" + self.msg
50
51 -class PysqlNotImplemented(PysqlException):
52 """Indicates function not yet implemented"""
53 - def __init__(self):
54 PysqlException.__init__(self, _("Not yet implemented"))
55
56 -class PysqlActionDenied(PysqlException):
57 """Indicates user is not granted to perform this action"""
58 - def __init__(self, message):
59 PysqlException.__init__(self, _("Action denied: %s") % message)
60
61 -class PysqlOptionParserNormalExitException(Exception):
62 """ 63 A dummy exception which makes it possible to have --help exit silently 64 """ 65 pass
66