Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

modified caught exceptions to present a track trace...

  • Loading branch information...
commit 2130fcf407f9bcdf425b57844951aaefd3bd6c0c 1 parent 6c0d516
nemonik authored
View
1  .settings/org.eclipse.core.resources.prefs
@@ -1,5 +1,4 @@
eclipse.preferences.version=1
-encoding//dist/Intellect-1.4.1/intellect/Intellect.py=utf-8
encoding//intellect/Callable.py=utf-8
encoding//intellect/IO.py=utf-8
encoding//intellect/Intellect.py=utf-8
View
29 intellect/Node.py
@@ -49,6 +49,7 @@
import collections
import keyword
import uuid
+import sys
import intellect.reflection as reflection
@@ -619,7 +620,8 @@ def eval(self, agenda):
self.log("Evaluating: {0}".format(importStmt))
exec(str(importStmt), self.globals)
except ImportError as error:
- raise ImportError, error.message + " at line: {0} from policy file: '{1}'".format(importStmt.line, importStmt.file.path)
+ exception_type, exception_value, exception_traceback = sys.exc_info()
+ raise ImportError, (error.message + " at line: {0} from policy file: '{1}'".format(importStmt.line, importStmt.file.path), exception_type, exception_value), exception_traceback
# put the policy attributes into the policy's global namespace
for attributeStmt in self.attributeStmts:
@@ -988,7 +990,8 @@ def eval(self, policy, ruleStmt):
matches = localScope["matches"]
except Exception as error:
- raise SyntaxError("{0} in rule: '{1}', near line: {2} in policy file: '{3}'".format(error, ruleStmt.id, self.line, self.file.path))
+ exception_type, exception_value, exception_traceback = sys.exc_info()
+ raise SyntaxError, ("{0} in rule: '{1}', near line: {2} in policy file: '{3}'".format(error, ruleStmt.id, self.line, self.file.path), exception_type, exception_value), exception_traceback
self.log("The matches found in memory: {0}".format(matches))
else:
@@ -1166,7 +1169,8 @@ def eval(self, policy, ruleStmt, matches, objectBinding):
# Execute the code
exec(str(code), policy.globals, localScope)
except Exception as error:
- raise SyntaxError("{0} in rule: '{1}' at line: {2} in the policy file: '{3}'".format(error, ruleStmt.id, actualAction.line, self.file.path))
+ exception_type, exception_value, exception_traceback = sys.exc_info()
+ raise SyntaxError, ("{0} in rule: '{1}' at line: {2} in the policy file: '{3}'".format(error, ruleStmt.id, actualAction.line, self.file.path), exception_type, exception_value), exception_traceback
policy.intellect.learn(localScope["new_fact"])
@@ -1186,9 +1190,8 @@ def eval(self, policy, ruleStmt, matches, objectBinding):
self.log("value" + " = " + str(Then.rewrite(propertyAssignment.constraint, Constraint(), objectBinding)))
exec("value" + " = " + str(Then.rewrite(propertyAssignment.constraint, Constraint(), objectBinding)), policy.globals, localScope)
except Exception as error:
- raise SyntaxError("{0} in rule: '{1}' near line: {2} in the policy file: '{3}'".format(error, ruleStmt.id, actualAction.line, self.file.path))
-
- #if localScope["value"]:
+ exception_type, exception_value, exception_traceback = sys.exc_info()
+ raise SyntaxError, ("{0} in rule: '{1}' near line: {2} in the policy file: '{3}'".format(error, ruleStmt.id, actualAction.line, self.file.path), exception_type, exception_value), exception_traceback
self.log("modifying {0} property {1} with value of {2} with assignment of {3}".format(objectBinding, propertyAssignment, localScope["value"], propertyAssignment.assignment))
@@ -1217,8 +1220,6 @@ def eval(self, policy, ruleStmt, matches, objectBinding):
else:
setattr(policy.intellect.knowledge[knowledgeIndex], propertyAssignment.name, getattr(policy.intellect.knowledge[knowledgeIndex], propertyAssignment.name) // localScope["value"])
- # if had ended here
-
break
elif isinstance(actualAction, HaltAction):
@@ -1273,7 +1274,8 @@ def eval(self, policy, ruleStmt, matches, objectBinding):
# Execute the code
exec(str(code), policy.globals, localScope)
except Exception as error:
- raise SyntaxError("{0} in rule: '{1}' at line: {2} in the policy file: '{3}'".format(error, ruleStmt.id, actualAction.line, self.file.path))
+ exception_value, exception_traceback = sys.exc_info()
+ raise SyntaxError, ("{0} in rule: '{1}' at line: {2} in the policy file: '{3}'".format(error, ruleStmt.id, actualAction.line, self.file.path), exception_type, exception_value), exception_traceback
policy.intellect.learn(localScope["new_fact"])
@@ -1313,7 +1315,6 @@ def eval(self, policy, ruleStmt, matches, objectBinding):
self.execute(policy, ruleStmt, localScope, code)
-
def execute(self, policy, ruleStmt, localScope, code):
'''
Executes the code
@@ -1325,11 +1326,9 @@ def execute(self, policy, ruleStmt, localScope, code):
# Execute the code, wrapped to collect stdout
with IO.RedirectStdOut() as stdout:
exec(str(code), policy.globals, localScope)
-
- print stdout.getvalue()
-
- except Exception as error:
- raise SyntaxError("{0} in rule: '{1}' near line: {2} in the policy file: '{3}'".format(error, ruleStmt.id, self.line, self.file.path))
+ except Exception, error:
+ exception_type, exception_value, exception_traceback = sys.exc_info()
+ raise RuntimeError, ("{0} in rule: '{1}' near line: {2} in the policy file: '{3}'".format(error, ruleStmt.id, self.line, self.file.path), exception_type, exception_value), exception_traceback
@staticmethod
View
2  intellect/__init__.py
@@ -30,4 +30,4 @@
__author__ = "Michael Joseph Walsh"
-VERSION = (1, 4, 8, 3)
+VERSION = (1, 4, 8, 4)
View
2  intellect/grammar/PolicyLexer.py
@@ -1,4 +1,4 @@
-# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 /Users/walsh/Development/workspace/Intellect/intellect/grammar/Policy.g 2012-04-19 12:49:36
+# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 /Users/walsh/Development/workspace/Intellect/intellect/grammar/Policy.g 2012-05-22 17:40:35
import sys
from antlr3 import *
View
2  intellect/grammar/PolicyParser.py
@@ -1,4 +1,4 @@
-# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 /Users/walsh/Development/workspace/Intellect/intellect/grammar/Policy.g 2012-04-19 12:49:36
+# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 /Users/walsh/Development/workspace/Intellect/intellect/grammar/Policy.g 2012-05-22 17:40:34
import sys
from antlr3 import *
Please sign in to comment.
Something went wrong with that request. Please try again.