Beispiel #1
0
 def gotClient(self, client, request, filepath):
     self.client = client
     protocol = FTPFileListProtocol()
     return client.list(filepath, protocol).addCallbacks(
         callback=self._build_response,
         callbackArgs=(request, protocol),
         errback=self._failed,
         errbackArgs=(request, ))
Beispiel #2
0
    def _get_files(self):
        try:
            file_list = FTPFileListProtocol()
            yield self.list('.', file_list)
            yield self._retrieve_files(file_list)
        except Exception as e:
            log.err('Exception while listing or retrieving files (%s)' % e)

        reactor.callLater(CHECK_INTERVAL, self._get_files)
Beispiel #3
0
    def connectionMade(self, ftpClient):
        """
        A callback function for a successful connection
        """

        # Get a detailed listing of the current directory
        self.twisted_FTP_client = ftpClient
        fileList = FTPFileListProtocol()
        d = ftpClient.list(self.read_path, fileList)
        d.addCallbacks(self.__getFiles, self.fail, callbackArgs=(fileList, ftpClient))
Beispiel #4
0
 def gotClient(self, client, request, filepath):
     if isinstance(request, FileFtpRequest):
         return super(FtpListingHandler,
                      self).gotClient(client, request, filepath)
     protocol = FTPFileListProtocol()
     return client.list(filepath, protocol).addCallbacks(
         callback=self._build_response,
         callbackArgs=(request, protocol),
         errback=self._failed,
         errbackArgs=(request, ))
Beispiel #5
0
 def gotClient(self, client, request, filepath):
     self.client = client
     if split(filepath)[1]:  # is file
         protocol = ReceivedDataProtocol()
         return client.retrieveFile(filepath, protocol)\
             .addCallbacks(callback=self._build_response,
                     callbackArgs=(request, protocol),
                     errback=self._failed,
                     errbackArgs=(request,))
     else:   # is dir
         protocol = FTPFileListProtocol()
         return client.list(filepath[1:], protocol).addCallbacks(
             callback=self._build_response_dir, callbackArgs=(request, protocol),
             errback=self._failed, errbackArgs=(request,))
Beispiel #6
0
    def gotClient(self, client, request, filepath):
        """ Gets files list or one file """

        # Check what class sent a request
        if not isinstance(request, ListFtpRequest):
            return super(FtpListingHandler,
                         self).gotClient(client, request, filepath)

        protocol = FTPFileListProtocol()
        return client.list(filepath, protocol).addCallbacks(
            callback=self._build_response,
            callbackArgs=(request, protocol),
            errback=self._failed,
            errbackArgs=(request, ))
Beispiel #7
0
    def gotClient(self, client, request, filepath):
        # download file
        if isinstance(request, FTPListRequest):
            # ftp listings
            proto = FTPFileListProtocol()
            result = client.list(filepath, proto).addCallbacks(
                callback=self._build_listing_response,
                callbackArgs=[request, proto],
                errback=self._failed,
                errbackArgs=[request],
            )
            client.quit()
            return result

        result = super().gotClient(client, request, filepath)
        client.quit()
        return result
Beispiel #8
0
def connectionMade(ftpClient):
    # Get the current working directory
    ftpClient.pwd().addCallbacks(success, fail)

    # Get a detailed listing of the current directory
    fileList = FTPFileListProtocol()
    d = ftpClient.list(".", fileList)
    d.addCallbacks(showFiles, fail, callbackArgs=(fileList, ))

    # Change to the parent directory
    ftpClient.cdup().addCallbacks(success, fail)

    # Create a buffer
    proto = BufferingProtocol()

    # Get short listing of current directory, and quit when done
    d = ftpClient.nlst(".", proto)
    d.addCallbacks(showBuffer, fail, callbackArgs=(proto, ))
    d.addCallback(lambda result: reactor.stop())
Beispiel #9
0
	def ftpFetchList(self, *args, **kwargs):
		self.filelist = FTPFileListProtocol()
		d = self.ftpclient.list(self.path, self.filelist)
		d.addCallback(self.listRcvd).addErrback(self.connectionFailed)