Example #1
0
 def render(self, name, value, attrs=None):
     if value != '':
         value = _render_decimal(value, places=8)
     rendered = super(CurrencyWidget, self).render(name, value, attrs)
     curr = get_l10n_default_currency_symbol()
     curr = curr.replace("_", " ")
     return mark_safe('<span class="currency">%s</span>%s' % (curr, rendered))
Example #2
0
 def render(self, name, value, attrs=None):
     if value != '':
         value = _render_decimal(value, places=8)
     rendered = super(CurrencyWidget, self).render(name, value, attrs)
     curr = get_l10n_default_currency_symbol()
     curr = curr.replace("_", "&nbsp;")
     return mark_safe('<span class="currency">%s</span>%s' % (curr, rendered))
Example #3
0
 def render(self, name, value, **kwargs):
     value = _render_decimal(value, places=2)
     rendered = super(TruncatedCurrencyWidget,
                      self).render(name, value, **kwargs)
     curr = get_l10n_default_currency_symbol()
     curr = curr.replace("_", "&nbsp;")
     return mark_safe('<span class="currency">%s</span>%s' %
                      (curr, rendered))
Example #4
0
 def render(self, name, value, attrs=None):
     try:
         value = _render_decimal(value, places=2)
     except RoundedDecimalError:
         value = '0.0'
     rendered = super(TruncatedCurrencyWidget, self).render(name, value, attrs)
     curr = get_l10n_default_currency_symbol()
     curr = curr.replace("_", "&nbsp;")
     return mark_safe('<span class="currency">%s</span>%s' % (curr, rendered))
Example #5
0
 def render(self, name, value, attrs=None):
     try:
         value = _render_decimal(value, places=2)
     except RoundedDecimalError:
         value = '0.0'
     rendered = super(TruncatedCurrencyWidget,
                      self).render(name, value, attrs)
     curr = get_l10n_default_currency_symbol()
     curr = curr.replace("_", "&nbsp;")
     return mark_safe('<span class="currency">%s</span>%s' %
                      (curr, rendered))
Example #6
0
 except Exception, e:
     error_out("Can not use livesettings: %s" % e)
 else:
     # The function urlresolvers.reverse has its own way of error reporting to screen and we have no access
     # to it so that we call it only if basic preconditions are fulfilled.
     try:
         url = urlresolvers.reverse('satchmo_search')
         # Catch SystemExit, because if an error occurs, `urlresolvers` usually calls sys.exit() and other error
         # messages would be lost.
     except (Exception, SystemExit), e:
         error_out("Unable to resolve urls. Received error - %s" % formaterror(e))
 try:
     from l10n.l10n_settings import get_l10n_default_currency_symbol
 except Exception:
     pass
 if not isinstance(get_l10n_default_currency_symbol(), types.UnicodeType):
     error_out("Your currency symbol should be a unicode string.")
 if 'satchmo_store.shop.SSLMiddleware.SSLRedirect' not in settings.MIDDLEWARE_CLASSES:
     error_out("You must have satchmo_store.shop.SSLMiddleware.SSLRedirect in your MIDDLEWARE_CLASSES.")
 if 'satchmo_store.shop.context_processors.settings' not in settings.TEMPLATE_CONTEXT_PROCESSORS:
     error_out("You must have satchmo_store.shop.context_processors.settings in your "
             "TEMPLATE_CONTEXT_PROCESSORS.")
 if 'threaded_multihost.middleware.ThreadLocalMiddleware' not in settings.MIDDLEWARE_CLASSES:
     error_out("You must install 'django threaded multihost'\n"
             "and place 'threaded_multihost.middleware.ThreadLocalMiddleware' in your MIDDLEWARE_CLASSES.")
 if 'satchmo_store.accounts.email-auth.EmailBackend' not in settings.AUTHENTICATION_BACKENDS:
     error_out("You must have satchmo_store.accounts.email-auth.EmailBackend in your AUTHENTICATION_BACKENDS")
 if len(settings.SECRET_KEY) == 0:
     error_out("You must have SECRET_KEY set to a valid string in your settings.py file")
 python_ver = Decimal("%s.%s" % (sys.version_info[0], sys.version_info[1]))
 if python_ver < Decimal("2.4"):
