On Mon, Sep 14, 2015 at 10:29 AM, richard kappler <richkapp...@gmail.com> wrote: > 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 >
I'm not sure if you want to remove src or dst, but whichever one you want to remove, use the name, not the file object, eg: os.remove(src) _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor -- Joel Goldstick http://joelgoldstick.com _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor