Esempio n. 1
0
def load_fixtures(fixtures):
    stream = StringIO()
    error_stream = StringIO()
    loaddata = LoadData()
    loaddata.style = no_style()
    loaddata.execute(*fixtures, **{
        'stdout': stream,
        'stderr': error_stream,
        'ignore': True,
        'database': DEFAULT_DB_ALIAS,
        'verbosity': 1
    })
    return loaddata.loaded_object_count
Esempio n. 2
0
def load_fixtures(fixtures):
    stream = StringIO()
    error_stream = StringIO()
    loaddata = LoadData()
    loaddata.style = no_style()
    loaddata.execute(
        *fixtures, **{
            'stdout': stream,
            'stderr': error_stream,
            'ignore': True,
            'database': DEFAULT_DB_ALIAS,
            'verbosity': 1
        })
    return loaddata.loaded_object_count
Esempio n. 3
0
File: utils.py Progetto: t0in4/exgit
def load_fixtures(fixtures):
    stream = StringIO()
    error_stream = StringIO()
    loaddata = LoadData()
    loaddata.style = no_style()
    loaddata.execute(*fixtures, **{
        'stdout': stream,
        'stderr': error_stream,
        'ignore': True,
        'database': DEFAULT_DB_ALIAS,
        'verbosity': 1
    })
    if hasattr(loaddata, 'loaded_object_count'):
        return loaddata.loaded_object_count
    else:
        # Django < 1.6 has no loaded_object_count attribute, we need
        # to fetch it from stderror :(
        errors = error_stream.getvalue()
        out = stream.getvalue()
        if errors:
            # The only way to handle errors in Django 1.4 is to inspect stdout
            raise CommandError(errors.strip().splitlines()[-1])
        return int(re.search('Installed ([0-9]+)', out.strip()).group(1))
Esempio n. 4
0
def load_fixtures(fixtures):
    stream = StringIO()
    error_stream = StringIO()
    loaddata = LoadData()
    loaddata.style = no_style()
    loaddata.execute(
        *fixtures, **{
            'stdout': stream,
            'stderr': error_stream,
            'ignore': True,
            'database': DEFAULT_DB_ALIAS,
            'verbosity': 1
        })
    if hasattr(loaddata, 'loaded_object_count'):
        return loaddata.loaded_object_count
    else:
        # Django < 1.6 has no loaded_object_count attribute, we need
        # to fetch it from stderror :(
        errors = error_stream.getvalue()
        out = stream.getvalue()
        if errors:
            # The only way to handle errors in Django 1.4 is to inspect stdout
            raise CommandError(errors.strip().splitlines()[-1])
        return int(re.search('Installed ([0-9]+)', out.strip()).group(1))