Ejemplo n.º 1
0
 def __init__(self, arg1 = None, arg2 = None):
     if arg1 == None or Common.typeIsString(arg1):
         filePath = ""
         if arg1 == None and arg2 == None:
             # Check if we can connect using UnixSocket.
             tryFilePath = "/var/run/nfd.sock"
             # Use listdir because isfile doesn't see socket file types.
             if  (os.path.basename(tryFilePath) in 
                  os.listdir(os.path.dirname(tryFilePath))):
                 filePath = tryFilePath
             else:
                 tryFilePath = "/tmp/.ndnd.sock"
                 if  (os.path.basename(tryFilePath) in 
                      os.listdir(os.path.dirname(tryFilePath))):
                     filePath = tryFilePath
         
         if filePath == "":
             transport = TcpTransport()
             host = arg1 if arg1 != None else "localhost"
             connectionInfo = TcpTransport.ConnectionInfo(
               host, arg2 if type(arg2) is int else 6363)
         else:
             transport = UnixTransport()
             connectionInfo = UnixTransport.ConnectionInfo(filePath)
     else:
         transport = arg1
         connectionInfo = arg2
         
     self._node = Node(transport, connectionInfo)
     self._commandKeyChain = None
     self._commandCertificateName = Name()
Ejemplo n.º 2
0
 def __init__(self, value = None):
     if type(value) is Name:
         # Copy the components array, but don't need to copy each Component.
         self._components = value._components[:]
     elif Common.typeIsString(value):
         self._components = []
         # Set _changeCount now because self.set() expects it.
         self._changeCount = 0
         self.set(value)
     else:
         self._components = []
         
     self._changeCount = 0
Ejemplo n.º 3
0
 def __init__(self, value = None):
     if type(value) is Name:
         # Copy the components array, but don't need to copy each Component.
         self._components = value._components[:]
     elif Common.typeIsString(value):
         self._components = []
         # Set _changeCount now because self.set() expects it.
         self._changeCount = 0
         self.set(value)
     else:
         self._components = []
         
     self._changeCount = 0
Ejemplo n.º 4
0
    def __init__(self, loop, arg1=None, arg2=None):
        self._loop = loop

        # Imitate the Face constructor, but use AsyncTcpTransport, etc.
        if arg1 == None or Common.typeIsString(arg1):
            filePath = ""
            if arg1 == None and arg2 == None:
                # Check if we can connect using UnixSocket.
                filePath = self._getUnixSocketFilePathForLocalhost()

            if filePath == "":
                transport = AsyncTcpTransport(loop)
                host = arg1 if arg1 != None else "localhost"
                connectionInfo = AsyncTcpTransport.ConnectionInfo(
                    host, arg2 if type(arg2) is int else 6363)
            else:
                transport = AsyncUnixTransport(loop)
                connectionInfo = AsyncUnixTransport.ConnectionInfo(filePath)
        else:
            transport = arg1
            connectionInfo = arg2
        super(ThreadsafeFace, self).__init__(transport, connectionInfo)
Ejemplo n.º 5
0
    def __init__(self, arg1=None, arg2=None):
        if arg1 == None or Common.typeIsString(arg1):
            filePath = ""
            if arg1 == None and arg2 == None:
                # Check if we can connect using UnixSocket.
                filePath = self._getUnixSocketFilePathForLocalhost()

            if filePath == "":
                transport = TcpTransport()
                host = arg1 if arg1 != None else "localhost"
                connectionInfo = TcpTransport.ConnectionInfo(
                    host, arg2 if type(arg2) is int else 6363)
            else:
                transport = UnixTransport()
                connectionInfo = UnixTransport.ConnectionInfo(filePath)
        else:
            transport = arg1
            connectionInfo = arg2

        self._node = Node(transport, connectionInfo)
        self._commandKeyChain = None
        self._commandCertificateName = Name()
Ejemplo n.º 6
0
    def __init__(self, arg1 = None, arg2 = None):
        if arg1 == None or Common.typeIsString(arg1):
            filePath = ""
            if arg1 == None and arg2 == None:
                # Check if we can connect using UnixSocket.
                filePath = self._getUnixSocketFilePathForLocalhost()

            if filePath == "":
                transport = TcpTransport()
                host = arg1 if arg1 != None else "localhost"
                connectionInfo = TcpTransport.ConnectionInfo(
                  host, arg2 if type(arg2) is int else 6363)
            else:
                transport = UnixTransport()
                connectionInfo = UnixTransport.ConnectionInfo(filePath)
        else:
            transport = arg1
            connectionInfo = arg2

        self._node = Node(transport, connectionInfo)
        self._commandKeyChain = None
        self._commandCertificateName = Name()
Ejemplo n.º 7
0
    def __init__(self, loop, arg1 = None, arg2 = None):
        self._loop = loop

        # Imitate the Face constructor, but use AsyncTcpTransport, etc.
        if arg1 == None or Common.typeIsString(arg1):
            filePath = ""
            if arg1 == None and arg2 == None:
                # Check if we can connect using UnixSocket.
                filePath = self._getUnixSocketFilePathForLocalhost()

            if filePath == "":
                transport = AsyncTcpTransport(loop)
                host = arg1 if arg1 != None else "localhost"
                connectionInfo = AsyncTcpTransport.ConnectionInfo(
                  host, arg2 if type(arg2) is int else 6363)
            else:
                transport = AsyncUnixTransport(loop)
                connectionInfo = AsyncUnixTransport.ConnectionInfo(filePath)
        else:
            transport = arg1
            connectionInfo = arg2
        super(ThreadsafeFace, self).__init__(transport, connectionInfo)
Ejemplo n.º 8
0
    def read(self, fileNameOrInput, inputName=None):
        """
        Add the contents of the file or input string to the root BoostInfoTree. 
        There are two forms:
        read(fileName) reads fileName from the file system.
        read(input, inputName) reads from the input, in which case inputName is
        used only for log messages, etc.
        :param str fileName: The path to the INFO file.
        :param str input: The contents of the INFO file, with lines separated by
          "\n" or "\r\n".
        :param str inputName: Use with input for log messages, etc.
        """
        if Common.typeIsString(inputName):
            input = fileNameOrInput
        else:
            # No inputName, so assume the first arg is the file name.
            fileName = fileNameOrInput
            inputName = fileName
            f = open(fileName, 'r')
            input = f.read()
            f.close()

        self._read(input, self._root)
Ejemplo n.º 9
0
    def read(self, fileNameOrInput, inputName = None):
        """
        Add the contents of the file or input string to the root BoostInfoTree. 
        There are two forms:
        read(fileName) reads fileName from the file system.
        read(input, inputName) reads from the input, in which case inputName is
        used only for log messages, etc.
        :param str fileName: The path to the INFO file.
        :param str input: The contents of the INFO file, with lines separated by
          "\n" or "\r\n".
        :param str inputName: Use with input for log messages, etc.
        """
        if Common.typeIsString(inputName):
            input = fileNameOrInput
        else:
            # No inputName, so assume the first arg is the file name.
            fileName = fileNameOrInput
            inputName = fileName
            f = open(fileName, 'r')
            input = f.read()
            f.close()

        self._read(input, self._root)