Example #7
0
    def handle(self, **options):
        """Checks Satchmo installation and configuration.

        Tests, catches and shortly summarizes many common installation errors, without tracebacks.
        If was seen a traceback, it should be reported to a developer. (for now)
        Tracebacks are saved to the 'satchmo.log'. It helps to find cyclic dependencies etc.
        """
        from django.conf import settings
        global logged_more
        print_out("Checking your satchmo configuration.")
        try:
            import satchmo_store
        except ImportError:
            error_out(
                "Satchmo is not installed correctly. Please verify satchmo is on your sys path."
            )
        print("Using Django version %s" % django.get_version())
        print("Using Satchmo version %s" % satchmo_store.get_version())
        #Check the Django version
        #Make sure we only get the X.Y.Z version info and not any other alpha or beta designations
        version_check = LooseVersion(".".join(map(str, django.VERSION)[:3]))
        if version_check < LooseVersion("1.2.3"):
            error_out("Django version must be >= 1.2.3")

        # Store these checked installation paths also to the paths overview
        verbose_check_install('satchmo',
                              'satchmo_store',
                              verbose_name='Satchmo')

        verbose_check_install('django', 'django', '1.2.3')

        # Try importing all our dependencies
        verbose_check_install('',
                              'Crypto.Cipher',
                              verbose_name='The Python Cryptography Toolkit')
        try:
            import Image
            verbose_check_install('Image', 'Image')
            try:
                import PIL
                if os.path.dirname(Image.__file__) != os.path.dirname(
                        PIL.__file__):
                    # Circumstancies of the serious problem beeing threated are related to confused installations
                    # of virtualenv e.g. if virtual...env/site-packages/PIL is a link
                    # to /user/lib/python*/site-packages/PIL but if virtual...env/site-packages/PIL is not on python
                    # path or if it is written after /user/lib/python*/site-packages/PIL.
                    print_out("Packages 'Image' and 'PIL.Image' are found on different paths " \
                                    "which usually cause difficult AccessInit error:\n" \
                            "  %(image)s\n  %(pil)s\n" \
                            "  Fix: Change the PYTHONPATH in order to packages are found on the same paths\n" \
                            "  usually by adding '%(pil)s' to the beginning of PYTHONPATH." \
                            % {'image': os.path.dirname(Image.__file__), 'pil': os.path.dirname(PIL.__file__)}
                            )
            except ImportError:
                pass
        except ImportError:
            verbose_check_install('PIL',
                                  'PIL',
                                  verbose_name='The Python Imaging Library')

        verbose_check_install('reportlab', 'reportlab', '2.3')

        verbose_check_install('TRML2PDF',
                              'trml2pdf',
                              verbose_name='Tiny RML2PDF')

        verbose_check_install('django_registration', 'registration', '0.7.1',
                              'eedf14249b89')

        verbose_check_install('', 'yaml', verbose_name='YAML')

        verbose_check_install('sorl_thumbnail', 'sorl', '3.2.5',
                              'caf69b520632', 'Sorl imaging library')

        verbose_check_install('django_caching_app_plugins', 'app_plugins',
                              '0.1.2', '53a31761e344')

        verbose_check_install('django_livesettings', 'livesettings', '1.4-8',
                              '9a3f0ed0dca5')

        verbose_check_install('django_threaded_multihost',
                              'threaded_multihost', '1.4.1', '7ca3743d8a70')

        verbose_check_install('django-keyedcache', 'keyedcache', '1.4-4',
                              '4be18235b372')

        # Installers versions can be interesting for installation problems
        check_install('pip', 'pip')  # pip can not show the version number
        verbose_check_install('setuptools', 'setuptools', required=False)
        verbose_check_install('mercurial', 'mercurial', required=False)

        try:
            cache_avail = settings.CACHES.get("default").get("BACKEND")
        except AttributeError:
            error_out("A CACHE_BACKEND must be configured.")
        # Try looking up a url to see if there's a misconfiguration there
        try:
            from livesettings.models import Setting
            Setting.objects.all().count()
        except Exception as e:
            error_out("Can not use livesettings: %s" % e)
        else:
            # The function reverse has its own way of error reporting to screen and we have no access
            # to it so that we call it only if basic preconditions are fulfilled.
            try:
                url = reverse('satchmo_search')
                # Catch SystemExit, because if an error occurs, `urlresolvers` usually calls sys.exit() and other error
                # messages would be lost.
            except (Exception, SystemExit) as e:
                error_out("Unable to resolve urls. Received error - %s" %
                          formaterror(e))
        try:
            from l10n.l10n_settings import get_l10n_default_currency_symbol
        except Exception:
            pass
        if not isinstance(get_l10n_default_currency_symbol(),
                          types.UnicodeType):
            error_out("Your currency symbol should be a unicode string.")
        if 'satchmo_store.shop.SSLMiddleware.SSLRedirect' not in settings.MIDDLEWARE_CLASSES:
            error_out(
                "You must have satchmo_store.shop.SSLMiddleware.SSLRedirect in your MIDDLEWARE_CLASSES."
            )
        if 'satchmo_store.shop.context_processors.settings' not in settings.TEMPLATE_CONTEXT_PROCESSORS:
            error_out(
                "You must have satchmo_store.shop.context_processors.settings in your "
                "TEMPLATE_CONTEXT_PROCESSORS.")
        if 'threaded_multihost.middleware.ThreadLocalMiddleware' not in settings.MIDDLEWARE_CLASSES:
            error_out(
                "You must install 'django threaded multihost'\n"
                "and place 'threaded_multihost.middleware.ThreadLocalMiddleware' in your MIDDLEWARE_CLASSES."
            )
        if 'satchmo_store.accounts.email-auth.EmailBackend' not in settings.AUTHENTICATION_BACKENDS:
            error_out(
                "You must have satchmo_store.accounts.email-auth.EmailBackend in your AUTHENTICATION_BACKENDS"
            )
        if len(settings.SECRET_KEY) == 0:
            error_out(
                "You must have SECRET_KEY set to a valid string in your settings.py file"
            )
        python_ver = Decimal("%s.%s" %
                             (sys.version_info[0], sys.version_info[1]))
        if python_ver < Decimal("2.4"):
            error_out("Python version must be at least 2.4.")
        if python_ver < Decimal("2.5"):
            try:
                from elementtree.ElementTree import Element
            except ImportError:
                error_out("Elementtree is not installed.")

        # Check all installed apps
        if not filter(lambda x: re.search('not .*(installed|imported)', x),
                      errors):
            for appname in settings.INSTALLED_APPS:
                pkgtype, filename, root_filename = find_module_extend(appname)
                try:
                    app = import_module(appname)
                except (Exception, SystemExit):
                    if not pkgtype:
                        error_out('Can not find module "%s"' % appname)
                    else:
                        error_out('Can not import "%s"' % appname)
                        log.exception('Can not import "%s"' % appname)
                        logged_more = True
        else:
            log.debug(
                'It does not test INSTALLED_APPS due to previous errors.')

        log.debug('\n'.join(2 * ['Installation paths:'] + [
            '  %s : %s' % (k, sorted(list(v)))
            for k, v in sorted(app_paths.items())
        ]))
        apps_in_root = sorted(
            reduce(set.union,
                   [v for k, v in app_paths.items() if k.startswith('/root')],
                   set()))
        if apps_in_root:
            error_out('No package should be installed in the "/root" home directory, but packages %s are.' \
                    % (apps_in_root,))
            logged_more = True

        if len(errors) == 0:
            print_out("Your configuration is OK. (no errors)")
        else:
            print_out("")
            print_out("The following errors were found:")
            for error in errors:
                print_out(error)
            if logged_more:
                print("Error details are in 'satchmo.log'", file=sys.stderr)
