Example #1
0
    def setUpServer(self):
        """Create an FTP server instance and save it in self.ftpServer
        """

        from ZServer import logger
        from ZServer.FTPServer import FTPServer
        from StringIO import StringIO

        log = self.log
        if log is None:
            log = StringIO()

        zopeLog = logger.file_logger(log)

        self.ftpServer = FTPServer(
            'Zope2',
            ip=self.host,
            port=self.port,
            logger_object=zopeLog,
        )
        # Refresh the hostname and port in case we dynamically picked them
        self.host, self.port = self.ftpServer.socket.getsockname()
        # If we dynamically set the host/port, we want to reset it to localhost
        # Otherwise this will depend on, for example, the local network setup
        if self.host in (
                '',
                '0.0.0.0',
                '127.0.0.1',
        ):
            self.host = 'localhost'
            self.ftpServer.hostname = 'localhost'
            self.ftpServer.ip = '127.0.0.1'
        self['host'] = self.host
        self['port'] = self.port
Example #2
0
class FTPServer(ZServer):
    """FTP variant of the ZServer layer.

    This will not play well with the ZServer layer. If you need both
    ZServer and FTPServer running together, you can subclass the ZServer
    layer class (like this layer class does) and implement setUpServer()
    and tearDownServer() to set up and close down two servers on different
    ports. They will then share a main loop.

    The ``FTP_SERVER_FIXTURE`` layer must be used as the base for a layer that
    uses the ``FunctionalTesting`` layer class. The ``FTP_SERVER`` layer is
    an example of such a layer.
    """

    defaultBases = (STARTUP,)

    host = os.environ.get('FTPSERVER_HOST', '')
    port = int(os.environ.get('FTPSERVER_PORT', 0))
    threads = 1
    timeout = 5.0
    log = None

    def setUpServer(self):
        """Create an FTP server instance and save it in self.ftpServer
        """

        from ZServer import logger
        from ZServer.FTPServer import FTPServer
        from StringIO import StringIO

        log = self.log
        if log is None:
            log = StringIO()

        zopeLog = logger.file_logger(log)

        self.ftpServer = FTPServer(
            'Zope2',
            ip=self.host,
            port=self.port,
            logger_object=zopeLog,
        )
        # Refresh the hostname and port in case we dynamically picked them
        self.host, self.port = self.ftpServer.socket.getsockname()
        # If we dynamically set the host/port, we want to reset it to localhost
        # Otherwise this will depend on, for example, the local network setup
        if self.host in ('', '0.0.0.0', '127.0.0.1', ):
            self.host = 'localhost'
            self.ftpServer.hostname = 'localhost'
            self.ftpServer.ip = '127.0.0.1'
        self['host'] = self.host
        self['port'] = self.port

    def tearDownServer(self):
        """Close the FTPServer socket
        """
        self.ftpServer.close()
Example #3
0
    def setUpServer(self):
        """Create an FTP server instance and save it in self.ftpServer
        """

        from ZServer import logger
        from ZServer.FTPServer import FTPServer
        from StringIO import StringIO

        log = self.log
        if log is None:
            log = StringIO()

        zopeLog = logger.file_logger(log)

        self.ftpServer = FTPServer(
            'Zope2',
            ip=self.host,
            port=self.port,
            logger_object=zopeLog,
        )
        # Refresh the hostname and port in case we dynamically picked them
        self.host, self.port = self.ftpServer.socket.getsockname()
        # If we dynamically set the host/port, we want to reset it to localhost
        # Otherwise this will depend on, for example, the local network setup
        if self.host in ('', '0.0.0.0', '127.0.0.1', ):
            self.host = 'localhost'
            self.ftpServer.hostname = 'localhost'
            self.ftpServer.ip = '127.0.0.1'
        self['host'] = self.host
        self['port'] = self.port
Example #4
0
class FTPServer(ZServer):
    """FTP variant of the ZServer layer.

    This will not play well with the ZServer layer. If you need both
    ZServer and FTPServer running together, you can subclass the ZServer
    layer class (like this layer class does) and implement setUpServer()
    and tearDownServer() to set up and close down two servers on different
    ports. They will then share a main loop.

    The ``FTP_SERVER_FIXTURE`` layer must be used as the base for a layer that
    uses the ``FunctionalTesting`` layer class. The ``FTP_SERVER`` layer is
    an example of such a layer.
    """

    defaultBases = (STARTUP,)

    host = os.environ.get('FTPSERVER_HOST', 'localhost')
    port = int(os.environ.get('FTPSERVER_PORT', 55002))
    threads = 1
    timeout = 5.0
    log = None

    def setUpServer(self):
        """Create an FTP server instance and save it in self.ftpServer
        """

        from ZServer import logger
        from ZServer.FTPServer import FTPServer
        from StringIO import StringIO

        log = self.log
        if log is None:
            log = StringIO()

        zopeLog = logger.file_logger(log)

        self.ftpServer = FTPServer(
            'Zope2',
            ip=self.host,
            port=self.port,
            logger_object=zopeLog)

    def tearDownServer(self):
        """Close the FTPServer socket
        """
        self.ftpServer.close()
