__main__.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2015, 2016 OpenMarket Ltd
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. from synapse.config._base import ConfigError
  16. if __name__ == "__main__":
  17. import sys
  18. from homeserver import HomeServerConfig
  19. action = sys.argv[1]
  20. if action == "read":
  21. key = sys.argv[2]
  22. try:
  23. config = HomeServerConfig.load_config("", sys.argv[3:])
  24. except ConfigError as e:
  25. sys.stderr.write("\n" + e.message + "\n")
  26. sys.exit(1)
  27. print (getattr(config, key))
  28. sys.exit(0)
  29. else:
  30. sys.stderr.write("Unknown command %r\n" % (action,))
  31. sys.exit(1)