<s> import getopt <EOL> import logging <EOL> import sys <EOL> from coapthon . reverse_proxy . coap import CoAP <EOL> __author__ = '<STR_LIT>' <EOL> class CoAPReverseProxy ( CoAP ) : <EOL> def __init__ ( self , host , port , xml_file , multicast = False ) : <EOL> CoAP . __init__ ( self , ( host , port ) , xml_file = xml_file , multicast = multicast ) <EOL> print "<STR_LIT>" + host + "<STR_LIT::>" + str ( port ) <EOL> def usage ( ) : <EOL> print "<STR_LIT>" <EOL> def main ( argv ) : <EOL> ip = "<STR_LIT:127.0.0.1>" <EOL> port = <NUM_LIT> <EOL> file_xml = "<STR_LIT>" <EOL> try : <EOL> opts , args = getopt . getopt ( argv , "<STR_LIT>" , [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> except getopt . GetoptError : <EOL> usage ( ) <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> for opt , arg in opts : <EOL> if opt == '<STR_LIT>' : <EOL> usage ( ) <EOL> sys . exit ( ) <EOL> elif opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> ip = arg <EOL> elif opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> port = int ( arg ) <EOL> elif opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> file_xml = arg <EOL> server = CoAPReverseProxy ( ip , port , file_xml ) <EOL> try : <EOL> server . listen ( <NUM_LIT:10> ) <EOL> except KeyboardInterrupt : <EOL> print "<STR_LIT>" <EOL> server . close ( ) <EOL> print "<STR_LIT>" <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( sys . argv [ <NUM_LIT:1> : ] ) </s>
