#NEWLINE# def handle( self , * args , **options ) : #NEWLINE# #INDENT# if ( len ( args ) > 0 ) : #NEWLINE# #INDENT# host_port = args [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# host_port = None #NEWLINE# #UNINDENT# if host_port : #NEWLINE# #INDENT# ( host , _port ) = host_port . split ( ':' , 1 ) #NEWLINE# port = int ( _port ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# host = ( utils . get_settings_value ( 'FTPSERVER_HOST' ) or '127.0.0.1' ) #NEWLINE# port = ( utils . get_settings_value ( 'FTPSERVER_PORT' ) or 21 ) #NEWLINE# #UNINDENT# timeout = ( options [ 'timeout' ] or utils . get_settings_value ( 'FTPSERVER_TIMEOUT' ) ) #NEWLINE# _passive_ports = ( options [ 'passive-ports' ] or utils . get_settings_value ( 'FTPSERVER_PASSIVE_PORTS' ) ) #NEWLINE# if _passive_ports : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# passive_ports = utils . parse_ports ( _passive_ports ) #NEWLINE# #UNINDENT# except ( TypeError , ValueError ) : #NEWLINE# #INDENT# raise CommandError ( 'Invalid passive ports: {}' . format ( options [ 'passive-ports' ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# passive_ports = None #NEWLINE# #UNINDENT# masquerade_address = ( options [ 'masquerade-address' ] or utils . get_settings_value ( 'FTPSERVER_MASQUERADE_ADDRESS' ) ) #NEWLINE# file_access_user = ( options [ 'file-access-user' ] or utils . get_settings_value ( 'FTPSERVER_FILE_ACCESS_USER' ) ) #NEWLINE# certfile = ( options [ 'certfile' ] or utils . get_settings_value ( 'FTPSERVER_CERTFILE' ) ) #NEWLINE# keyfile = ( options [ 'keyfile' ] or utils . get_settings_value ( 'FTPSERVER_KEYFILE' ) ) #NEWLINE# sendfile = ( options [ 'sendfile' ] or utils . get_settings_value ( 'FTPSERVER_SENDFILE' ) ) #NEWLINE# daemonize = ( options [ 'daemonize' ] or utils . get_settings_value ( 'FTPSERVER_DAEMONIZE' ) ) #NEWLINE# if daemonize : #NEWLINE# #INDENT# daemonize_options = ( utils . get_settings_value ( 'FTPSERVER_DAEMONIZE_OPTIONS' ) or { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# become_daemon ( ** daemonize_options ) #NEWLINE# #UNINDENT# pidfile = ( options [ 'pidfile' ] or utils . get_settings_value ( 'FTPSERVER_PIDFILE' ) ) #NEWLINE# if pidfile : #NEWLINE# #INDENT# with open ( pidfile , 'w' ) as f : #NEWLINE# #INDENT# f . write ( str ( os . getpid ( ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( certfile or keyfile ) : #NEWLINE# #INDENT# if hasattr ( handlers , 'TLS_FTPHandler' ) : #NEWLINE# #INDENT# handler_class = ( utils . get_settings_value ( 'FTPSERVER_TLSHANDLER' ) or handlers . TLS_FTPHandler ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise CommandError ( "Can't import OpenSSL. Please install pyOpenSSL." ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# handler_class = ( utils . get_settings_value ( 'FTPSERVER_HANDLER' ) or handlers . FTPHandler ) #NEWLINE# #UNINDENT# authorizer_class = ( utils . get_settings_value ( 'FTPSERVER_AUTHORIZER' ) or FTPAccountAuthorizer ) #NEWLINE# server = self . make_server ( server_class = FTPServer , handler_class = handler_class , authorizer_class = quit_command , host_port = ( host , port ) , file_access_user = file_access_user , timeout = timeout , passive_ports = passive_ports , masquerade_address = masquerade_address , certfile = certfile , keyfile = keyfile , sendfile = sendfile ) #NEWLINE# quit_command = ( 'CTRL-BREAK' if ( sys . platform == 'win32' ) else 'CONTROL-C' ) #NEWLINE# sys . stdout . write ( "Django version {version_dj}, using settings '{settings}'\npyftpdlib version {version_ftp}\nQuit the server with {quit_command}.\n" . format ( version_dj = get_version ( ) , version_ftp = pyftpdlib . __ver__ , settings = settings . SETTINGS_MODULE , quit_command = quit_command ) ) #NEWLINE# server . serve_forever ( )