From 9adfbada8a429dcdd7bf95d9b52d28bb3448e1d4 Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Thu, 11 Feb 2016 12:53:07 +0200 Subject: validate_type for easier type checks, hltapi move to trex_stl_lib --- .../trex_control_plane/stl/trex_stl_lib/utils/common.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/utils') 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 -- cgit 1.2.3-korg