Example #5
0
class FTPServer(ZServer):
    """FTP variant of the ZServer layer.

    This will not play well with the ZServer layer. If you need both
    ZServer and FTPServer running together, you can subclass the ZServer
    layer class (like this layer class does) and implement setUpServer()
    and tearDownServer() to set up and close down two servers on different
    ports. They will then share a main loop.

    The ``FTP_SERVER_FIXTURE`` layer must be used as the base for a layer that
    uses the ``FunctionalTesting`` layer class. The ``FTP_SERVER`` layer is
    an example of such a layer.
    """

    defaultBases = (STARTUP, )

    host = os.environ.get('FTPSERVER_HOST', 'localhost')
    port = int(os.environ.get('FTPSERVER_PORT', 55002))
    threads = 1
    timeout = 5.0
    log = None

    def setUpServer(self):
        """Create an FTP server instance and save it in self.ftpServer
        """

        from ZServer import logger
        from ZServer.FTPServer import FTPServer
        from StringIO import StringIO

        log = self.log
        if log is None:
            log = StringIO()

        zopeLog = logger.file_logger(log)

        self.ftpServer = FTPServer('Zope2',
                                   ip=self.host,
                                   port=self.port,
                                   logger_object=zopeLog)

    def tearDownServer(self):
        """Close the FTPServer socket
        """
        self.ftpServer.close()
Example #6
0
    def setUpServer(self):
        """Create an FTP server instance and save it in self.ftpServer
        """

        from ZServer import logger
        from ZServer.FTPServer import FTPServer
        from StringIO import StringIO

        log = self.log
        if log is None:
            log = StringIO()

        zopeLog = logger.file_logger(log)

        self.ftpServer = FTPServer('Zope2',
                                   ip=self.host,
                                   port=self.port,
                                   logger_object=zopeLog)
Example #7
0
 def create(self):
     from ZServer.AccessLogger import access_logger
     from ZServer.FTPServer import FTPServer
     return FTPServer(ip=self.ip,
                      hostname=self.host,
                      port=self.port,
                      module=self.module,
                      resolver=self.dnsresolver,
                      logger_object=access_logger)
Example #8
0
    def setUpServer(self):
        """Create an FTP server instance and save it in self.ftpServer
        """

        from ZServer import logger
        from ZServer.FTPServer import FTPServer
        from StringIO import StringIO

        log = self.log
        if log is None:
            log = StringIO()

        zopeLog = logger.file_logger(log)

        self.ftpServer = FTPServer('Zope2', ip=self.host, port=self.port, logger_object=zopeLog)
Example #9
0
        """

        from ZServer import logger
        from ZServer.FTPServer import FTPServer
        from StringIO import StringIO

        log = self.log
        if log is None:
            log = StringIO()

        zopeLog = logger.file_logger(log)

        self.ftpServer = FTPServer('Zope2',
                                   ip=self.host,
                                   port=self.port,
                                   logger_object=zopeLog)

    def tearDownServer(self):
        """Close the FTPServer socket
        """
        self.ftpServer.close()


# Fixture layer - use as a base layer, but don't use directly, as it has no
# test lifecycle
FTP_SERVER_FIXTURE = FTPServer()

# Functional testing layer that uses the FTP_SERVER_FIXTURE
FTP_SERVER = FunctionalTesting(bases=(FTP_SERVER_FIXTURE, ),
                               name="FTPServer:Functional")
Example #10
0
class FTPServer(ZServer):
    """FTP variant of the ZServer layer.

    This will not play well with the ZServer layer. If you need both
    ZServer and FTPServer running together, you can subclass the ZServer
    layer class (like this layer class does) and implement setUpServer()
    and tearDownServer() to set up and close down two servers on different
    ports. They will then share a main loop.

    The ``FTP_SERVER_FIXTURE`` layer must be used as the base for a layer that
    uses the ``FunctionalTesting`` layer class. The ``FTP_SERVER`` layer is
    an example of such a layer.
    """

    defaultBases = (STARTUP, )

    host = os.environ.get('FTPSERVER_HOST', '')
    port = int(os.environ.get('FTPSERVER_PORT', 0))
    threads = 1
    timeout = 5.0
    log = None

    def setUpServer(self):
        """Create an FTP server instance and save it in self.ftpServer
        """

        from ZServer import logger
        from ZServer.FTPServer import FTPServer
        from StringIO import StringIO

        log = self.log
        if log is None:
            log = StringIO()

        zopeLog = logger.file_logger(log)

        self.ftpServer = FTPServer(
            'Zope2',
            ip=self.host,
            port=self.port,
            logger_object=zopeLog,
        )
        # Refresh the hostname and port in case we dynamically picked them
        self.host, self.port = self.ftpServer.socket.getsockname()
        # If we dynamically set the host/port, we want to reset it to localhost
        # Otherwise this will depend on, for example, the local network setup
        if self.host in (
                '',
                '0.0.0.0',
                '127.0.0.1',
        ):
            self.host = 'localhost'
            self.ftpServer.hostname = 'localhost'
            self.ftpServer.ip = '127.0.0.1'
        self['host'] = self.host
        self['port'] = self.port

    def tearDownServer(self):
        """Close the FTPServer socket
        """
        self.ftpServer.close()