<s> """<STR_LIT>""" <EOL> import sys <EOL> from flask import current_app <EOL> from website . services import exec_command <EOL> def exchange_maskint ( mask_int ) : <EOL> bin_arr = [ '<STR_LIT:0>' for i in range ( <NUM_LIT:32> ) ] <EOL> for i in xrange ( mask_int ) : <EOL> bin_arr [ i ] = '<STR_LIT:1>' <EOL> tmpmask = [ '<STR_LIT>' . join ( bin_arr [ i * <NUM_LIT:8> : i * <NUM_LIT:8> + <NUM_LIT:8> ] ) for i in range ( <NUM_LIT:4> ) ] <EOL> tmpmask = [ str ( int ( tmpstr , <NUM_LIT:2> ) ) for tmpstr in tmpmask ] <EOL> return '<STR_LIT:.>' . join ( tmpmask ) <EOL> def get_localhost_ip ( ) : <EOL> cmd = [ '<STR_LIT>' ] <EOL> eth_ip = { } <EOL> try : <EOL> r = exec_command ( cmd ) <EOL> except : <EOL> current_app . logger . error ( '<STR_LIT>' , cmd , <EOL> sys . exc_info ( ) [ <NUM_LIT:1> ] ) <EOL> return False <EOL> if r [ '<STR_LIT>' ] == <NUM_LIT:0> : <EOL> r_data = r [ '<STR_LIT>' ] . split ( '<STR_LIT:\n>' ) <EOL> for index , line in enumerate ( r_data ) : <EOL> if line . startswith ( '<STR_LIT>' ) : <EOL> eth_ip [ r_data [ index - <NUM_LIT:1> ] . split ( ) [ <NUM_LIT:0> ] ] = line . split ( ) . split ( '<STR_LIT::>' ) [ <NUM_LIT:1> ] <EOL> else : <EOL> current_app . logger . error ( '<STR_LIT>' , cmd , <EOL> r [ '<STR_LIT>' ] , r [ '<STR_LIT>' ] ) <EOL> return False <EOL> return eth_ip </s>
