Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.
My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
from pyftpdlib import ftpserver from datetime import datetime import ConfigParser, os, shutil "Handles the connection variables specified in the configuration file." "Gets the variables from the configuration file" config = self.ip = self.port = self.directory = self.user = self.password = self.logname = self.archive = self.remain = # Create ftp root if not exists "Returns the hostname" return self.ip "Returns the port number" return self.port "Returns the root directory of the ftp-server" return self.directory "Returns the user" return self.user "Returns the password" return self.password "Returns the name of the log file" return self.logname "Returns true/false if the program should archive log files or not." return self.archive "Returns true/false if the logfile should remain after logout." return self.remain "Creates ftp root if not exist" try: except OSError: if : # We are nearly safe print 'Could not create root folder, it exists' pass else: # There was an error on creation, so make sure we know about it raise "Creates archive directory in ftp root if not exist" try: except OSError: if : # We are nearly safe print 'Could not create root folder, it exists' pass else: # There was an error on creation, so make sure we know about it raise # do something when user login pass # do something when user logs out pass "What to do when retrieved the file the class is watching over" attr = if == 'true': t = if file.name == "log.log": try: except OSError: print 'Could not copy file' raise if == 'false': try: except OSError: print 'Could not remove file' raise # remove partially uploaded files import os # do something when a file has been received pass # do something when a file is partially sent pass #Read configs from the FTP section in the config file #Put the data into variables used to create the ftp-connection # Open a new connection object conn = #Check if we are going to archive files, if true, create an archive folder. if( == 'true'): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = # Define a new user having full r/w permissions and a read-only # anonymous user # Remove # below to add an anonymous user with only read access. # authorizer.add_anonymous(homedir='.') # Instantiate FTP handler class handler = ArchiveHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "Session started, ftp-server api version %s" %ftpserver.__ver__ # Specify a masquerade address and the range of ports to use for # passive connections. Decomment in case you're behind a NAT. #ftp_handler.masquerade_address = '151.25.42.11' #ftp_handler.passive_ports = range(60000, 65535) # Instantiate FTP server class and listen to 0.0.0.0:21 address = (', ) server = # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server if __name__ == '__main__': |