I have a program that calls a couple of DOS commands, moves files, ZIPS them, and FTPs them to a server. When I test it in IDLE, works fine. I have tried to make into a EXE using pyInstaller and py2exe, both EXEs make the the program die immediatelt. Tried debugging, everything, cannot figure it out.
# FTP v0.3
# Writen by Kevin Culinane
import ftplib
import os
import sys
import traceback
import datetime
import subprocess
import shutil
import zipfile
import time
#This section defines the variables
today = datetime.date.today()
yesterday = (today + datetime.timedelta(days=-1))
host='site.ftp.site'
port='**'
login='***
password='***'
some_directory='***'
fullname='C:\\crunchtime'
#This section renames the zip file with todays date
os.chdir('c:\\sc')
subprocess.Popen(['posidbfw', '/alt', '1', '1'])
subprocess.Popen(['tarw', '-r', '52', '1', '1', '/alt'])
time.sleep(10)
shutil.rmtree('c:\\crunchtime')
os.mkdir('c:\\crunchtime')
os.chdir('c:\\altdbf')
shutil.copy2('c:\\altdbf\\cashout.dbf', 'c:\\crunchtime')
shutil.copy2('c:\\altdbf\\chkitems.dbf', 'c:\\crunchtime')
shutil.copy2('c:\\altdbf\\deposits.dbf', 'c:\\crunchtime')
shutil.copy2('c:\\altdbf\\DISCOUNT.DBF', 'c:\\crunchtime')
shutil.copy2('c:\\altdbf\\hrsales.dbf', 'c:\\crunchtime')
shutil.copy2('c:\\altdbf\\nrt.DBF', 'c:\\crunchtime')
shutil.copy2('c:\\altdbf\\paidouts.DBF', 'c:\\crunchtime')
shutil.copy2('c:\\altdbf\\salestax.DBF', 'c:\\crunchtime')
shutil.copy2('c:\\altdbf\\shftsls.DBF', 'c:\\crunchtime')
shutil.copy2('c:\\altdbf\\names.DBF', 'c:\\crunchtime')
shutil.copy2('c:\\altdbf\\payrpunc.DBF', 'c:\\crunchtime')
os.chdir('c:\\crunchtime')
allFileNames = os.listdir('c:\\crunchtime')
myZipFile = zipfile.ZipFile("CT" +yesterday.strftime('%m%d%y') + ".zip", 'w')
for fileName in allFileNames:
(name, ext) = os.path.splitext( fileName )
print "Writing..." + fileName
myZipFile.write( fileName, os.path.basename(fileName), zipfile.ZIP_DEFLATED )
myZipFile.close()
#This section starts the FTP process
print "Files:", 'c:\\crunchtime\\CT' + yesterday.strftime('%m%d%y') + '.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\\CT' + yesterday.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()