I'm running a script for an FTP server in Python with PyFTPdLib like this:
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
def main():
authorizer = DummyAuthorizer()
authorizer.add_user('user', '12345', '.', perm='elradfmwM')
handler = FTPHandler
handler.authorizer = authorizer
address = ('localhost', 2121)
server = FTPServer(address, handler)
# start ftp server
server.serve_forever()
if __name__ == '__main__':
main()
Whenever I call this code, it keeps the command line busy with running the "server.serve_forever()", it doesn't keep running through the if loop.
So my question is, how do you add a user while the server is running without shutting down the server?
Do I need to create another script to call this one and then another to add a user? Will it need to be threaded so both can run without locking up on this one?
I've tried to look through the tutorials on this module, but I haven't found any examples or seen any solutions. I'm willing to switch to a different module to run a FTP server if needed, so long as I can control everything.
I'm going to be adding users a lot from a database, then removing them. So I don't want to take the server down and restart it every time I need to add someone.