Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | r""" |
| 4 | This module is the python counterpart to code_update.robot. |
| 5 | """ |
| 6 | |
| 7 | import os |
| 8 | import sys |
| 9 | import re |
| 10 | import string |
| 11 | import tarfile |
| 12 | import time |
| 13 | |
| 14 | robot_pgm_dir_path = os.path.dirname(__file__) + os.sep |
| 15 | repo_lib_path = re.sub('/extended/code_update/', '/lib', robot_pgm_dir_path) |
| 16 | repo_data_path = re.sub('/extended/code_update/', '/data', robot_pgm_dir_path) |
| 17 | sys.path.append(repo_lib_path) |
| 18 | sys.path.append(repo_data_path) |
| 19 | |
| 20 | import gen_robot_keyword as keyword |
| 21 | import gen_print as gp |
| 22 | import gen_valid as gv |
| 23 | import variables as var |
| 24 | from robot.libraries.BuiltIn import BuiltIn |
| 25 | |
| 26 | |
| 27 | ############################################################################### |
| 28 | def wait_for_activation_state_change(version_id, initial_state): |
| 29 | |
| 30 | r""" |
| 31 | Wait for the current activation state of ${version_id} to |
| 32 | change from the state provided by the calling function. |
| 33 | |
| 34 | Description of argument(s): |
| 35 | version_id The version ID whose state change we are waiting for. |
| 36 | initial_state The activation state we want to wait for. |
| 37 | """ |
| 38 | |
| 39 | keyword.run_key_u("Open Connection And Log In") |
| 40 | retry = 0 |
| 41 | while (retry < 20): |
| 42 | status, software_state = keyword.run_key("Read Properties " + |
| 43 | var.SOFTWARE_VERSION + str(version_id)) |
| 44 | current_state = (software_state)["Activation"] |
| 45 | if (initial_state == current_state): |
| 46 | time.sleep(60) |
| 47 | retry += 1 |
| 48 | else: |
| 49 | return |
| 50 | return |
| 51 | |
| 52 | ############################################################################### |