I get a file permissions error, and this is running on Apache.
It's dying on the retrbinary line. However, it's logging in using
valid user names and passwords, so I'm confused as to why it's dying.
def getInvRpt(id, filename, path, db):
file_list = []
os.chdir('/home/amr/ics_in/')
ftp_info = getFtpInfo(2, db)
ftp = FTP(ftp_info[0])
ftp.login(ftp_info[1], ftp_info[2])
if None == path:
ftp.cwd('/home/ics/amr')
else:
ftp.cwd(path)
avail_file_list = ftp.nlst()
for row in avail_file_list:
if filename == row:
ftp_cmd = 'RETR ' + row
ftp.retrbinary(ftp_cmd, open(row, 'wb').write)
file_list.append(row)
break
return file_list
I got more details after taking what the command line program did and
putting most of it into a new function in views.py.
def process_file_load(inventory_file, inventory_file_path):
my_cnf = '/home/amr' + '/.my.cnf'
db = connectToMysqlDBuc(my_cnf)
file_list = []
# dies here performing the ftp.
file_list = getInvRpt(2, inventory_file, inventory_file_path, db)
out_file = cvtInvData(file_list)
rc = truncateInvInTables(None)
rc = loadIncomingInvData(out_file)
total_items = []
items_processed = []
errors = []
load_rpt = []
rc = xferInvInData(total_items, items_processed, errors, db)
if 0 != rc:
load_rpt.append(("SQL Error: ", str(-1)))
print("SQL Error")
process_string = "Inventory items for processing: " +
str(len(total_items))
load_rpt.append((process_string, -1))
process_string = "Inventory items processed: " +
str(len(items_processed))
load_rpt.append((process_string, -1))
if 0 < len(errors):
process_string = "Inventory items processing errors: " +
str(len(errors))
load_rpt.append((process_string, -1))
load_rpt.append(("\n", str(-1)))
load_rpt.append(("Part Number", "Serial Number\n"))
load_rpt.append(("----------------------------\n", str(-1)))
for row in errors:
load_rpt.append(row)
fp = open('/tmp/inv_rpt.txt', 'w')
for rpt_line in load_rpt:
if rpt_line[1] != str(-1) and rpt_line[1] != -1:
"""
This is kludgy, but appears to work on handling special
strings that are not
part of the inventory.
"""
if 15 <= len(rpt_line):
fixed_rpt_line = rpt_line[0] + ' ' + str(rpt_line[15])
+ '\n'
else:
fixed_rpt_line = str(rpt_line) + '\n'
else:
fixed_rpt_line = rpt_line[0] + ' ' + '\n'
fp.write(fixed_rpt_line)
fp.close()
fp = open('/tmp/inv_rpt.txt', 'r')
msg = MIMEText(fp.read())
fp.close()
this_day = datetime.today()
.
.
.
I believe it's hanging up on an ftp in one of the imported modules.
On Aug 15, 3:33 pm, wayne <[email protected]> wrote:
> What error exactly do you get? Do you encounter this error while
> using runserver, or is it live on a web server (Apache et al)?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.