Hi I am trying to create an FTP server and to aid the development I'm using pyftpdlib. What I wanted to do is to do some file operations if a user downloads a specific file but sometimes it raises an exception and I don't really know why.
I wrote my own handler in pyftpdlib after this tutorial: http://code.google.com/p/pyftpdlib/wiki/Tutorial#3.8_-_Event_callbacks
But something goes terribly wrong sometimes when the user downloads the log file (which I intend to do some file operations on) and I don't really understand why. I have another class which basically reads from a configuration file and the error message said it couldn't find FTP Section. But it's strange because I clearly have it in my configuration file and it is working sometimes perfectly.
May this error appear because I have two "Connection" objects? That's the only guess I have, so I would be very glad if someone could explain what's going wrong. Here is my code that's troubled (nevermind the file.name check because that was very recently added):
class ArchiveHandler(ftpserver.FTPHandler):
def on_login(self, username):
    # do something when user login
    pass
def on_logout(self, username):
    # do something when user logs out
    pass
def on_file_sent(self, file):
    "What to do when retrieved the file the class is watching over"
    attr = Connection()
    if attr.getarchive() == 'true':
        t = datetime.now()
    if file.name == "log.log":
            try:
                shutil.copy2(file, attr.getdir() + ".archive/" + str(t.strftime("%Y-%m-%d_%H:%M:%S") + '.log'))
            except OSError:
                print 'Could not copy file'
                raise
        if attr.getremain() == 'false':
                try:
                    os.remove(file)
                except OSError:
                    print 'Could not remove file'
                    raise
The full source: http://pastie.org/3552079
Source of the config-file: http://pastie.org/3552085
EDIT-> (and of course the error):
[root]@85.230.122.159:40659 unhandled exception in instance <pyftpdlib.ftpserver.DTPHandler object at 0xb75f49ec>
Traceback (most recent call last):
  File "/usr/lib/python2.6/asyncore.py", line 84, in write
    obj.handle_write_event()
  File "/usr/lib/python2.6/asyncore.py", line 435, in handle_write_event
    self.handle_write()
  File "/usr/lib/python2.6/asynchat.py", line 174, in handle_write
    self.initiate_send()
  File "/usr/lib/python2.6/asynchat.py", line 215, in initiate_send
    self.handle_close()
  File "/usr/local/lib/python2.6/dist-packages/pyftpdlib/ftpserver.py", line 1232, in handle_close
    self.close()
  File "/usr/local/lib/python2.6/dist-packages/pyftpdlib/ftpserver.py", line 1261, in close
    self.cmd_channel.on_file_sent(filename)
  File "ftp.py", line 87, in on_file_sent
  File "ftp.py", line 12, in __init__
  File "/usr/lib/python2.6/ConfigParser.py", line 311, in get
    raise NoSectionError(section)
NoSectionError: No section: 'FTP Section'
 
     
    