1# eventlib - Copyright (c) 2012 Yipit, Inc 2# 3# This program is free software: you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation, either version 3 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16from logan.runner import run_app 17 18import base64 19import os 20 21KEY_LENGTH = 40 22 23CONFIG_TEMPLATE = """ 24import os.path 25 26CONF_ROOT = os.path.dirname(__file__) 27 28CELERY_ALWAYS_EAGER = True 29CELERY_EAGER_PROPAGATES_EXCEPTIONS = True 30 31INSTALLED_APPS = ( 32 'eventlib', 33) 34 35REDIS_CONNECTIONS = { 36 'default': { 37 'HOST': 'localhost', 38 'PORT': 6379, 39 }, 40} 41""" 42 43 44def generate_settings(): 45 """ 46 This command is run when ``default_path`` doesn't exist, or ``init`` is 47 run and returns a string representing the default data to put into their 48 settings file. 49 """ 50 output = CONFIG_TEMPLATE % dict( 51 default_key=base64.b64encode(os.urandom(KEY_LENGTH)), 52 ) 53 54 return output 55 56 57def main(): 58 run_app( 59 project='eventlib', 60 default_config_path='~/.eventlib/', 61 settings_initializer=generate_settings, 62 settings_envvar='EVENTLIB_CONF', 63 ) 64 65if __name__ == '__main__': 66 main() 67