How to delete a user "on the fly", meaning when the server itself is running?--Here's my code at the moment:Inside my main.py I created a local FTP server using this lib.Then I create a new folder named modules with a class called GameServer. Inside this class gameserver I defined a method (static) to deleteFTPAccess(username). How to call this method now using the FTP server defined inside the main.py?My structure of files:main.pymodulesgameserver.pygameserver.py
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
class GameServer ():
def __init__(self, id, ip_address, port):
self.id = id
self.ip_address = ip_address
self.port = port
@staticmethod
def deleteServer(id):
#delete FTP access
authorizer = DummyAuthorizer()
authorizer.remove_user(id)main.py
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
from modules.gameserver import GameServer
authorizer = DummyAuthorizer()
authorizer.add_user("user", "12345", "/home", perm="elradfmw")
handler = FTPHandler
handler.authorizer = authorizer
server = FTPServer(("127.0.0.1", 21), handler)
server.serve_forever()
GameServer.deleteServer("user")When deleting a server it doesn't effect the FTP, meaning I can access the server using the username after deleting. From my point of view, the usage is wrong.
You received this message because you are subscribed to the "Python FTP server library" project group:
http://code.google.com/p/pyftpdlib/
To post to this group, send email to pyft...@googlegroups.com
To unsubscribe from this group, send email to pyftpdlib-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/pyftpdlib
---
You received this message because you are subscribed to the Google Groups "Python FTP server library - Discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyftpdlib+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group, send email to pyftpdlib-...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/pyftpdlib
---
You received this message because you are subscribed to the Google Groups "Python FTP server library - Discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyftpdlib+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group, send email to pyftpdlib-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/pyftpdlib
---
You received this message because you are subscribed to the Google Groups "Python FTP server library - Discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyftpdlib+unsubscribe@googlegroups.com.
global authorizer
authorizer = DummyAuthorizer()
@staticmethod
def deleteServer(id):
#delete FTP access
authorizer.remove_user(id)
NameError: global name 'authorizer' is not defined
To unsubscribe from this group, send email to pyftpdlib-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/pyftpdlib
---
You received this message because you are subscribed to the Google Groups "Python FTP server library - Discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyftpdlib+unsubscribe@googlegroups.com.
class GameServer ():
def __init__(self, id, ip_address, port, slots, tickrate = 64):
self.id = id
self.ip_address = ip_address
self.port =
port
self.slots = slots
self.tickrate = tickrate
@staticmethod
def deleteServer(id):
#delete FTP access
authorizer.remove_user(id)
#import ConfigParser
#from database_connection import *
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
from modules.gameserver import GameServer
global authorizer
authorizer = DummyAuthorizer()
authorizer.add_user("user", "12345", "/home", perm="elradfmw")
handler = FTPHandler
handler.authorizer = authorizer
server = FTPServer(("127.0.0.1", 21), handler)
server.serve_forever()
GameServer.deleteServer("user")
--
You received this message because you are subscribed to the "Python FTP server library" project group:
http://code.google.com/p/pyftpdlib/
To post to this group, send email to pyft...@googlegroups.com
To unsubscribe from this group, send email to pyftpdlib-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/pyftpdlib
---
You received this message because you are subscribed to the Google Groups "Python FTP server library - Discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyftpdlib+unsubscribe@googlegroups.com.
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import MultiprocessFTPServer
from modules.gameserver import Gameserver
def main():
print("hallo1")
authorizer = DummyAuthorizer()
authorizer.add_user('user', '12345', '.')
handler = FTPHandler
handler.authorizer =
authorizer
server = MultiprocessFTPServer(('', 2121), handler)
server.serve_forever()
print("hallo")
server.close_all()
Gameserver.deleteServer(server, authorizer, "user")
if __name__ == "__main__":
main()
class Gameserver (): def __init__(self, id, ip_address, port, slots, tickrate = 64): self.id = id self.ip_address = ip_address self.port = port self.slots = slots self.tickrate = tickrate @staticmethod def deleteServer (server, authorizer, name ): authorizer.remove_user(name)
To unsubscribe from this group, send email to pyftpdlib-...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/pyftpdlib
---
You received this message because you are subscribed to the Google Groups "Python FTP server library - Discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyftpdlib+...@googlegroups.com.