How to use get_timeout method in lisa

Best Python code snippet using lisa_python

decorators.py

Source:decorators.py Github

copy

Full Screen

...133 Returns:134 The actual decorator.135 """136 def decorator(f):137 def get_timeout(inst, *_args, **kwargs):138 ret = getattr(inst, default_timeout_name)139 if min_default_timeout is not None:140 ret = max(min_default_timeout, ret)141 return kwargs.get('timeout', ret)142 def get_retries(inst, *_args, **kwargs):143 return kwargs.get('retries', getattr(inst, default_retries_name))144 return _TimeoutRetryWrapper(f, get_timeout, get_retries, pass_values=True)...

Full Screen

Full Screen

snmp.py

Source:snmp.py Github

copy

Full Screen

1from pysnmp.hlapi import *2import logging34logger = logging.getLogger(__name__)56class SnmpBase:7 def __init__(self):8 """ default settings """9 self.get_timeout = 110 self.get_retries = 511 self.set_timeout = 312 self.set_retries = 01314 def update_setting(self, get_timeout=None, get_retries=None, set_timeout=None, set_retries=None):15 if get_timeout != None:16 self.get_timeout = get_timeout17 if get_retries != None:18 self.get_retries = get_retries19 if set_timeout != None:20 self.set_timeout = set_timeout21 if set_retries != None:22 self.set_retries = set_retries2324class SnmpV1V2(SnmpBase):25 def __init__(self, get_timeout=None, get_retries=None, set_timeout=None, set_retries=None):26 super(SnmpV1V2, self).__init__() # 呼叫父類別__init__()27 self.update_setting(get_timeout, get_retries, set_timeout, set_retries)2829 def get_request(self, ip, port, get_comm, oid, timeout=None, retries=None):30 self.update_setting(get_timeout=timeout, get_retries=retries)3132 g = getCmd(SnmpEngine(),33 CommunityData(get_comm),34 UdpTransportTarget((ip, port), timeout=self.get_timeout, retries=self.get_retries),35 ContextData(),36 ObjectType(ObjectIdentity(oid)))37 return g3839 def set_request(self, ip, port, set_comm, oid, value, timeout=None, retries=None):40 self.update_setting(set_timeout=timeout, set_retries=retries)4142 set_value = Integer(value) if isinstance(value, int) else OctetString(value)43 g = setCmd(SnmpEngine(),44 CommunityData(set_comm),45 UdpTransportTarget((ip, port), timeout=self.set_timeout, retries=self.set_retries),46 ContextData(),47 ObjectType(ObjectIdentity(oid), set_value))48 return g4950class SnmpV3(SnmpBase):51 def __init__(self, get_timeout=None, get_retries=None, set_timeout=None, set_retries=None):52 super(SnmpV3, self).__init__() # 呼叫父類別__init__()53 self.update_setting(get_timeout, get_retries, set_timeout, set_retries)5455 def get_request(self, ip, port, oid, username, auth_key=None, priv_key=None, auth_protocol=None, priv_protocol=None, context_name='', timeout=None, retries=None):56 self.update_setting(get_timeout=timeout, get_retries=retries)5758 g = getCmd(SnmpEngine(),59 UsmUserData(username, auth_key, priv_key, auth_protocol, priv_protocol),60 UdpTransportTarget((ip, port), timeout=self.get_timeout, retries=self.get_retries),61 ContextData(contextName=context_name),62 ObjectType(ObjectIdentity(oid)))63 return g6465 def set_request(self, ip, port, oid, value, username, auth_key=None, priv_key=None, auth_protocol=None, priv_protocol=None, context_name='', timeout=None, retries=None):66 self.update_setting(set_timeout=timeout, set_retries=retries)6768 set_value = Integer(value) if isinstance(value, int) else OctetString(value)6970 g = setCmd(SnmpEngine(),71 UsmUserData(username, auth_key, priv_key, auth_protocol, priv_protocol),72 UdpTransportTarget((ip, port), timeout=self.set_timeout, retries=self.set_retries),73 ContextData(contextName=context_name),74 ObjectType(ObjectIdentity(oid), set_value))75 return g7677class SnmpError(Exception):78 pass7980def get_auth_protocol_by_str(value):81 '''82 usmHMACMD5AuthProtocol83 usmHMACSHAAuthProtocol84 usmHMAC128SHA224AuthProtocol85 usmHMAC192SHA256AuthProtocol86 usmHMAC256SHA384AuthProtocol87 usmHMAC384SHA512AuthProtocol88 usmNoAuthProtocol89 '''90 result = None91 if value == 'MD5':92 result = usmHMACMD5AuthProtocol93 elif value == 'SHA1':94 result = usmHMACSHAAuthProtocol9596 return result9798def get_priv_protocol_by_str(value):99 '''100 usmDESPrivProtocol101 usm3DESEDEPrivProtocol102 usmAesCfb128Protocol103 usmAesCfb192Protocol104 usmAesCfb256Protocol105 usmNoPrivProtocol106 '''107 result = None108 if value == 'DES':109 result = usmDESPrivProtocol110 elif value == 'AES128':111 result = usmAesCfb128Protocol112 return result113114115def create_obj_type_by_oid_list(oid_list): ...

Full Screen

Full Screen

test_get_timeout.py

Source:test_get_timeout.py Github

copy

Full Screen

...3import pytest4from linotp.lib.type_utils import get_timeout5class GetTimeoutTest(unittest.TestCase):6 def test_get_timout_str(self):7 assert get_timeout("5") == 5.08 assert get_timeout("5 , ") == 5.09 assert get_timeout("5, 3") == (5.0, 3.0)10 assert get_timeout("5, 3 , ") == (5.0, 3.0)11 def test_get_timout_types(self):12 assert get_timeout((5, 2)) == (5, 2)13 assert get_timeout(5.0) == 5.014 assert get_timeout(5) == 515 def test_get_timeout_fail_type(self):16 with pytest.raises(ValueError) as exx:17 get_timeout(datetime.now())18 exx.match("Unsupported timeout input type")19 def test_get_timeout_fail_string(self):20 with pytest.raises(ValueError) as exx:21 get_timeout("5 , , ,")22 exx.match("Failed to convert timeout")23 with pytest.raises(ValueError) as exx:24 get_timeout("5 , 3.0, ,")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful