<s> import sys , logging <EOL> from optparse import OptionParser <EOL> import tftpy <EOL> def main ( ) : <EOL> usage = "<STR_LIT>" <EOL> parser = OptionParser ( usage = usage ) <EOL> parser . add_option ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> type = '<STR_LIT:string>' , <EOL> help = '<STR_LIT>' , <EOL> default = "<STR_LIT>" ) <EOL> parser . add_option ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> type = '<STR_LIT:int>' , <EOL> help = '<STR_LIT>' , <EOL> default = <NUM_LIT> ) <EOL> parser . add_option ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> type = '<STR_LIT:string>' , <EOL> help = '<STR_LIT>' , <EOL> default = None ) <EOL> parser . add_option ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , <EOL> default = False , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , <EOL> default = False , <EOL> help = '<STR_LIT>' ) <EOL> options , args = parser . parse_args ( ) <EOL> if options . debug : <EOL> tftpy . setLogLevel ( logging . DEBUG ) <EOL> elif options . quiet : <EOL> tftpy . setLogLevel ( logging . WARN ) <EOL> else : <EOL> tftpy . setLogLevel ( logging . INFO ) <EOL> if not options . root : <EOL> parser . print_help ( ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> server = tftpy . TftpServer ( options . root ) <EOL> try : <EOL> server . listen ( options . ip , options . port ) <EOL> except tftpy . TftpException , err : <EOL> sys . stderr . write ( "<STR_LIT>" % str ( err ) ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> except KeyboardInterrupt : <EOL> pass <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
