Esempio n. 1
0
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

import importlib
import os
import sys
import threading

from future import standard_library

from cartoview.log_handler import get_logger

logger = get_logger(__name__, with_formatter=True)
lock = threading.Lock()
standard_library.install_aliases()

# BASE_DIR must be defined in project.settings

CARTOVIEW_APPS = ()
APPS_SETTINGS = []


def load_apps(APPS_DIR):
    with lock:
        from cartoview.apps_handler.utils import create_apps_dir
        from cartoview.apps_handler.config import CartoviewApp
        global CARTOVIEW_APPS
        global APPS_SETTINGS
        create_apps_dir(APPS_DIR)
        if APPS_DIR not in sys.path:
Esempio n. 2
0
import importlib

from django.core.management.base import BaseCommand
from geonode.people.models import Profile

from cartoview.app_manager.models import App, AppType
from cartoview.apps_handler.config import CartoviewApp
from cartoview.log_handler import get_logger

logger = get_logger(with_formatter=True)


class Command(BaseCommand):
    help = 'Update existing apps'

    def handle(self, *args, **options):
        carto_apps = CartoviewApp.objects.get_active_apps().values()
        user = Profile.objects.filter(is_superuser=True).first()
        for carto_app in carto_apps:
            app_name = carto_app.name
            query = App.objects.filter(name=app_name)
            if query.count() == 0:
                try:
                    # ensure that the folder is python module
                    importlib.import_module(app_name)
                    app = App(title=app_name,
                              name=app_name,
                              status="Alpha",
                              license=None,
                              version='1.0.0',
                              installed_by=user,
Esempio n. 3
0
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

import importlib
import os
import sys

from future import standard_library
from past.builtins import execfile

from cartoview.app_manager.config import AppsConfig
from cartoview.app_manager.helpers import (change_path_permission,
                                           create_direcotry)
from cartoview.log_handler import get_logger

logger = get_logger(__name__)

standard_library.install_aliases()

# BASE_DIR must be defined in project.settings


def create_apps_dir(APPS_DIR):
    if not os.path.exists(APPS_DIR):
        create_direcotry(APPS_DIR)
        if not os.access(APPS_DIR, os.W_OK):
            change_path_permission(APPS_DIR)


def load_apps(APPS_DIR):
    create_apps_dir(APPS_DIR)
Esempio n. 4
0
 def test_get_logger(self):
     logger = get_logger(__name__)
     self.assertEqual(isinstance(logger, Logger), True)
     self.assertEqual(logger.name, __name__)
     self.assertEqual(logger.level, DEBUG)