def handle(self, *args, **options):

        skipped_paths = []

        if len(args) > 0:
            app_names = args[0]
            if not isinstance(app_names, list):
                app_names = app_names.split(',')

                _apps = []
                for app_name in app_names:
                    try:
                        app = apps.get_app_config(app_name)
                    except Exception as e:
                        skipped_paths(app_name)
                    else:
                        _apps.append(app.path)
        else:
            _apps = apps.get_app_paths()

        for app_path in _apps:
            try:
                os.chdir(app_path)
                call_command('makemessages')
                call_command('compilemessages')
            except Exception as e:
                skipped_paths.append(app_path)
                self.stderr.write(str(e))

        if skipped_paths:
            self.stderr.write('Skipped paths: \n%s' % '\n'.join(skipped_paths))
        self.stdout.write('Successfully generated and compiled all messages')
Ejemplo n.º 2
0
def django_present():
    global django

    try:
        sys.path.append(config.project_path)
        sys.path.append(config.apps_path)
        os.environ.setdefault('DJANGO_SETTINGS_MODULE', config.project_name +
                              '.settings')  # 'eracks.settings')
        print 'ENVIRON', pformat(os.environ)
        import django as dj
        dj.setup()
        from django.conf import settings
        from django.apps import apps
        app_paths = [
            p for p in apps.get_app_paths()
            if p.startswith(config.apps_path) and not p.startswith(my_path)
        ]
        if trace: pprint(app_paths)
        django.update(
            settings=settings,
            apps=apps,
            app_paths=app_paths,
        )
        return True
    except:
        print 'Django not present.'
Ejemplo n.º 3
0
    def handle(self, *args, **options):

        skipped_paths = []

        if len(args) > 0:
            app_names = args[0]
            if not isinstance(app_names, list):
                app_names = app_names.split(',')

                _apps = []
                for app_name in app_names:
                    try:
                        app = apps.get_app_config(app_name)
                    except Exception as e:
                        skipped_paths(app_name)
                    else:
                        _apps.append(app.path)
        else:
            _apps = apps.get_app_paths()

        for app_path in _apps:
            try:
                os.chdir(app_path)
                call_command('makemessages')
                call_command('compilemessages')
            except Exception as e:
                skipped_paths.append(app_path)
                self.stderr.write(str(e))

        if skipped_paths:
            self.stderr.write('Skipped paths: \n%s' % '\n'.join(skipped_paths))
        self.stdout.write('Successfully generated and compiled all messages')
Ejemplo n.º 4
0
def update_config(kv):
    global config, templates_path

    config.update(kv)
    #if trace: print 'Config keys:', config.keys()

    # could do inject_locals or inject_globals, here
    theme_name = config['theme_name']
    theme_url = config['theme_url']
    download = config.get('download', 0)  # optional
    templates_path = config['templates_path']
    theme_downloaded_path = config['theme_downloaded_path']

    static_link = os.path.join(static_path, theme_name)
    templates_path = Template(templates_path).safe_substitute(config)
    theme_downloaded_path = Template(theme_downloaded_path).safe_substitute(
        config)

    config.update(
        static_link=static_link,
        templates_path=templates_path,
        theme_downloaded_path=theme_downloaded_path,
    )

    if trace:
        print 'Config:',
        pprint(config)

    # This should be moved to a linkstatic management command:
    # Also see the README in the stheme/static dir, and the theme's assets/css dirs
    # these links should be relative, not absolute, see test_relpath.py - or at least don't overwrite them if they are there already
    if not os.path.exists(static_link) and not os.path.islink(static_link):
        os.symlink(theme_downloaded_path, static_link)

    try:
        sys.path.append(project_path)
        sys.path.append(apps_path)
        os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'eracks.settings')
        import django
        django.setup()
        from django.conf import settings as django_settings
        from django.apps import apps as django_apps
        django_app_paths = [
            p for p in django_apps.get_app_paths()
            if p.startswith(apps_path) and not p.startswith(my_path)
        ]
        if trace: pprint(django_app_paths)
        django_present = 1
    except:
        django_present = 0

    if download:
        raise Exception('Deprecated - use cached url instead')
Ejemplo n.º 5
0
def update_config (kv):
  global config, templates_path

  config.update (kv)
  if trace: print 'Config keys:', config.keys(), kv

  # could do inject_locals or inject_globals, here
  theme_name            = config ['theme_name']
  #theme_url            = config ['theme_url']
  download              = config.get ('download', 0)  # optional
  templates_path        = config ['templates_path']
  theme_path            = config ['theme_path']

  static_link           = os.path.join (static_path, theme_name) if theme_name else ''
  templates_path        = Template (templates_path).safe_substitute (config)
  theme_path            = Template (theme_path).safe_substitute (config)

  config.update (
    static_link         = static_link,
    templates_path      = templates_path,
    theme_path          = theme_path,
  )

  if trace: print 'Config:', ; pprint (config)

  # This should be moved to a linkstatic management command:
  # Also see the README in the stheme/static dir, and the theme's assets/css dirs
  # these links should be relative, not absolute, see test_relpath.py - or at least don't overwrite them if they are there already
  if theme_path and static_link and os.path.exists (static_link) and not os.path.islink (static_link):
    os.symlink (theme_path, static_link)

  try:
    sys.path.append (project_path)
    sys.path.append (apps_path)
    os.environ.setdefault ('DJANGO_SETTINGS_MODULE', 'eracks.settings')
    import django
    django.setup()
    from django.conf import settings as django_settings
    from django.apps import apps as django_apps
    django_app_paths = [p for p in django_apps.get_app_paths()
                        if p.startswith (apps_path) and not p.startswith (my_path)]
    if trace: pprint (django_app_paths)
    django_present = 1
  except:
    django_present = 0

  if download:
    raise Exception ('Deprecated - use cached url instead')
Ejemplo n.º 6
0
Archivo: engine.py Proyecto: jowolf/tlg
def django_present():
  global django

  try:
    sys.path.append (config.project_path)
    sys.path.append (config.apps_path)
    os.environ.setdefault ('DJANGO_SETTINGS_MODULE', config.project_name + '.settings')  # 'eracks.settings')
    print 'ENVIRON', pformat (os.environ)
    import django as dj
    dj.setup()
    from django.conf import settings
    from django.apps import apps
    app_paths = [p for p in apps.get_app_paths() if p.startswith (config.apps_path) and not p.startswith (my_path)]
    if trace: pprint (app_paths)
    django.update (
      settings = settings,
      apps = apps,
      app_paths = app_paths,
    )
    return True
  except:
    print 'Django not present.'
Ejemplo n.º 7
0
else:
    django.setup = lambda: False

    from django.apps.registry import apps

    apps.apps_ready = True
    settings = []

from django.conf import global_settings
from django.core.exceptions import ImproperlyConfigured, AppRegistryNotReady
from django.db.models.query import QuerySet

print('@@apppaths')
try:
    for path in apps.get_app_paths():
        print('##%s' % path)
except AppRegistryNotReady:
    pass

try:
    from django.conf import settings as djsettings
    tpldirs = set(getattr(djsettings, 'TEMPLATE_DIRS', []))
    if not isinstance(tpldirs, set):
        tpldirs = set()

    for tplconf in getattr(djsettings, 'TEMPLATES', []):
        if 'DIRS' in tplconf:
            tpldirs.update(tplconf['DIRS'])

    for tpldir in tpldirs: