Exemple #1
0
def config_location():
    '''
    Returns the default location for the settings file and the data folder
    '''
    print('Default locations:')
    print('* settings:      {0}'.format(get_user_config_path('wger', 'settings.py')))
    print('* media folder:  {0}'.format(get_user_data_path('wger', 'media')))
    print('* database path: {0}'.format(get_user_data_path('wger', 'database.sqlite')))
Exemple #2
0
def create_settings(settings_path=None,
                    database_path=None,
                    url=None,
                    database_type='sqlite3',
                    key_length=50):
    '''
    Creates a local settings file
    '''
    if settings_path is None:
        settings_path = get_user_config_path('wger', 'settings.py')

    settings_module = os.path.dirname(settings_path)
    print("*** Creating settings file at {0}".format(settings_module))

    if database_path is None:
        database_path = get_user_data_path('wger', 'database.sqlite')
    dbpath_value = repr(database_path)

    media_folder_path = repr(get_user_data_path('wger', 'media'))

    # Use localhost with default django port if no URL given
    if url is None:
        url = 'http://*****:*****@#$%^&*(-_=+)')

    settings_content = settings_content.format(
        dbname=dbname,
        dbpath=dbpath_value,
        dbengine=dbengine,
        dbuser=dbuser,
        dbpassword=dbpassword,
        dbhost=dbhost,
        dbport=dbport,
        default_key=secret_key,
        siteurl=url,
        media_folder_path=media_folder_path)

    if not os.path.exists(settings_module):
        os.makedirs(settings_module)

    if not os.path.exists(os.path.dirname(database_path)):
        os.makedirs(os.path.dirname(database_path))

    with open(settings_path, 'w') as settings_file:
        settings_file.write(settings_content)
Exemple #3
0
def create_settings(settings_path=None, database_path=None, url=None, database_type='sqlite3', key_length=50):
    '''
    Creates a local settings file
    '''
    if settings_path is None:
        settings_path = get_user_config_path('wger', 'settings.py')

    settings_module = os.path.dirname(settings_path)
    print("*** Creating settings file at {0}".format(settings_module))

    if database_path is None:
        database_path = get_user_data_path('wger', 'database.sqlite')
    dbpath_value = repr(database_path)

    media_folder_path = repr(get_user_data_path('wger', 'media'))

    # Use localhost with default django port if no URL given
    if url is None:
        url = 'http://*****:*****@#$%^&*(-_=+)')

    settings_content = settings_content.format(dbname=dbname,
                                               dbpath=dbpath_value,
                                               dbengine=dbengine,
                                               dbuser=dbuser,
                                               dbpassword=dbpassword,
                                               dbhost=dbhost,
                                               dbport=dbport,
                                               default_key=secret_key,
                                               siteurl=url,
                                               media_folder_path=media_folder_path)

    if not os.path.exists(settings_module):
        os.makedirs(settings_module)

    if not os.path.exists(os.path.dirname(database_path)):
        os.makedirs(os.path.dirname(database_path))

    with open(settings_path, 'w') as settings_file:
        settings_file.write(settings_content)