Example #8
0
     error_out("Can not use livesettings: %s" % e)
 else:
     # The function urlresolvers.reverse has its own way of error reporting to screen and we have no access
     # to it so that we call it only if basic preconditions are fulfilled.
     try:
         url = urlresolvers.reverse('satchmo_search')
         # Catch SystemExit, because if an error occurs, `urlresolvers` usually calls sys.exit() and other error
         # messages would be lost.
     except (Exception, SystemExit), e:
         error_out("Unable to resolve urls. Received error - %s" %
                   formaterror(e))
 try:
     from l10n.l10n_settings import get_l10n_default_currency_symbol
 except Exception:
     pass
 if not isinstance(get_l10n_default_currency_symbol(),
                   types.UnicodeType):
     error_out("Your currency symbol should be a unicode string.")
 if 'satchmo_store.shop.SSLMiddleware.SSLRedirect' not in settings.MIDDLEWARE_CLASSES:
     error_out(
         "You must have satchmo_store.shop.SSLMiddleware.SSLRedirect in your MIDDLEWARE_CLASSES."
     )
 if 'satchmo_store.shop.context_processors.settings' not in settings.TEMPLATE_CONTEXT_PROCESSORS:
     error_out(
         "You must have satchmo_store.shop.context_processors.settings in your "
         "TEMPLATE_CONTEXT_PROCESSORS.")
 if 'threaded_multihost.middleware.ThreadLocalMiddleware' not in settings.MIDDLEWARE_CLASSES:
     error_out(
         "You must install 'django threaded multihost'\n"
         "and place 'threaded_multihost.middleware.ThreadLocalMiddleware' in your MIDDLEWARE_CLASSES."
     )
