Ejemplo n.º 1
0
def create_apps_dir(apps_dir=getattr(settings, 'APPS_DIR', None)):
    if not apps_dir:
        project_dir = getattr(settings, 'BASE_DIR', settings.PROJECT_DIR)
        apps_dir = os.path.abspath(
            os.path.join(os.path.dirname(project_dir), "apps"))
    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)
Ejemplo n.º 2
0
def setup_apps(options):
    from cartoview.app_manager.helpers import (create_direcotry,
                                               change_path_permission)
    try:
        f = urlopen(TEST_DATA_URL)
        zip_ref = zipfile.ZipFile(BytesIO(f.read()))
        create_direcotry(APPS_DIR)
        if not os.access(APPS_DIR, os.W_OK):
            change_path_permission(APPS_DIR)
        zip_ref.extractall(APPS_DIR)
        zip_ref.close()
    except urllib2.HTTPError as e:
        print ("HTTP Error:", e.code)
    except urllib2.URLError as e:
        print ("URL Error:", e.reason)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
standard_library.install_aliases()

formatter = logging.Formatter(
    '[%(asctime)s] p%(process)s  { %(name)s %(pathname)s:%(lineno)d} \
                            %(levelname)s - %(message)s', '%m-%d %H:%M:%S')
logger = logging.getLogger(__name__)
handler = logging.StreamHandler(stdout)
handler.setFormatter(formatter)
logger.addHandler(handler)
# BASE_DIR must be defined in project.settings
APPS_DIR = os.path.abspath(os.path.join(BASE_DIR, "apps"))
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)
if APPS_DIR not in sys.path:
    sys.path.append(APPS_DIR)

apps_file_path = os.path.join(APPS_DIR, "apps.yml")
PENDING_APPS = os.path.join(APPS_DIR, "pendingOperation.yml")
apps_config = AppsConfig(apps_file_path)
CARTOVIEW_APPS = ()
for app_config in apps_config:
    if app_config.active:
        try:
            # ensure that the folder is python module
            app_module = importlib.import_module(app_config.name)
            app_dir = os.path.dirname(app_module.__file__)
            app_settings_file = os.path.join(app_dir, 'settings.py')
            if os.path.exists(app_settings_file):