コード例 #1
0
ファイル: listeners.py プロジェクト: huangdehui2013/EShop-1
def add_toolbar_context(sender, context={}, **kwargs):
    user = threadlocals.get_current_user()
    if user and user.is_staff:
        request_path = context['request'].META['PATH_INFO']
        slug = request_path.split('/')[-2]
        total_sales = 0
        show_sales = False
        variation_items = []
        try:
            product = Product.objects.get(slug=slug)
            show_sales = True
            subtypes = product.get_subtypes()
            if 'ConfigurableProduct' in subtypes:
                variation_items, total_sales = _get_all_variations(product)
            else:
                total_sales = product.total_sold

        except:
            pass

        st = {}
        st['st_satchmo_version'] = get_version()
        newq = Order.objects.filter(status__exact='New')
        st['st_new_order_ct'] = newq.count()
        amounts = newq.values_list('total', flat=True)
        if amounts:
            newtotal = reduce(operator.add, filter(None, amounts), 0)
        else:
            newtotal = 0
        st['st_new_order_total'] = newtotal
        st['st_total_sold'] = total_sales
        st['st_show_sales'] = show_sales
        st['st_variations'] = variation_items
        week = datetime.datetime.today() - datetime.timedelta(days=7)
        day = datetime.datetime.today() - datetime.timedelta(days=1)
        hours = datetime.datetime.today() - datetime.timedelta(hours=1)
        cartweekq = Cart.objects.filter(date_time_created__gte=week)
        cartdayq = Cart.objects.filter(date_time_created__gte=day)
        carthourq = Cart.objects.filter(date_time_created__gte=hours)
        st['st_cart_7d_ct'] = cartweekq.count()
        st['st_cart_1d_ct'] = cartdayq.count()
        st['st_cart_1h_ct'] = carthourq.count()

        st['st_contacts_ct'] = Contact.objects.all().count()
        st['st_contacts_7d_ct'] = Contact.objects.filter(
            create_date__gte=week).count()
        # edits = []
        # st['st_edits'] = edits

        context.update(st)
コード例 #2
0
ファイル: listeners.py プロジェクト: kidaa30/pops
def add_toolbar_context(sender, context={}, **kwargs):
    user = threadlocals.get_current_user()
    if user and user.is_staff:
        request_path = context["request"].META["PATH_INFO"]
        slug = request_path.split("/")[-2]
        total_sales = 0
        show_sales = False
        variation_items = []
        try:
            product = Product.objects.get(slug=slug)
            show_sales = True
            subtypes = product.get_subtypes()
            if "ConfigurableProduct" in subtypes:
                variation_items, total_sales = _get_all_variations(product)
            else:
                total_sales = product.total_sold

        except:
            pass

        st = {}
        st["st_satchmo_version"] = get_version()
        newq = Order.objects.filter(status__exact="New")
        st["st_new_order_ct"] = newq.count()
        amounts = newq.values_list("total", flat=True)
        if amounts:
            newtotal = reduce(operator.add, filter(None, amounts), 0)
        else:
            newtotal = 0
        st["st_new_order_total"] = newtotal
        st["st_total_sold"] = total_sales
        st["st_show_sales"] = show_sales
        st["st_variations"] = variation_items
        week = datetime.datetime.today() - datetime.timedelta(days=7)
        day = datetime.datetime.today() - datetime.timedelta(days=1)
        hours = datetime.datetime.today() - datetime.timedelta(hours=1)
        cartweekq = Cart.objects.filter(date_time_created__gte=week)
        cartdayq = Cart.objects.filter(date_time_created__gte=day)
        carthourq = Cart.objects.filter(date_time_created__gte=hours)
        st["st_cart_7d_ct"] = cartweekq.count()
        st["st_cart_1d_ct"] = cartdayq.count()
        st["st_cart_1h_ct"] = carthourq.count()

        st["st_contacts_ct"] = Contact.objects.all().count()
        st["st_contacts_7d_ct"] = Contact.objects.filter(create_date__gte=week).count()
        # edits = []
        # st['st_edits'] = edits

        context.update(st)
コード例 #3
0
ファイル: satchmo_check.py プロジェクト: 34/T
 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)
コード例 #4
0
ファイル: satchmo_check.py プロジェクト: eyeyunianto/satchmo
    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')
            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', '1.0', 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.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:
            from livesettings.models import Setting
            Setting.objects.all().count()
        except Exception, e:
            error_out("Can not use livesettings: %s" % e)
コード例 #5
0
ファイル: satchmo_check.py プロジェクト: hnejadi/EShop-2
    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))
コード例 #6
0
ファイル: satchmo_check.py プロジェクト: siddhant3030/Satchmo
    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)
コード例 #7
0
ファイル: satchmo_check.py プロジェクト: hnejadi/xerobis
 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()
     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:
          from l10n.utils import get_locale_conv
          get_locale_conv()
     except:
         errors.append("""
         Locale is not set correctly.  Try 
         Unix: sudo locale-gen en_US  
         If the above does not work, try
         sudo localedef -i en_US -f ISO-8859-1 en_US
         Windows: set LANGUAGE_CODE in settings.py to LANGUAGE_CODE = 'us'
         """)
     try:
         cache_avail = settings.CACHE_BACKEND
     except AttributeError:
         errors.append("A CACHE_BACKEND must be configured.")
     
     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
コード例 #8
0
ファイル: satchmo_check.py プロジェクト: grengojbo/satchmo
    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", "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")

        # 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))
コード例 #9
0
    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')
            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',
                              '1.0',
                              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.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:
            from livesettings.models import Setting
            Setting.objects.all().count()
        except Exception, e:
            error_out("Can not use livesettings: %s" % e)
コード例 #10
0
ファイル: satchmo_check.py プロジェクト: ringemup/satchmo
    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)
コード例 #11
0
    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))
コード例 #12
0
 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)