Example #9
0
class Command(NoArgsCommand):
    help = "Check the system to see if the Satchmo components are installed correctly."
    
    # These settings help to not import some dependencies before they are
    can_import_settings = False
    requires_model_validation = False

    def handle_noargs(self, **options):
        """Checks Satchmo installation and configuration.

        Tests, catches and shortly summarizes many common installation errors, without tracebacks.
        If was seen a traceback, it should be reported to a developer. (for now)
        Tracebacks are saved to the 'satchmo.log'. It helps to find cyclic dependencies etc.
        """
        #    print_out(...)  # print immediately and log it
        #    error_out(...)  # print at the end and log it now
        from django.conf import settings
        print_out("Checking your satchmo configuration.")
        try:
            import satchmo_store
        except ImportError:
            error_out("Satchmo is not installed correctly. Please verify satchmo is on your sys path.")
        print_out("Using Django version %s" % django.get_version())
        print_out("Using Satchmo version %s" % satchmo_store.get_version())
        #Check the Django version
        #Make sure we only get the X.Y.Z version info and not any other alpha or beta designations
        version_check = LooseVersion(".".join(map(str, django.VERSION)[:3]))
        if version_check < LooseVersion("1.2.3"):
            error_out("Django version must be >= 1.2.3")

        # Try importing all our dependencies
        verbose_check_install('', 'Crypto.Cipher', verbose_name='The Python Cryptography Toolkit')
        try:
            import Image
            verbose_check_install('Image', 'Image')
        except ImportError:
            verbose_check_install('PIL', 'PIL', verbose_name='The Python Imaging Library')

        verbose_check_install('reportlab', 'reportlab', '2.3')

        verbose_check_install('TRML2PDF', 'trml2pdf', '1.0', verbose_name='Tiny RML2PDF')

        verbose_check_install('django_registration', 'registration', '0.7')

        verbose_check_install('', 'yaml', verbose_name='YAML')

        verbose_check_install('sorl_thumbnail', 'sorl', '3.2.5', 'caf69b520632', 'Sorl imaging library')

        verbose_check_install('django_caching_app_plugins', 'app_plugins', '0.1.2', '53a31761e344')

        verbose_check_install('django_livesettings', 'livesettings', '1.4.8', 'e2769f9f60ec')

        verbose_check_install('django_signals_ahoy', 'signals_ahoy', '0.1.0', '9ad8779d4c63')

        verbose_check_install('django_threaded_multihost', 'threaded_multihost', '1.4.1', '7ca3743d8a70')

        verbose_check_install('django-keyedcache', 'keyedcache', '1.4.4', '4be18235b372')

        try:
            cache_avail = settings.CACHE_BACKEND
        except AttributeError:
            error_out("A CACHE_BACKEND must be configured.")
        # Try looking up a url to see if there's a misconfiguration there    
        try:
            url = urlresolvers.reverse('satchmo_search')
            # Catch SystemExit, because if an error occurs, `urlresolvers` usually calls sys.exit() and other error messages would be lost.
        except (Exception, SystemExit), e:
            error_out("Unable to resolve url. Received error - %s" % e)
        from l10n.l10n_settings import get_l10n_default_currency_symbol
        if not isinstance(get_l10n_default_currency_symbol(),types.UnicodeType):
            error_out("Your currency symbol should be a unicode string.")
        if 'satchmo_store.shop.SSLMiddleware.SSLRedirect' not in settings.MIDDLEWARE_CLASSES:
            error_out("You must have satchmo_store.shop.SSLMiddleware.SSLRedirect in your MIDDLEWARE_CLASSES.")
        if 'satchmo_store.shop.context_processors.settings' not in settings.TEMPLATE_CONTEXT_PROCESSORS:
            error_out("You must have satchmo_store.shop.context_processors.settings in your TEMPLATE_CONTEXT_PROCESSORS.")
        if 'threaded_multihost.middleware.ThreadLocalMiddleware' not in settings.MIDDLEWARE_CLASSES:
            error_out("You must install django threaded multihost \n and place threaded_multihost.middleware.ThreadLocalMiddleware in your MIDDLEWARE_CLASSES.")
        if 'satchmo_store.accounts.email-auth.EmailBackend' not in settings.AUTHENTICATION_BACKENDS:
            error_out("You must have satchmo_store.accounts.email-auth.EmailBackend in your AUTHENTICATION_BACKENDS")
        if len(settings.SECRET_KEY) == 0:
            error_out("You must have SECRET_KEY set to a valid string in your settings.py file")
        python_ver = Decimal("%s.%s" % (sys.version_info[0], sys.version_info[1]))
        if python_ver < Decimal("2.4"):
            error_out("Python version must be at least 2.4.")
        if python_ver < Decimal("2.5"):
            try:
                from elementtree.ElementTree import Element
            except ImportError:
                error_out("Elementtree is not installed.")

        # Check all installed apps
        if not filter(lambda x: re.search('not .*(installed|imported)', x), errors):
            for appname in settings.INSTALLED_APPS:
                try:
                    app = import_module(appname)
                except (Exception, SystemExit):
                    error_out('Can not import "%s"' % appname) 
                    log.exception('Can not import "%s"' % appname)
        else:
            log.debug('It does not test INSTALLED_APPS due to previous errors.')

        if len(errors) == 0:
            print_out("Your configuration has no errors.")
        else:
            print_out(""); print_out("The following errors were found:")
            for error in errors:
                print_out(error)
            if filter(lambda x: re.search('not .*import(ed)?', x), errors):
                print "Error details are in 'satchmo.log'"
