[Tutor] Type Error

richard kappler richkappler at gmail.com
Mon Sep 14 16:29:37 CEST 2015


Still working on my data feed script, if you'll recall from previous
emails, it reads incoming data and creates a name for image files based on
the incoming data in a test environment. below is a snippet of that code
that copies the next image in the pool renaming it as it copies, sends to
another machine via ftp, the closes the file and *** should then delete the
file *** but does not.

img = str(i) + '.jpg'
ID = device + '_' + timestamp + '_' + counter + '.jpg'
src = '/home/test/DataFeed/input/BOT/' + img
dst = '/home/test/DataFeed/output/BOT' + ID
shututil.copyfile(src, dst)
file = open(dst, 'rb')
sendBOT01.storbinary('STOR ' + ID, file)
file.close()
os.remove(file)


everything works except the os.remove(file) which gives the following error:

Traceback (most recent call last):
  File "DataFeedBatch.py", line 104, in <module>
     os.remove(file)
TypeError: coercing to Unicode: need string or buffer, file found

I don't understand the error
-- 

All internal models of the world are approximate. ~ Sebastian Thrun


More information about the Tutor mailing list