summary refs log tree commit diff
path: root/synapse/config/_base.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-05-05 18:15:20 +0100
committerErik Johnston <erik@matrix.org>2015-05-05 18:15:20 +0100
commited2584050f4dc1e09f7e29735bbf89686e0fe04d (patch)
tree0f71510eb24eb9168b48a7b5e0a5ae946a06685d /synapse/config/_base.py
parentAdd a comment about the zip(*[zip(sorted(...),...)]) (diff)
parentUse buffer(...) when inserting into bytea column (diff)
downloadsynapse-ed2584050f4dc1e09f7e29735bbf89686e0fe04d.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/executemany
Diffstat (limited to 'synapse/config/_base.py')
-rw-r--r--synapse/config/_base.py47
1 files changed, 29 insertions, 18 deletions
diff --git a/synapse/config/_base.py b/synapse/config/_base.py
index cd4bd28e8c..2807abbc90 100644
--- a/synapse/config/_base.py
+++ b/synapse/config/_base.py
@@ -144,16 +144,17 @@ class Config(object):
         )
         config_args, remaining_args = config_parser.parse_known_args(argv)
 
-        if not config_args.config_path:
-            config_parser.error(
-                "Must supply a config file.\nA config file can be automatically"
-                " generated using \"--generate-config -h SERVER_NAME"
-                " -c CONFIG-FILE\""
-            )
-
-        config_dir_path = os.path.dirname(config_args.config_path[0])
-        config_dir_path = os.path.abspath(config_dir_path)
         if config_args.generate_config:
+            if not config_args.config_path:
+                config_parser.error(
+                    "Must supply a config file.\nA config file can be automatically"
+                    " generated using \"--generate-config -h SERVER_NAME"
+                    " -c CONFIG-FILE\""
+                )
+
+            config_dir_path = os.path.dirname(config_args.config_path[0])
+            config_dir_path = os.path.abspath(config_dir_path)
+
             server_name = config_args.server_name
             if not server_name:
                 print "Most specify a server_name to a generate config for."
@@ -196,6 +197,25 @@ class Config(object):
             )
             sys.exit(0)
 
+        parser = argparse.ArgumentParser(
+            parents=[config_parser],
+            description=description,
+            formatter_class=argparse.RawDescriptionHelpFormatter,
+        )
+
+        obj.invoke_all("add_arguments", parser)
+        args = parser.parse_args(remaining_args)
+
+        if not config_args.config_path:
+            config_parser.error(
+                "Must supply a config file.\nA config file can be automatically"
+                " generated using \"--generate-config -h SERVER_NAME"
+                " -c CONFIG-FILE\""
+            )
+
+        config_dir_path = os.path.dirname(config_args.config_path[0])
+        config_dir_path = os.path.abspath(config_dir_path)
+
         specified_config = {}
         for config_path in config_args.config_path:
             yaml_config = cls.read_config_file(config_path)
@@ -208,15 +228,6 @@ class Config(object):
 
         obj.invoke_all("read_config", config)
 
-        parser = argparse.ArgumentParser(
-            parents=[config_parser],
-            description=description,
-            formatter_class=argparse.RawDescriptionHelpFormatter,
-        )
-
-        obj.invoke_all("add_arguments", parser)
-        args = parser.parse_args(remaining_args)
-
         obj.invoke_all("read_arguments", args)
 
         return obj