@@ -25,18 +25,29 @@ class ConfigError(Exception):
2525 pass
2626
2727
28- class Config (object ):
28+ # We split these messages out to allow packages to override with package
29+ # specific instructions.
30+ MISSING_REPORT_STATS_CONFIG_INSTRUCTIONS = """\
31+ Please opt in or out of reporting anonymized homeserver usage statistics, by
32+ setting the `report_stats` key in your config file to either True or False.
33+ """
34+
35+ MISSING_REPORT_STATS_SPIEL = """\
36+ We would really appreciate it if you could help our project out by reporting
37+ anonymized usage statistics from your homeserver. Only very basic aggregate
38+ data (e.g. number of users) will be reported, but it helps us to track the
39+ growth of the Matrix community, and helps us to make Matrix a success, as well
40+ as to convince other networks that they should peer with us.
41+
42+ Thank you.
43+ """
44+
45+ MISSING_SERVER_NAME = """\
46+ Missing mandatory `server_name` config option.
47+ """
2948
30- stats_reporting_begging_spiel = (
31- "We would really appreciate it if you could help our project out by"
32- " reporting anonymized usage statistics from your homeserver. Only very"
33- " basic aggregate data (e.g. number of users) will be reported, but it"
34- " helps us to track the growth of the Matrix community, and helps us to"
35- " make Matrix a success, as well as to convince other networks that they"
36- " should peer with us."
37- "\n Thank you."
38- )
3949
50+ class Config (object ):
4051 @staticmethod
4152 def parse_size (value ):
4253 if isinstance (value , int ) or isinstance (value , long ):
@@ -215,7 +226,7 @@ def load_config(cls, description, argv, generate_section=None):
215226 if config_args .report_stats is None :
216227 config_parser .error (
217228 "Please specify either --report-stats=yes or --report-stats=no\n \n " +
218- cls . stats_reporting_begging_spiel
229+ MISSING_REPORT_STATS_SPIEL
219230 )
220231 if not config_files :
221232 config_parser .error (
@@ -290,6 +301,10 @@ def load_config(cls, description, argv, generate_section=None):
290301 yaml_config = cls .read_config_file (config_file )
291302 specified_config .update (yaml_config )
292303
304+ if "server_name" not in specified_config :
305+ sys .stderr .write ("\n " + MISSING_SERVER_NAME + "\n " )
306+ sys .exit (1 )
307+
293308 server_name = specified_config ["server_name" ]
294309 _ , config = obj .generate_config (
295310 config_dir_path = config_dir_path ,
@@ -299,11 +314,8 @@ def load_config(cls, description, argv, generate_section=None):
299314 config .update (specified_config )
300315 if "report_stats" not in config :
301316 sys .stderr .write (
302- "Please opt in or out of reporting anonymized homeserver usage "
303- "statistics, by setting the report_stats key in your config file "
304- " ( " + config_path + " ) " +
305- "to either True or False.\n \n " +
306- Config .stats_reporting_begging_spiel + "\n " )
317+ "\n " + MISSING_REPORT_STATS_CONFIG_INSTRUCTIONS + "\n " +
318+ MISSING_REPORT_STATS_SPIEL + "\n " )
307319 sys .exit (1 )
308320
309321 if generate_keys :
0 commit comments