hooks/post_gen_project.py
changeset 15 c3dbfc6488c2
parent 8 8ab3fffe8d36
equal deleted inserted replaced
14:42a3268863b6 15:c3dbfc6488c2
    24         with open(os.path.join(root, filename), 'w') as f:
    24         with open(os.path.join(root, filename), 'w') as f:
    25             f.write(content)
    25             f.write(content)
    26 
    26 
    27 
    27 
    28 #
    28 #
    29 # Check for logs directory
    29 # Check user and group
    30 #
    30 #
    31 
    31 
    32 user = '{{ cookiecutter.run_user }}'
    32 user = '{{ cookiecutter.run_user }}'
    33 user_id = getpwnam(user).pw_uid
    33 user_id = getpwnam(user).pw_uid
    34 
    34 
    35 group = '{{ cookiecutter.run_group }}'
    35 group = '{{ cookiecutter.run_group }}'
    36 group_id = getgrnam(group).gr_gid
    36 group_id = getgrnam(group).gr_gid
    37 
    37 
       
    38 
       
    39 #
       
    40 # Check for logs directory
       
    41 #
    38 
    42 
    39 LOGS_DIRECTORY = '{{ cookiecutter.logs_directory }}'
    43 LOGS_DIRECTORY = '{{ cookiecutter.logs_directory }}'
    40 
    44 
    41 if not os.path.exists(LOGS_DIRECTORY):
    45 if not os.path.exists(LOGS_DIRECTORY):
    42     try:
    46     try:
    80 # Make binary scripts executable
    84 # Make binary scripts executable
    81 #
    85 #
    82 
    86 
    83 BIN_DIRECTORY = os.path.join(TARGET, 'bin')
    87 BIN_DIRECTORY = os.path.join(TARGET, 'bin')
    84 
    88 
    85 for root, dirs, files in os.walk(VAR_DIRECTORY):
    89 for root, dirs, files in os.walk(BIN_DIRECTORY):
    86     for filename in files:
    90     for filename in files:
    87         try:
    91         try:
    88             target = os.path.join(BIN_DIRECTORY, root, filename)
    92             target = os.path.join(BIN_DIRECTORY, root, filename)
    89             os.chmod(target, 0o775)
    93             os.chmod(target, 0o775)
    90         except PermissionError:
    94         except PermissionError:
    94 print("\nYour ZEO environment is initialized.")
    98 print("\nYour ZEO environment is initialized.")
    95 print("To finalize it's creation, just type:")
    99 print("To finalize it's creation, just type:")
    96 print("- cd {{ cookiecutter.project_slug }}")
   100 print("- cd {{ cookiecutter.project_slug }}")
    97 print("- python3.5 bootstrap.py")
   101 print("- python3.5 bootstrap.py")
    98 print("- ./bin/buildout")
   102 print("- ./bin/buildout")
    99 
       
   100 
       
   101 {%- if cookiecutter.use_zeo_auth %}
       
   102 #
       
   103 # Initialize ZEO authentication file
       
   104 #
       
   105 
       
   106 cmd = os.path.join(TARGET, 'bin', 'zeopasswd')
       
   107 target = os.path.join(TARGET, 'etc', 'auth.db')
       
   108 print("\nTo initialize authentication database, please run following command after buildout:")
       
   109 print('{cmd} -f {target} -p digest -r "{{ cookiecutter.project_name }}" {{ cookiecutter.zeo_auth_user }} '
       
   110       '{{ cookiecutter.zeo_auth_password }}'.format(cmd=cmd, target=target))
       
   111 {%- endif %}