Error on importing from seahub.utils


#1

We are using a custom script to check office-convert functionality. Since updating to 6.3.13 we are facing an issue while importing. We are calling the python script with this modified bash-script:

  #!/bin/bash

SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "${SCRIPT}")
TOPDIR=$(dirname "${SCRIPTPATH}")
INSTALLPATH=${TOPDIR}/seafile-server-latest
default_ccnet_conf_dir=${TOPDIR}/ccnet
default_seafile_data_dir=${TOPDIR}/seafile-data
default_conf_dir=${TOPDIR}/conf

pyscript=${SCRIPTPATH}/$(basename ${0%.sh}.py)

function check_python_executable() {
  if [[ "$PYTHON" != "" && -x $PYTHON ]]; then
      return 0
  fi
  if which python2.7 2>/dev/null 1>&2; then
      PYTHON=python2.7
  elif which python27 2>/dev/null 1>&2; then
      PYTHON=python27
  elif which python2.6 2>/dev/null 1>&2; then
      PYTHON=python2.6
  elif which python26 2>/dev/null 1>&2; then
      PYTHON=python26
  else
      echo
      echo "Can't find a python executable of version 2.6 or above in PATH"
      echo "Install python 2.6+ before continue."
      echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment varirable to it"
      echo
      exit 1
  fi
}

check_python_executable;

# running script
export CCNET_CONF_DIR=${default_ccnet_conf_dir}
export SEAFILE_CONF_DIR=${default_seafile_data_dir}
export SEAFILE_CENTRAL_CONF_DIR=${default_conf_dir}

export PYTHONPATH=${INSTALLPATH}/seafile/lib/python2.6/site-packages:${INSTALLPATH}/seafile/lib64/python2.6/site-packages:${INSTALLPATH
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python2.7/site-packages:${INSTALLPATH}/seafile/lib64/python2.7/site-packages:$PYTHONPATH

export PYTHONPATH=${INSTALLPATH}/seahub:${INSTALLPATH}/seahub-extra:${INSTALLPATH}/pro:${INSTALLPATH}/pro/python:$PYTHONPATH

export DJANGO_SETTINGS_MODULE=seahub.settings

$PYTHON ${pyscript} $@

beginning of python-script:

#!/usr/bin/env python
# coding: utf-8

from seaserv import seafile_api
import time
import pro

import os
import sys

os.environ.update(pro.get_seafes_env())

from seahub.utils import delegate_query_office_convert_status, gen_file_get_url, gen_inner_file_get_url, add_office_convert_task

Error:

Traceback (most recent call last):
  File "/data/seafile/scripts/office_check.py", line 13, in <module>
    from seahub.utils import delegate_query_office_convert_status, gen_file_get_url, gen_inner_file_get_url, add_office_convert_task
  File "/data/seafile/seafile-server-latest/seahub/seahub/utils/__init__.py", line 35, in <module>
    from seahub.api2.models import Token, TokenV2
  File "/data/seafile/seafile-server-latest/seahub/seahub/api2/models.py", line 15, in <module>
    class Token(models.Model):
  File "/data/seafile/seafile-server-latest/seahub/thirdpart/django/db/models/base.py", line 110, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/data/seafile/seafile-server-latest/seahub/thirdpart/django/apps/registry.py", line 247, in get_containing_app_config
    self.check_apps_ready()
  File "/data/seafile/seafile-server-latest/seahub/thirdpart/django/apps/registry.py", line 125, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

Anybody else having this problem?

Thanks!


#2

Found the missing hint at:

Added:

import django
django.setup()