You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.1 KiB

  1. #!/usr/bin/python
  2. #-*- coding: utf-8 -*-
  3. # Copyright 2010 Calculate Ltd. http://www.calculate-linux.org
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. import sys
  17. import os
  18. sys.path.insert(0,os.path.abspath('/usr/lib/calculate-2.2/calculate-lib/pym'))
  19. sys.path.insert(0,\
  20. os.path.abspath('/usr/lib/calculate-2.2/calculate-ldap/pym'))
  21. from cl_ldap_setup_cmd import ldap_setup_cmd
  22. from cl_lang import lang
  23. tr = lang()
  24. tr.setGlobalDomain('cl_ldap')
  25. tr.setLanguage(sys.modules[__name__])
  26. if __name__ == "__main__":
  27. obj = ldap_setup_cmd()
  28. ret = obj.optobj.parse_args()
  29. if ret is False:
  30. sys.exit(1)
  31. opts, args = ret
  32. # Установка цвета при печати сообщений
  33. obj.setPrintNoColor(opts)
  34. # Установка переменных
  35. if not obj.setVars(opts):
  36. sys.exit(1)
  37. # Печать переменных
  38. obj.printVars(opts)
  39. # Если нет печати переменных выполняем логику программы
  40. if not opts.v and not opts.filter and not opts.xml:
  41. if not filter(lambda x: x[1], obj.optobj.values.__dict__.items()):
  42. # Setup
  43. if not obj.setup():
  44. sys.exit(1)
  45. elif opts.f:
  46. # Force setup
  47. if not obj.setup(force=True):
  48. sys.exit(1)
  49. elif opts.install:
  50. # Install
  51. if not obj.install():
  52. sys.exit(1)
  53. elif opts.uninstall:
  54. # Uninstall
  55. if not obj.uninstall():
  56. sys.exit(1)
  57. # Запись переменных
  58. if not obj.writeVars(opts):
  59. sys.exit(1)
  60. sys.exit(0)