ftp下载导致程序无响应直到下载完成

时间:2016-04-07 14:12:28

标签: python download ftp qthread

从ftp下载文件时,我的程序没有响应。我正在查看qthread,但对如何使用它感到困惑。

def Download(self):

    #self.startbutton1.destroy()

    userprofile = environ['USERPROFILE']
    tempfile = environ['TEMP']

    ftp = FTP('ftpsite')
    ftp.login(user='username', passwd = 'PWhere')
    ftp.nlst()

    ftp.cwd(self.directoryftp)

    #Download all file in directory
    filenames = ftp.nlst()
    print filenames

    if not os.path.exists(tempfile + "\\PythonEXE\'s"):
        os.makedirs(tempfile + "\\PythonEXE\'s")

    for filename in filenames:
        local_filename = os.path.join(tempfile + "\\PythonEXE\'s", filename)
        file = open(local_filename, 'wb')
        ftp.retrbinary('RETR '+ filename, file.write)
    file.close()

0 个答案:

没有答案