diff options
author | 2016-02-11 13:04:59 +0200 | |
---|---|---|
committer | 2016-02-11 13:04:59 +0200 | |
commit | 1a780eaa3669a296b683201ef6431a7490fdc7d6 (patch) | |
tree | e62c1476468e5d184c87a4e369e532036f582d8f /scripts/automation/trex_control_plane/stl/trex_stl_lib/utils | |
parent | 1aec60fb7a6bb5dc4143e91e28844dd4fef6ece6 (diff) | |
parent | a66529ec065cf0745618c0f065d491b9fcca4e53 (diff) |
Fix tests
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/utils')
-rw-r--r-- | scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/common.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/common.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/common.py index 117017c3..9490c1b0 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/common.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/common.py @@ -45,3 +45,12 @@ def random_id_gen(length=8): for i in range(length): return_id += random.choice(id_chars) yield return_id + +# try to get number from input, return None in case of fail +def get_number(input): + try: + if type(input) in (int, long): + return input + return int(input) + except: + return None |