<s> import sys <EOL> from ConfigParser import SafeConfigParser , NoOptionError , NoSectionError <EOL> from graph_explorer . validation import ConfigValidator <EOL> class DummyConfigParser ( object ) : <EOL> def __getattr__ ( self , name ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> parser = DummyConfigParser ( ) <EOL> file_name = "<STR_LIT>" <EOL> def init ( filename ) : <EOL> global parser , config , file_name <EOL> file_name = filename <EOL> parser = SafeConfigParser ( ) <EOL> parser . readfp ( open ( filename ) ) <EOL> config = sys . modules [ __name__ ] <EOL> def get ( section , option ) : <EOL> try : <EOL> return parser . get ( section , option ) <EOL> except ( NoOptionError , NoSectionError ) : <EOL> pass <EOL> return None <EOL> def getlist ( section , option ) : <EOL> try : <EOL> list_str = parser . get ( section , option ) <EOL> return list_str . splitlines ( ) <EOL> except ( NoOptionError , NoSectionError ) : <EOL> pass <EOL> return None <EOL> def getint ( section , option ) : <EOL> try : <EOL> return parser . getint ( section , option ) <EOL> except ( NoOptionError , NoSectionError ) : <EOL> pass <EOL> return None <EOL> def getboolean ( section , option ) : <EOL> try : <EOL> return parser . getboolean ( section , option ) <EOL> except ( NoOptionError , NoSectionError ) : <EOL> pass <EOL> return None <EOL> config . listen_host = get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . listen_port = getint ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . filename_metrics = get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . log_file = get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . graphite_url_server = get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . graphite_url_client = get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . graphite_username = get ( "<STR_LIT>" , "<STR_LIT:username>" ) or None <EOL> config . graphite_password = get ( "<STR_LIT>" , "<STR_LIT:password>" ) or None <EOL> config . anthracite_host = get ( "<STR_LIT>" , "<STR_LIT:host>" ) or None <EOL> config . anthracite_port = getint ( "<STR_LIT>" , "<STR_LIT:port>" ) or <NUM_LIT> <EOL> config . anthracite_index = get ( "<STR_LIT>" , "<STR_LIT:index>" ) or None <EOL> config . anthracite_add_url = get ( "<STR_LIT>" , "<STR_LIT>" ) or None <EOL> config . locations_plugins_structured_metrics = getlist ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . locations_dashboards = getlist ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . es_host = get ( "<STR_LIT>" , "<STR_LIT:host>" ) <EOL> config . es_port = getint ( "<STR_LIT>" , "<STR_LIT:port>" ) <EOL> config . es_index = get ( "<STR_LIT>" , "<STR_LIT:index>" ) <EOL> config . limit_es_metrics = getint ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . process_native_proto2 = getboolean ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . alerting = getboolean ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . alerting_db = get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . alerting_smtp = get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . alerting_from = get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . alert_backoff = getint ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . alerting_base_uri = get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . collectd_StoreRates = getboolean ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> config . collectd_prefix = get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> def valid_or_die ( ) : <EOL> global config , file_name <EOL> config = sys . modules [ __name__ ] <EOL> c = ConfigValidator ( obj = config ) <EOL> if c . validate ( ) : <EOL> return <EOL> print "<STR_LIT>" % file_name <EOL> for ( key , err ) in c . errors . items ( ) : <EOL> print key , <EOL> for e in err : <EOL> print "<STR_LIT>" % e <EOL> sys . exit ( <NUM_LIT:1> ) </s>
