Changed all BuiltIn().import_resource() calls to my_import_resource().
Change-Id: I68cac29a9e6d55c2588c94de1c387b32f63ac9b6
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/extended/run_keyword.py b/extended/run_keyword.py
index 38033c7..e9d2d57 100644
--- a/extended/run_keyword.py
+++ b/extended/run_keyword.py
@@ -6,6 +6,8 @@
import gen_robot_print as grp
import gen_robot_valid as grv
+import gen_robot_utils as gru
+
from robot.libraries.BuiltIn import BuiltIn
import re
@@ -54,8 +56,9 @@
grp.rdprint_issuing("import_library(\"" + lib_file_path + "\")")
BuiltIn().import_library(lib_file_path)
else:
- grp.rdprint_issuing("import_resource(\"" + lib_file_path + "\")")
- BuiltIn().import_resource(lib_file_path)
+ grp.rdprint_issuing("my_import_resource(\"" + lib_file_path +
+ "\")")
+ gru.my_import_resource(lib_file_path)
BuiltIn().set_global_variable("${quiet}", quiet)
# The user can pass multiple keyword strings by separating them with " ; ".
diff --git a/lib/boot/poweroffs.py b/lib/boot/poweroffs.py
index e776bfb..d72fd81 100755
--- a/lib/boot/poweroffs.py
+++ b/lib/boot/poweroffs.py
@@ -7,16 +7,12 @@
import gen_robot_print as grp
import state as state_mod
+import gen_robot_utils as gru
from robot.libraries.BuiltIn import BuiltIn
-# We don't want global variable getting changed when an import is done
-# so we'll save it and restore it.
-quiet = int(BuiltIn().get_variable_value("${quiet}"))
-
# We need utils.robot to get keyword "Initiate Power Off".
-BuiltIn().import_resource("utils.robot")
-BuiltIn().set_global_variable("${quiet}", quiet)
+gru.my_import_resource("utils.robot")
###############################################################################
diff --git a/lib/boot/powerons.py b/lib/boot/powerons.py
index e8b921b..94ee1b1 100755
--- a/lib/boot/powerons.py
+++ b/lib/boot/powerons.py
@@ -7,17 +7,12 @@
import gen_robot_print as grp
import state as state_mod
+import gen_robot_utils as gru
from robot.libraries.BuiltIn import BuiltIn
-# We don't want global variable getting changed when an import is done
-# so we'll save it and restore it.
-quiet = int(BuiltIn().get_variable_value("${quiet}"))
-
# We need utils.robot to get keyword "Initiate Power On".
-BuiltIn().import_resource("utils.robot")
-
-BuiltIn().set_global_variable("${quiet}", quiet)
+gru.my_import_resource("utils.robot")
###############################################################################
diff --git a/lib/state.py b/lib/state.py
index c59c359..612753e 100755
--- a/lib/state.py
+++ b/lib/state.py
@@ -30,6 +30,7 @@
import gen_print as gp
import gen_robot_print as grp
import gen_valid as gv
+import gen_robot_utils as gru
import commands
from robot.libraries.BuiltIn import BuiltIn
@@ -38,33 +39,19 @@
import re
import os
-# We don't want global variable getting changed when an import is done
-# so we'll save it and restore it.
-quiet = int(BuiltIn().get_variable_value("${quiet}"))
# We need utils.robot to get keywords like "Get Power State".
-BuiltIn().import_resource("utils.robot")
+gru.my_import_resource("utils.robot")
+gru.my_import_resource("state_manager.robot")
-###############################################################################
# The BMC code is about to be changed as far as what states are defined and
# what the state values can be. I am creating a means of processing both the
# old style state (i.e. OBMC_STATES_VERSION = 0) and the new style (i.e.
-# OBMC_STATES_VERSION >= 1.
+# OBMC_STATES_VERSION = 1).
# The caller can set environment variable OBMC_STATES_VERSION to dictate
# whether we're processing old or new style states. If OBMC_STATES_VERSION is
# not set it will default to 0.
-DEFAULT_OBMC_STATES_VERSION = 0
-try:
- BuiltIn().import_resource("state_manager.robot")
-except RuntimeError:
- pass
-try:
- OBMC_STATES_VERSION = int(os.environ.get('OBMC_STATES_VERSION',
- DEFAULT_OBMC_STATES_VERSION))
-except ValueError:
- OBMC_STATES_VERSION = DEFAULT_OBMC_STATES_VERSION
-BuiltIn().set_global_variable("${quiet}", quiet)
-quiet = int(BuiltIn().get_variable_value("${quiet}"))
+OBMC_STATES_VERSION = int(os.environ.get('OBMC_STATES_VERSION', 0))
if OBMC_STATES_VERSION == 0:
default_state = DotDict([('power', '1'),
@@ -328,7 +315,7 @@
os_password = ""
# Get the component states.
- if OBMC_STATES_VERSION== 0:
+ if OBMC_STATES_VERSION == 0:
cmd_buf = ["Get Power State", "quiet=${" + str(quiet) + "}"]
grp.rdpissuing_keyword(cmd_buf)
power = BuiltIn().run_keyword(*cmd_buf)
@@ -339,7 +326,7 @@
# Strip everything up to the final period.
chassis = re.sub(r'.*\.', "", chassis)
- if OBMC_STATES_VERSION== 0:
+ if OBMC_STATES_VERSION == 0:
qualifier = "utils"
else:
qualifier = "state_manager"