<s> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> import logging <EOL> from ConfigParser import ConfigParser <EOL> log = logging . getLogger ( __name__ ) <EOL> config_fields = { } <EOL> config_fields [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> config_fields [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> config_fields [ '<STR_LIT>' ] = <NUM_LIT:8> <EOL> config_fields [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> config_fields [ '<STR_LIT>' ] = '<STR_LIT:127.0.0.1>' <EOL> config_fields [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> config_fields [ '<STR_LIT>' ] = '<STR_LIT:127.0.0.1>' <EOL> config_fields [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> config_fields [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> config_fields [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> config_fields [ '<STR_LIT>' ] = '<STR_LIT:/>' <EOL> config_fields [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> config_fields [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> config_fields [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> config_fields [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> config_fields [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> config_fields [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> def ReadConfig ( config_file = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> global config_fields <EOL> config = ConfigParser ( ) <EOL> section = "<STR_LIT>" <EOL> if os . path . exists ( config_file ) : <EOL> try : <EOL> with open ( config_file , '<STR_LIT:r>' ) as cfg : <EOL> config . readfp ( cfg ) <EOL> except IOError , e : <EOL> log . error ( "<STR_LIT>" + str ( e ) ) <EOL> else : <EOL> config . add_section ( section ) <EOL> for key in config_fields . keys ( ) : <EOL> config . set ( section , key , config_fields [ key ] ) <EOL> try : <EOL> with open ( config_file , '<STR_LIT:w>' ) as cfg : <EOL> config . write ( cfg ) <EOL> except IOError : <EOL> pass <EOL> cfg = { } <EOL> for key in config_fields . keys ( ) : <EOL> try : <EOL> cfg [ key ] = config . get ( section , key ) <EOL> except Exception : <EOL> cfg [ key ] = config_fields [ key ] <EOL> return cfg </s>