Example #10
0
class Command(NoArgsCommand):
    help = "Check the system to see if the Satchmo components are installed correctly."

    # These settings help to not import some dependencies before they are
    can_import_settings = False
    requires_model_validation = False

    def handle_noargs(self, **options):
        """Checks Satchmo installation and configuration.

        Tests, catches and shortly summarizes many common installation errors, without tracebacks.
        If was seen a traceback, it should be reported to a developer. (for now)
        Tracebacks are saved to the 'satchmo.log'. It helps to find cyclic dependencies etc.
        """
        from django.conf import settings
        global logged_more
        print_out("Checking your satchmo configuration.")
        try:
            import satchmo_store
        except ImportError:
            error_out(
                "Satchmo is not installed correctly. Please verify satchmo is on your sys path."
            )
        print "Using Django version %s" % django.get_version()
        print "Using Satchmo version %s" % satchmo_store.get_version()
        #Check the Django version
        #Make sure we only get the X.Y.Z version info and not any other alpha or beta designations
        version_check = LooseVersion(".".join(map(str, django.VERSION)[:3]))
        if version_check < LooseVersion("1.2.3"):
            error_out("Django version must be >= 1.2.3")

        # Store these checked installation paths also to the paths overview
        verbose_check_install('satchmo',
                              'satchmo_store',
                              verbose_name='Satchmo')

        verbose_check_install('django', 'django', '1.2.3')

        # Try importing all our dependencies
        verbose_check_install('',
                              'Crypto.Cipher',
                              verbose_name='The Python Cryptography Toolkit')
        try:
            import Image
            verbose_check_install('Image', 'Image')
        except ImportError:
            verbose_check_install('PIL',
                                  'PIL',
                                  verbose_name='The Python Imaging Library')

        verbose_check_install('reportlab', 'reportlab', '2.3')

        verbose_check_install('TRML2PDF',
                              'trml2pdf',
                              '1.0',
                              verbose_name='Tiny RML2PDF')

        verbose_check_install('django_registration', 'registration', '0.7')

        verbose_check_install('', 'yaml', verbose_name='YAML')

        verbose_check_install('sorl_thumbnail', 'sorl', '3.2.5',
                              'caf69b520632', 'Sorl imaging library')

        verbose_check_install('django_caching_app_plugins', 'app_plugins',
                              '0.1.2', '53a31761e344')

        verbose_check_install('django_livesettings', 'livesettings', '1.4-8',
                              '9a3f0ed0dca5')

        verbose_check_install('django_signals_ahoy', 'signals_ahoy', '0.1.0',
                              '9ad8779d4c63')

        verbose_check_install('django_threaded_multihost',
                              'threaded_multihost', '1.4.1', '7ca3743d8a70')

        verbose_check_install('django-keyedcache', 'keyedcache', '1.4-4',
                              '4be18235b372')

        # Installers versions can be interesting for installation problems
        check_install('pip', 'pip')  # pip can not show the version number
        verbose_check_install('setuptools', 'setuptools', required=False)
        #verbose_check_install('mercurial', 'mercurial', required=False)

        try:
            cache_avail = settings.CACHE_BACKEND
        except AttributeError:
            error_out("A CACHE_BACKEND must be configured.")
        # Try looking up a url to see if there's a misconfiguration there
        try:
            # The function urlresolvers.reverse has its own way of error reporting to screen and we have no access to it
            url = urlresolvers.reverse('satchmo_search')
            # Catch SystemExit, because if an error occurs, `urlresolvers` usually calls sys.exit() and other error messages would be lost.
        except (Exception, SystemExit), e:
            error_out("Unable to resolve urls. Received error - %s" %
                      formaterror(e))
        try:
            from l10n.l10n_settings import get_l10n_default_currency_symbol
        except:
            pass
        if not isinstance(get_l10n_default_currency_symbol(),
                          types.UnicodeType):
            error_out("Your currency symbol should be a unicode string.")
        if 'satchmo_store.shop.SSLMiddleware.SSLRedirect' not in settings.MIDDLEWARE_CLASSES:
            error_out(
                "You must have satchmo_store.shop.SSLMiddleware.SSLRedirect in your MIDDLEWARE_CLASSES."
            )
        if 'satchmo_store.shop.context_processors.settings' not in settings.TEMPLATE_CONTEXT_PROCESSORS:
            error_out(
                "You must have satchmo_store.shop.context_processors.settings in your TEMPLATE_CONTEXT_PROCESSORS."
            )
        if 'threaded_multihost.middleware.ThreadLocalMiddleware' not in settings.MIDDLEWARE_CLASSES:
            error_out(
                "You must install django threaded multihost \n and place threaded_multihost.middleware.ThreadLocalMiddleware in your MIDDLEWARE_CLASSES."
            )
        if 'satchmo_store.accounts.email-auth.EmailBackend' not in settings.AUTHENTICATION_BACKENDS:
            error_out(
                "You must have satchmo_store.accounts.email-auth.EmailBackend in your AUTHENTICATION_BACKENDS"
            )
        if len(settings.SECRET_KEY) == 0:
            error_out(
                "You must have SECRET_KEY set to a valid string in your settings.py file"
            )
        python_ver = Decimal("%s.%s" %
                             (sys.version_info[0], sys.version_info[1]))
        if python_ver < Decimal("2.4"):
            error_out("Python version must be at least 2.4.")
        if python_ver < Decimal("2.5"):
            try:
                from elementtree.ElementTree import Element
            except ImportError:
                error_out("Elementtree is not installed.")

        # Check all installed apps
        if not filter(lambda x: re.search('not .*(installed|imported)', x),
                      errors):
            for appname in settings.INSTALLED_APPS:
                pkgtype, filename, root_filename = find_module_extend(appname)
                try:
                    app = import_module(appname)
                except (Exception, SystemExit):
                    if not pkgtype:
                        error_out('Can not find module "%s"' % appname)
                    else:
                        error_out('Can not import "%s"' % appname)
                        log.exception('Can not import "%s"' % appname)
                        logged_more = True
        else:
            log.debug(
                'It does not test INSTALLED_APPS due to previous errors.')

        log.debug('\n'.join(2 * ['Installation paths:'] + [
            '  %s : %s' % (k, sorted(list(v)))
            for k, v in sorted(app_paths.items())
        ]))
        apps_in_root = sorted(
            reduce(set.union,
                   [v for k, v in app_paths.items() if k.startswith('/root')],
                   set()))
        if apps_in_root:
            error_out(
                'No package should be installed in the "/root" home directory, but packages %s are.'
                % (apps_in_root, ))
            logged_more = True

        if len(errors) == 0:
            print_out("Your configuration has no errors.")
        else:
            print_out("")
            print_out("The following errors were found:")
            for error in errors:
                print_out(error)
            if logged_more:
                print "Error details are in 'satchmo.log'"
