Fix Python 2.4-2.5 except statement
Older Pythons do not support 'except ... as...' syntax.release-4.4.5 v4.4.5
parent
43a181b692
commit
8a3727a9fc
|
@ -31,6 +31,8 @@
|
|||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
# THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
import sys
|
||||
|
||||
from pysnmp.smi.rfc1902 import *
|
||||
from pysnmp.hlapi.auth import *
|
||||
from pysnmp.hlapi.context import *
|
||||
|
@ -41,6 +43,7 @@ from pysnmp.entity.rfc3413 import cmdgen
|
|||
|
||||
try:
|
||||
import asyncio
|
||||
|
||||
except ImportError:
|
||||
import trollius as asyncio
|
||||
|
||||
|
@ -137,8 +140,9 @@ def getCmd(snmpEngine, authData, transportTarget, contextData,
|
|||
try:
|
||||
varBindsUnmade = vbProcessor.unmakeVarBinds(snmpEngine, varBinds,
|
||||
lookupMib)
|
||||
except Exception as e:
|
||||
future.set_exception(e)
|
||||
except Exception:
|
||||
ex = sys.exc_info()[1]
|
||||
future.set_exception(ex)
|
||||
else:
|
||||
future.set_result(
|
||||
(errorIndication, errorStatus, errorIndex, varBindsUnmade)
|
||||
|
@ -242,8 +246,9 @@ def setCmd(snmpEngine, authData, transportTarget, contextData,
|
|||
try:
|
||||
varBindsUnmade = vbProcessor.unmakeVarBinds(snmpEngine, varBinds,
|
||||
lookupMib)
|
||||
except Exception as e:
|
||||
future.set_exception(e)
|
||||
except Exception:
|
||||
ex = sys.exc_info()[1]
|
||||
future.set_exception(ex)
|
||||
else:
|
||||
future.set_result(
|
||||
(errorIndication, errorStatus, errorIndex, varBindsUnmade)
|
||||
|
@ -353,8 +358,9 @@ def nextCmd(snmpEngine, authData, transportTarget, contextData,
|
|||
varBindTableRow,
|
||||
lookupMib)
|
||||
for varBindTableRow in varBindTable]
|
||||
except Exception as e:
|
||||
future.set_exception(e)
|
||||
except Exception:
|
||||
ex = sys.exc_info()[1]
|
||||
future.set_exception(ex)
|
||||
else:
|
||||
future.set_result(
|
||||
(errorIndication, errorStatus, errorIndex, varBindsUnmade)
|
||||
|
@ -493,8 +499,9 @@ def bulkCmd(snmpEngine, authData, transportTarget, contextData,
|
|||
varBindTableRow,
|
||||
lookupMib)
|
||||
for varBindTableRow in varBindTable]
|
||||
except Exception as e:
|
||||
future.set_exception(e)
|
||||
except Exception:
|
||||
ex = sys.exc_info()[1]
|
||||
future.set_exception(ex)
|
||||
else:
|
||||
future.set_result(
|
||||
(errorIndication, errorStatus, errorIndex, varBindsUnmade)
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
# Authors: Matt Hooks <me@matthooks.com>
|
||||
# Zachary Lorusso <zlorusso@gmail.com>
|
||||
#
|
||||
import sys
|
||||
|
||||
from pysnmp.smi.rfc1902 import *
|
||||
from pysnmp.hlapi.auth import *
|
||||
from pysnmp.hlapi.context import *
|
||||
|
@ -18,6 +20,7 @@ from pysnmp.entity.rfc3413 import ntforg
|
|||
|
||||
try:
|
||||
import asyncio
|
||||
|
||||
except ImportError:
|
||||
import trollius as asyncio
|
||||
|
||||
|
@ -127,8 +130,9 @@ def sendNotification(snmpEngine, authData, transportTarget, contextData,
|
|||
try:
|
||||
varBindsUnmade = vbProcessor.unmakeVarBinds(snmpEngine, varBinds,
|
||||
lookupMib)
|
||||
except Exception as e:
|
||||
future.set_exception(e)
|
||||
except Exception:
|
||||
ex = sys.exc_info()[1]
|
||||
future.set_exception(ex)
|
||||
else:
|
||||
future.set_result(
|
||||
(errorIndication, errorStatus, errorIndex, varBindsUnmade)
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
# Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com>
|
||||
# License: http://snmplabs.com/pysnmp/license.html
|
||||
#
|
||||
import sys
|
||||
|
||||
from pysnmp.smi.rfc1902 import *
|
||||
from pysnmp.hlapi.auth import *
|
||||
from pysnmp.hlapi.context import *
|
||||
|
@ -120,8 +122,9 @@ def getCmd(snmpEngine, authData, transportTarget, contextData,
|
|||
try:
|
||||
varBindsUnmade = vbProcessor.unmakeVarBinds(snmpEngine, varBinds, lookupMib)
|
||||
|
||||
except Exception as e:
|
||||
deferred.errback(Failure(e))
|
||||
except Exception:
|
||||
ex = sys.exc_info()[1]
|
||||
deferred.errback(Failure(ex))
|
||||
|
||||
else:
|
||||
deferred.callback((errorStatus, errorIndex, varBindsUnmade))
|
||||
|
@ -236,8 +239,9 @@ def setCmd(snmpEngine, authData, transportTarget, contextData,
|
|||
try:
|
||||
varBindsUnmade = vbProcessor.unmakeVarBinds(snmpEngine, varBinds, lookupMib)
|
||||
|
||||
except Exception as e:
|
||||
deferred.errback(Failure(e))
|
||||
except Exception:
|
||||
ex = sys.exc_info()[1]
|
||||
deferred.errback(Failure(ex))
|
||||
|
||||
else:
|
||||
deferred.callback((errorStatus, errorIndex, varBindsUnmade))
|
||||
|
@ -366,8 +370,9 @@ def nextCmd(snmpEngine, authData, transportTarget, contextData,
|
|||
lookupMib)
|
||||
for varBindTableRow in varBindTable]
|
||||
|
||||
except Exception as e:
|
||||
deferred.errback(Failure(e))
|
||||
except Exception:
|
||||
ex = sys.exc_info()[1]
|
||||
deferred.errback(Failure(ex))
|
||||
|
||||
else:
|
||||
deferred.callback((errorStatus, errorIndex, varBindsUnmade))
|
||||
|
@ -524,8 +529,9 @@ def bulkCmd(snmpEngine, authData, transportTarget, contextData,
|
|||
lookupMib)
|
||||
for varBindTableRow in varBindTable]
|
||||
|
||||
except Exception as e:
|
||||
deferred.errback(Failure(e))
|
||||
except Exception:
|
||||
ex = sys.exc_info()[1]
|
||||
deferred.errback(Failure(ex))
|
||||
|
||||
else:
|
||||
deferred.callback((errorStatus, errorIndex, varBindsUnmade))
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
# Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com>
|
||||
# License: http://snmplabs.com/pysnmp/license.html
|
||||
#
|
||||
import sys
|
||||
|
||||
from pysnmp.smi.rfc1902 import *
|
||||
from pysnmp.hlapi.auth import *
|
||||
from pysnmp.hlapi.context import *
|
||||
|
@ -128,8 +130,9 @@ def sendNotification(snmpEngine, authData, transportTarget, contextData,
|
|||
try:
|
||||
varBindsUnmade = vbProcessor.unmakeVarBinds(snmpEngine, varBinds, lookupMib)
|
||||
|
||||
except Exception as e:
|
||||
deferred.errback(Failure(e))
|
||||
except Exception:
|
||||
ex = sys.exc_info()[1]
|
||||
deferred.errback(Failure(ex))
|
||||
|
||||
else:
|
||||
deferred.callback((errorStatus, errorIndex, varBindsUnmade))
|
||||
|
|
Loading…
Reference in New Issue