Revision 1fca349b ncclient/operations/rpc.py

b/ncclient/operations/rpc.py
24 24
from . import logger
25 25
from reply import RPCReply
26 26

  
27

  
27 28
# Cisco does not include message-id attribute in <rpc-reply> in case of an error.
28 29
# This is messed up however we have to deal with it.
29 30
# So essentially, there can be only one operation at a time if we are talking to
30 31
# a Cisco device.
31 32

  
33
def cisco_check(session):
34
    try:
35
        return session.is_remote_cisco
36
    except AttributeError:
37
        return False
38

  
32 39
class RPC(object):
33 40
    
34 41
    def __init__(self, session, async=False):
35
        if session.is_remote_cisco and async:
42
        if cisco_check(session) and async:
36 43
            raise UserWarning('Asynchronous mode not supported for Cisco devices')
37 44
        self._session = session
38 45
        self._async = async
......
120 127
        if instance is None:
121 128
            instance = object.__new__(cls)
122 129
            instance._id2rpc = WeakValueDictionary()
123
            instance._cisco = session.is_remote_cisco
130
            instance._cisco = cisco_check(session)
124 131
            instance._errback = None
125 132
            session.add_listener(instance)
126 133
        return instance

Also available in: Unified diff