Example #11
0
class Command(NoArgsCommand):
    help = "Check the system to see if the Satchmo components are installed correctly."

    def handle_noargs(self, **options):
        from django.conf import settings
        errors = []
        print "Checking your satchmo configuration."
        try:
            import satchmo_store
        except ImportError:
            errors.append(
                "Satchmo is not installed correctly. Please verify satchmo is on your sys path."
            )
        print "Using Django version %s" % django.get_version()
        print "Using Satchmo version %s" % satchmo_store.get_version()
        #Check the Django version
        #Make sure we only get the X.Y.Z version info and not any other alpha or beta designations
        version_check = LooseVersion(".".join([str(s)
                                               for s in django.VERSION][:3]))
        if version_check < LooseVersion("1.2.3"):
            errors.append("Django version must be >= 1.2.3")
        # Try importing all our dependencies
        try:
            import Crypto.Cipher
        except ImportError:
            errors.append("The Python Cryptography Toolkit is not installed.")
        try:
            import Image
        except ImportError:
            try:
                import PIL as Image
            except ImportError:
                errors.append("The Python Imaging Library is not installed.")
        try:
            import reportlab
        except ImportError:
            errors.append("Reportlab is not installed.")
        try:
            import trml2pdf
        except ImportError:
            errors.append("Tiny RML2PDF is not installed.")
        try:
            import registration
        except ImportError:
            errors.append("Django registration is not installed.")
        try:
            import yaml
        except ImportError:
            errors.append("YAML is not installed.")
        try:
            import sorl
        except ImportError:
            errors.append("Sorl imaging library is not installed.")
        try:
            import app_plugins
        except ImportError:
            errors.append("App plugins is not installed.")
        try:
            import livesettings
        except ImportError:
            errors.append("Livesettings is not installed.")
        try:
            import keyedcache
        except ImportError:
            errors.append("Keyedcache is not installed.")
        try:
            cache_avail = settings.CACHE_BACKEND
        except AttributeError:
            errors.append("A CACHE_BACKEND must be configured.")
        # Try looking up a url to see if there's a misconfiguration there
        try:
            url = urlresolvers.reverse('satchmo_search')
        except Exception, e:
            errors.append("Unable to resolve url. Received error- %s" % e)
        from l10n.l10n_settings import get_l10n_default_currency_symbol
        if not isinstance(get_l10n_default_currency_symbol(),
                          types.UnicodeType):
            errors.append("Your currency symbol should be a unicode string.")
        if 'satchmo_store.shop.SSLMiddleware.SSLRedirect' not in settings.MIDDLEWARE_CLASSES:
            errors.append(
                "You must have satchmo_store.shop.SSLMiddleware.SSLRedirect in your MIDDLEWARE_CLASSES."
            )
        if 'satchmo_store.shop.context_processors.settings' not in settings.TEMPLATE_CONTEXT_PROCESSORS:
            errors.append(
                "You must have satchmo_store.shop.context_processors.settings in your TEMPLATE_CONTEXT_PROCESSORS."
            )
        if 'threaded_multihost.middleware.ThreadLocalMiddleware' not in settings.MIDDLEWARE_CLASSES:
            errors.append(
                "You must install django threaded multihost \n and place threaded_multihost.middleware.ThreadLocalMiddleware in your MIDDLEWARE_CLASSES."
            )
        if 'satchmo_store.accounts.email-auth.EmailBackend' not in settings.AUTHENTICATION_BACKENDS:
            errors.append(
                "You must have satchmo_store.accounts.email-auth.EmailBackend in your AUTHENTICATION_BACKENDS"
            )
        if len(settings.SECRET_KEY) == 0:
            errors.append(
                "You must have SECRET_KEY set to a valid string in your settings.py file"
            )
        python_ver = Decimal("%s.%s" %
                             (sys.version_info[0], sys.version_info[1]))
        if python_ver < Decimal("2.4"):
            errors.append("Python version must be at least 2.4.")
        if python_ver < Decimal("2.5"):
            try:
                from elementtree.ElementTree import Element
            except ImportError:
                errors.append("Elementtree is not installed.")
        if len(errors) == 0:
            print "Your configuration has no errors."
        else:
            print "The following errors were found:"
            for error in errors:
                print error