0

Wrote this script to send a zip file that gets created every day and sent to a FTP server. In line 16, getting a windows 183 error cannot create file that already exists. I am using os.rename, and it works if I run it stand alone. Any ideas?

import ftplib
import os
import sys
import traceback
import datetime

today = datetime.date.today()
host='mail.freshfoodconcepts.com'
port='21'
login='ftpclient'
password='74Dog91'
some_directory='Warwick'
fullname='C:\\crunchtime'
rb='crunsend.zip'

os.rename("c:\\crunchtime\\crunsend.zip", "c:\\kmfc\\crunchtime" + today.strftime("%m%d%y") + ".zip")


print "Files:", 'c:\\crunchtime\\crunsend.zip'

print "Logging in..."
ftp = ftplib.FTP()
ftp.connect(host, port)
print ftp.getwelcome()
try:
    try:
        ftp.login(login, password)
        ftp.cwd(some_directory)
        # move to the desired upload directory
        print "Currently in:", ftp.pwd()

        print "Uploading...",
        fullname = 'c:\\crunchtime\\crunsend' + today.strftime("%m%d%y") + '.zip'
        name = os.path.split(fullname)[1]
        f = open(fullname, "rb")
        ftp.storbinary('STOR ' + name, f)
        f.close()
        print "OK"
        
        print "Files:"
        print ftp.retrlines('LIST')
    finally:
        print "Quitting..."
        ftp.quit()
except:
    traceback.print_exc()
2
Contributors
2
Replies
4
Views
8 Years
Discussion Span
Last Post by woooee
1

Sorry for the dumb question, I saw the problem, thanks for looking though.

Votes + Comments
There's not dumb questions, just dumb answers.
0

Sorry for the dumb question, I saw the problem, thanks for looking though.

They are pretty much all dumb.....after you find the answer. Also, please mark the post solved.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.