Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Leger2013-01-16 03:34:18 -0500
committerAnton Leherbauer2013-01-16 03:34:18 -0500
commit7997d52dc1d0e5a24de734a80016c65329cc9149 (patch)
treefe155ca75d2b22b3789737c82e696f45d61807fd /python/src/tcf/errors.py
parent61435e0455753f81c20f42b9eef51f925da293ba (diff)
downloadorg.eclipse.tcf-7997d52dc1d0e5a24de734a80016c65329cc9149.tar.gz
org.eclipse.tcf-7997d52dc1d0e5a24de734a80016c65329cc9149.tar.xz
org.eclipse.tcf-7997d52dc1d0e5a24de734a80016c65329cc9149.zip
TCF Python: Bug 397827 - Use relative imports inside tcf package modules
Diffstat (limited to 'python/src/tcf/errors.py')
-rw-r--r--python/src/tcf/errors.py139
1 files changed, 75 insertions, 64 deletions
diff --git a/python/src/tcf/errors.py b/python/src/tcf/errors.py
index 947590167..9085e29b6 100644
--- a/python/src/tcf/errors.py
+++ b/python/src/tcf/errors.py
@@ -1,5 +1,5 @@
-# *******************************************************************************
-# * Copyright (c) 2011 Wind River Systems, Inc. and others.
+# *****************************************************************************
+# * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
# * All rights reserved. This program and the accompanying materials
# * are made available under the terms of the Eclipse Public License v1.0
# * which accompanies this distribution, and is available at
@@ -7,19 +7,21 @@
# *
# * Contributors:
# * Wind River Systems - initial API and implementation
-# *******************************************************************************
+# *****************************************************************************
-import cStringIO, time, types
+import cStringIO
+import time
+import types
# Error report attribute names
-ERROR_CODE = "Code" # integer
-ERROR_TIME = "Time" # integer
-ERROR_SERVICE = "Service" # string
-ERROR_FORMAT = "Format" # string
-ERROR_PARAMS = "Params" # array
-ERROR_SEVERITY = "Severity" # integer
-ERROR_ALT_CODE = "AltCode" # integer
-ERROR_ALT_ORG = "AltOrg" # string
+ERROR_CODE = "Code" # integer
+ERROR_TIME = "Time" # integer
+ERROR_SERVICE = "Service" # string
+ERROR_FORMAT = "Format" # string
+ERROR_PARAMS = "Params" # array
+ERROR_SEVERITY = "Severity" # integer
+ERROR_ALT_CODE = "AltCode" # integer
+ERROR_ALT_ORG = "AltOrg" # string
ERROR_CAUSED_BY = "CausedBy" # object
# Error severity codes
@@ -41,37 +43,38 @@ CODE_RESERVED_MIN = 0x20000
CODE_RESERVED_MAX = 0x2ffff
# Standard TCF error codes
-TCF_ERROR_OTHER = 1
-TCF_ERROR_JSON_SYNTAX = 2
-TCF_ERROR_PROTOCOL = 3
-TCF_ERROR_BUFFER_OVERFLOW = 4
-TCF_ERROR_CHANNEL_CLOSED = 5
-TCF_ERROR_COMMAND_CANCELLED = 6
-TCF_ERROR_UNKNOWN_PEER = 7
-TCF_ERROR_BASE64 = 8
-TCF_ERROR_EOF = 9
-TCF_ERROR_ALREADY_STOPPED = 10
-TCF_ERROR_ALREADY_EXITED = 11
-TCF_ERROR_ALREADY_RUNNING = 12
-TCF_ERROR_ALREADY_ATTACHED = 13
-TCF_ERROR_IS_RUNNING = 14
-TCF_ERROR_INV_DATA_SIZE = 15
-TCF_ERROR_INV_CONTEXT = 16
-TCF_ERROR_INV_ADDRESS = 17
-TCF_ERROR_INV_EXPRESSION = 18
-TCF_ERROR_INV_FORMAT = 19
-TCF_ERROR_INV_NUMBER = 20
-TCF_ERROR_INV_DWARF = 21
-TCF_ERROR_SYM_NOT_FOUND = 22
-TCF_ERROR_UNSUPPORTED = 23
-TCF_ERROR_INV_DATA_TYPE = 24
-TCF_ERROR_INV_COMMAND = 25
-TCF_ERROR_INV_TRANSPORT = 26
-TCF_ERROR_CACHE_MISS = 27
-TCF_ERROR_NOT_ACTIVE = 28
+TCF_ERROR_OTHER = 1
+TCF_ERROR_JSON_SYNTAX = 2
+TCF_ERROR_PROTOCOL = 3
+TCF_ERROR_BUFFER_OVERFLOW = 4
+TCF_ERROR_CHANNEL_CLOSED = 5
+TCF_ERROR_COMMAND_CANCELLED = 6
+TCF_ERROR_UNKNOWN_PEER = 7
+TCF_ERROR_BASE64 = 8
+TCF_ERROR_EOF = 9
+TCF_ERROR_ALREADY_STOPPED = 10
+TCF_ERROR_ALREADY_EXITED = 11
+TCF_ERROR_ALREADY_RUNNING = 12
+TCF_ERROR_ALREADY_ATTACHED = 13
+TCF_ERROR_IS_RUNNING = 14
+TCF_ERROR_INV_DATA_SIZE = 15
+TCF_ERROR_INV_CONTEXT = 16
+TCF_ERROR_INV_ADDRESS = 17
+TCF_ERROR_INV_EXPRESSION = 18
+TCF_ERROR_INV_FORMAT = 19
+TCF_ERROR_INV_NUMBER = 20
+TCF_ERROR_INV_DWARF = 21
+TCF_ERROR_SYM_NOT_FOUND = 22
+TCF_ERROR_UNSUPPORTED = 23
+TCF_ERROR_INV_DATA_TYPE = 24
+TCF_ERROR_INV_COMMAND = 25
+TCF_ERROR_INV_TRANSPORT = 26
+TCF_ERROR_CACHE_MISS = 27
+TCF_ERROR_NOT_ACTIVE = 28
_timestamp_format = "%Y-%m-%d %H:%M:%S"
+
class ErrorReport(Exception):
def __init__(self, msg, attrs):
super(ErrorReport, self).__init__(msg)
@@ -85,12 +88,12 @@ class ErrorReport(Exception):
self.attrs = attrs
caused_by = attrs.get(ERROR_CAUSED_BY)
if caused_by:
- map = caused_by
+ errMap = caused_by
bf = cStringIO.StringIO()
bf.write("TCF error report:")
bf.write('\n')
- appendErrorProps(bf, map)
- self.caused_by = ErrorReport(bf.getvalue(), map)
+ appendErrorProps(bf, errMap)
+ self.caused_by = ErrorReport(bf.getvalue(), errMap)
def getErrorCode(self):
return self.attrs.get(ERROR_CODE) or 0
@@ -106,44 +109,52 @@ class ErrorReport(Exception):
def toErrorString(data):
- if not data: return None
- map = data
- fmt = map.get(ERROR_FORMAT)
+ if not data:
+ return None
+ errMap = data
+ fmt = errMap.get(ERROR_FORMAT)
if fmt:
- c = map.get(ERROR_PARAMS)
- if c: return fmt.format(c)
+ c = errMap.get(ERROR_PARAMS)
+ if c:
+ return fmt.format(c)
return fmt
- code = map.get(ERROR_CODE)
+ code = errMap.get(ERROR_CODE)
if code is not None:
if code == TCF_ERROR_OTHER:
- alt_org = map.get(ERROR_ALT_ORG)
- alt_code = map.get(ERROR_ALT_CODE)
+ alt_org = errMap.get(ERROR_ALT_ORG)
+ alt_code = errMap.get(ERROR_ALT_CODE)
if alt_org and alt_code:
return "%s Error %d" % (alt_org, alt_code)
return "TCF Error %d" % code
return "Invalid error report format"
-def appendErrorProps(bf, map):
- timeVal = map.get(ERROR_TIME)
- code = map.get(ERROR_CODE)
- service = map.get(ERROR_SERVICE)
- severity = map.get(ERROR_SEVERITY)
- alt_code = map.get(ERROR_ALT_CODE)
- alt_org = map.get(ERROR_ALT_ORG)
+
+def appendErrorProps(bf, errMap):
+ timeVal = errMap.get(ERROR_TIME)
+ code = errMap.get(ERROR_CODE)
+ service = errMap.get(ERROR_SERVICE)
+ severity = errMap.get(ERROR_SEVERITY)
+ alt_code = errMap.get(ERROR_ALT_CODE)
+ alt_org = errMap.get(ERROR_ALT_ORG)
if timeVal:
bf.write('\n')
bf.write("Time: ")
- bf.write(time.strftime(_timestamp_format, time.localtime(timeVal/1000.)))
+ bf.write(time.strftime(_timestamp_format,
+ time.localtime(timeVal / 1000.)))
if severity:
bf.write('\n')
bf.write("Severity: ")
- if severity == SEVERITY_ERROR: bf.write("Error")
- elif severity == SEVERITY_FATAL: bf.write("Fatal")
- elif severity == SEVERITY_WARNING: bf.write("Warning")
- else: bf.write("Unknown")
+ if severity == SEVERITY_ERROR:
+ bf.write("Error")
+ elif severity == SEVERITY_FATAL:
+ bf.write("Fatal")
+ elif severity == SEVERITY_WARNING:
+ bf.write("Warning")
+ else:
+ bf.write("Unknown")
bf.write('\n')
bf.write("Error text: ")
- bf.write(toErrorString(map))
+ bf.write(toErrorString(errMap))
bf.write('\n')
bf.write("Error code: ")
bf.write(str(code))

Back to the top