Skip to content

Commit

Permalink
Merge pull request #929 from tue-robotics/knowledge_loader_raise
Browse files Browse the repository at this point in the history
Remove sys.exit from knowledge loader
  • Loading branch information
MatthijsBurgh committed Nov 14, 2019
2 parents 306ad7d + d7f16d2 commit 2ef4ce2
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions robocup_knowledge/src/robocup_knowledge/knowledge_loader.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import print_function

# Resolve the environment variable $ROBOT_ENV

def load_knowledge(knowledge_item, print_knowledge=False):
import os, sys, imp
import os, imp
_robot_env = os.environ.get('ROBOT_ENV')

if not _robot_env:
print "robocup_knowledge - load(): ROBOT_ENV environment variable is not set!"
sys.exit(1)
raise KeyError("robocup_knowledge - load(): ROBOT_ENV environment variable is not set!")

# Look for the correct knowledge file
try:
Expand All @@ -16,15 +17,14 @@ def load_knowledge(knowledge_item, print_knowledge=False):
knowledge_attrs = [attr for attr in dir(knowledge) if not callable(attr) and not attr.startswith("__")]

if print_knowledge:
print "====================================="
print "== KNOWLEDGE =="
print "====================================="
print("=====================================")
print("== KNOWLEDGE ==")
print("=====================================")
for attr in knowledge_attrs:
print "==> %s = %s" % (attr, str(getattr(knowledge, attr)))
print "====================================="
print("==> %s = %s" % (attr, str(getattr(knowledge, attr))))
print("=====================================")

return knowledge

except Exception as e:
print "Knowledge item '%s' for environment '%s' is incorrect at path '%s'! [Error = %s]"%(knowledge_item, _robot_env, _knowledge_path, e)
sys.exit(1)
raise RuntimeError("Knowledge item '%s' for environment '%s' is incorrect at path '%s'! [Error = %s]"%(knowledge_item, _robot_env, _knowledge_path, e))

0 comments on commit 2ef4ce2

Please sign in to comment.