Ejemplo n.º 1
0
    def download(self):
        f = open(self.filename,'wb')
        f.seek(self.firstbyte)

        ftp = FTP(self.url[1])
        
        #if i got user and password i login in
        if self.user and self.password:
            response = ftp.login(self.user,self.password)
        else:
            response = ftp.login()
            
        #verifying that the login is ok
        common.verify_ftp_response(response)
        
        #begin from the firstbyte
        ftp.sendcmd("SYST")
        ftp.sendcmd("TYPE I")
        ftp.sendcmd("PASV")
        
        sock = ftp.transfercmd(("RETR %s"%(self.url[2])),self.firstbyte)

        self.write_bytes(sock,f)
        
        sock.close()
Ejemplo n.º 2
0
    def download(self):
        f = open(self.filename, 'wb')
        f.seek(self.firstbyte)

        ftp = FTP(self.url[1])

        #if i got user and password i login in
        if self.user and self.password:
            response = ftp.login(self.user, self.password)
        else:
            response = ftp.login()

        #verifying that the login is ok
        common.verify_ftp_response(response)

        #begin from the firstbyte
        ftp.sendcmd("SYST")
        ftp.sendcmd("TYPE I")
        ftp.sendcmd("PASV")

        sock = ftp.transfercmd(("RETR %s" % (self.url[2])), self.firstbyte)

        self.write_bytes(sock, f)

        sock.close()
Ejemplo n.º 3
0
 def get_file_size(self,url,user,password):
     parsedURL = urlparse(url)
     print "Connecting to %s..."%(parsedURL[1])
     ftp = FTP(parsedURL[1])
     
     print "Login..."
     #authentication stuff
     if user and password:
         response = ftp.login(user,password)
     else:
         response = ftp.login()
         
     #verify that the login was right
     common.verify_ftp_response(response)
     
     length = ftp.size(parsedURL[2])
     
     ftp.quit()
     
     return length
Ejemplo n.º 4
0
    def get_file_size(self, url, user, password):
        parsedURL = urlparse(url)
        print "Connecting to %s..." % (parsedURL[1])
        ftp = FTP(parsedURL[1])

        print "Login..."
        #authentication stuff
        if user and password:
            response = ftp.login(user, password)
        else:
            response = ftp.login()

        #verify that the login was right
        common.verify_ftp_response(response)

        length = ftp.size(parsedURL[2])

        ftp.quit()

        return length