diff options
author | elie <elie> | 2015-10-10 19:21:11 +0000 |
---|---|---|
committer | elie <elie> | 2015-10-10 19:21:11 +0000 |
commit | e3e7f0d94ec05b0e6020ecdf6830cfbf56c75c8e (patch) | |
tree | 8364173e36c25370b6f7622408a614920b9b3aaf /pysnmp/entity/rfc3413 | |
parent | 886428097d6ef38036f64b6d96ed8f6f7b56513b (diff) | |
download | pysnmp-git-e3e7f0d94ec05b0e6020ecdf6830cfbf56c75c8e.tar.gz |
fixed crash at oneliner compatibility code on EOM response
Diffstat (limited to 'pysnmp/entity/rfc3413')
-rw-r--r-- | pysnmp/entity/rfc3413/oneliner/cmdgen.py | 38 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/oneliner/ntforg.py | 24 |
2 files changed, 40 insertions, 22 deletions
diff --git a/pysnmp/entity/rfc3413/oneliner/cmdgen.py b/pysnmp/entity/rfc3413/oneliner/cmdgen.py index 2736d28f..9254cf53 100644 --- a/pysnmp/entity/rfc3413/oneliner/cmdgen.py +++ b/pysnmp/entity/rfc3413/oneliner/cmdgen.py @@ -179,24 +179,35 @@ class CommandGenerator: kwargs['lookupNames'] = False if 'lookupValues' not in kwargs: kwargs['lookupValues'] = False - for x in sync.getCmd(self.snmpEngine, authData, transportTarget, - ContextData(kwargs.get('contextEngineId'), - kwargs.get('contextName', null)), - *[ (x, self._null) for x in varNames ], - **kwargs): - return x + errorIndication, errorStatus, errorIndex, varBinds = None, 0, 0, [] + for errorIndication, \ + errorStatus, errorIndex, \ + varBinds \ + in sync.getCmd(self.snmpEngine, authData, transportTarget, + ContextData(kwargs.get('contextEngineId'), + kwargs.get('contextName', null)), + *[ (x, self._null) for x in varNames ], + **kwargs): + break + return errorIndication, errorStatus, errorIndex, varBinds def setCmd(self, authData, transportTarget, *varBinds, **kwargs): if 'lookupNames' not in kwargs: kwargs['lookupNames'] = False if 'lookupValues' not in kwargs: kwargs['lookupValues'] = False - for x in sync.setCmd(self.snmpEngine, authData, transportTarget, - ContextData(kwargs.get('contextEngineId'), - kwargs.get('contextName', null)), - *varBinds, - **kwargs): - return x + errorIndication, errorStatus, errorIndex, rspVarBinds = None, 0, 0, [] + for errorIndication, \ + errorStatus, errorIndex, \ + rspVarBinds \ + in sync.setCmd(self.snmpEngine, authData, transportTarget, + ContextData(kwargs.get('contextEngineId'), + kwargs.get('contextName', null)), + *varBinds, + **kwargs): + break + + return errorIndication, errorStatus, errorIndex, rspVarBinds def nextCmd(self, authData, transportTarget, *varNames, **kwargs): if 'lookupNames' not in kwargs: @@ -205,6 +216,7 @@ class CommandGenerator: kwargs['lookupValues'] = False if 'lexicographicMode' not in kwargs: kwargs['lexicographicMode'] = False + errorIndication, errorStatus, errorIndex = None, 0, 0 varBindTable = [] for errorIndication, \ errorStatus, errorIndex, \ @@ -229,6 +241,7 @@ class CommandGenerator: kwargs['lookupValues'] = False if 'lexicographicMode' not in kwargs: kwargs['lexicographicMode'] = False + errorIndication, errorStatus, errorIndex = None, 0, 0 varBindTable = [] for errorIndication, \ errorStatus, errorIndex, \ @@ -246,4 +259,3 @@ class CommandGenerator: varBindTable.append(varBinds) return errorIndication, errorStatus, errorIndex, varBindTable - diff --git a/pysnmp/entity/rfc3413/oneliner/ntforg.py b/pysnmp/entity/rfc3413/oneliner/ntforg.py index 1d733dac..d2462bd2 100644 --- a/pysnmp/entity/rfc3413/oneliner/ntforg.py +++ b/pysnmp/entity/rfc3413/oneliner/ntforg.py @@ -142,14 +142,20 @@ class NotificationOriginator: if not isinstance(notificationType, NotificationType): notificationType = NotificationType(notificationType) - for x in sync.sendNotification(self.snmpEngine, authData, - transportTarget, - ContextData(kwargs.get('contextEngineId'), - kwargs.get('contextName', null)), - notifyType, - notificationType.addVarBinds(*varBinds), - **kwargs): + errorIndication, errorStatus, errorIndex, rspVarBinds = None, 0, 0, [] + for errorIndication, \ + errorStatus, errorIndex, \ + rspVarBinds \ + in sync.sendNotification(self.snmpEngine, authData, + transportTarget, + ContextData( + kwargs.get('contextEngineId'), + kwargs.get('contextName', null) + ), + notifyType, + notificationType.addVarBinds(*varBinds), + **kwargs): if notifyType == 'inform': - return x + return errorIndication, errorStatus, errorIndex, rspVarBinds else: - return + break |