def __init__(self, *args, **kwargs):
        # some settings
        self.PROD_DETAILS_DIR = settings_fallback('PROD_DETAILS_DIR')
        self.PROD_DETAILS_URL = settings_fallback('PROD_DETAILS_URL')
        self._storage = STORAGE_CLASS(json_dir=self.PROD_DETAILS_DIR)

        super(Command, self).__init__(*args, **kwargs)
    def __init__(self, *args, **kwargs):
        # some settings
        self.PROD_DETAILS_DIR = settings_fallback('PROD_DETAILS_DIR')
        self.PROD_DETAILS_URL = settings_fallback('PROD_DETAILS_URL')
        self._storage = STORAGE_CLASS(json_dir=self.PROD_DETAILS_DIR)
        self.is_db_storage = self._storage.storage_type == 'db'

        super(Command, self).__init__(*args, **kwargs)
예제 #3
0
def test_init():
    with patch.object(product_details, 'get_django_cache') as cache_mock:
        pd = product_details.ProductDetails()
    eq_(pd.json_dir, settings_fallback('PROD_DETAILS_DIR'))
    eq_(pd.cache_timeout, settings_fallback('PROD_DETAILS_CACHE_TIMEOUT'))
    cache_mock.assert_called_with(settings_fallback('PROD_DETAILS_CACHE_NAME'))

    with patch.object(product_details, 'get_django_cache') as cache_mock:
        pd = product_details.ProductDetails(json_dir='walter', cache_name='donny',
                                            cache_timeout=2)

    eq_(pd.json_dir, 'walter')
    eq_(pd.cache_timeout, 2)
    cache_mock.assert_called_with('donny')
예제 #4
0
def test_init():
    with patch.object(product_details, 'get_django_cache') as cache_mock:
        pd = product_details.ProductDetails()
    eq_(pd.json_dir, settings_fallback('PROD_DETAILS_DIR'))
    eq_(pd.cache_timeout, settings_fallback('PROD_DETAILS_CACHE_TIMEOUT'))
    cache_mock.assert_called_with(settings_fallback('PROD_DETAILS_CACHE_NAME'))

    with patch.object(product_details, 'get_django_cache') as cache_mock:
        pd = product_details.ProductDetails(json_dir='walter',
                                            cache_name='donny',
                                            cache_timeout=2)

    eq_(pd.json_dir, 'walter')
    eq_(pd.cache_timeout, 2)
    cache_mock.assert_called_with('donny')
예제 #5
0
 def __init__(self, json_dir=None, cache_name=None, cache_timeout=None,
              storage_class=None):
     self._storage_class = import_string(storage_class or settings_fallback('PROD_DETAILS_STORAGE'))
     self._json_dir = json_dir
     self._cache_name = cache_name
     self._cache_timeout = cache_timeout
     self._real_storage = None
예제 #6
0
 def __init__(self,
              json_dir=None,
              cache_name=None,
              cache_timeout=None,
              storage_class=None):
     storage_class = import_string(
         storage_class or settings_fallback('PROD_DETAILS_STORAGE'))
     self._storage = storage_class(cache_name=cache_name,
                                   cache_timeout=cache_timeout,
                                   json_dir=json_dir)
import os
import re
import shutil
import tempfile
import urllib2
from urlparse import urljoin

from django.core.management.base import NoArgsCommand, CommandError

from product_details import product_details
from product_details.utils import settings_fallback


log = logging.getLogger('prod_details')
log.addHandler(logging.StreamHandler())
log.setLevel(settings_fallback('LOG_LEVEL'))


class Command(NoArgsCommand):
    help = 'Update Mozilla product details off SVN.'
    requires_model_validation = False
    option_list = NoArgsCommand.option_list + (
        make_option('-f', '--force', action='store_true', dest='force',
                    default=False, help=(
                        'Download product details even if they have not been '
                        'updated since the last fetch.')),
        make_option('-q', '--quiet', action='store_true', dest='quiet',
                    default=False, help=(
                        'If no error occurs, swallow all output.')),
    )
import re

from django.db import transaction
from django.utils.six.moves.urllib.parse import urljoin
from django.core.management.base import BaseCommand, CommandError
from django.utils.module_loading import import_string

import requests
from requests.exceptions import RequestException

from product_details.utils import settings_fallback


log = logging.getLogger('prod_details')
log.addHandler(logging.StreamHandler())
log.setLevel(settings_fallback('LOG_LEVEL'))
STORAGE_CLASS = import_string(settings_fallback('PROD_DETAILS_STORAGE'))


class Command(BaseCommand):
    help = 'Update Mozilla product details off SVN.'
    requires_model_validation = False

    def __init__(self, *args, **kwargs):
        # some settings
        self.PROD_DETAILS_DIR = settings_fallback('PROD_DETAILS_DIR')
        self.PROD_DETAILS_URL = settings_fallback('PROD_DETAILS_URL')
        self._storage = STORAGE_CLASS(json_dir=self.PROD_DETAILS_DIR)
        self.is_db_storage = self._storage.storage_type == 'db'

        super(Command, self).__init__(*args, **kwargs)
예제 #9
0
 def __init__(self, cache_name=None, cache_timeout=None, **kwargs):
     self._cache_timeout = cache_timeout or settings_fallback('PROD_DETAILS_CACHE_TIMEOUT')
     cache_name = cache_name or settings_fallback('PROD_DETAILS_CACHE_NAME')
     self._cache = get_django_cache(cache_name)
예제 #10
0
 def __init__(self, json_dir=None, cache_name=None, cache_timeout=None):
     super(PDFileStorage, self).__init__(cache_name, cache_timeout)
     self.json_dir = json_dir or settings_fallback('PROD_DETAILS_DIR')
예제 #11
0
 def __init__(self, json_dir=None, cache_name=None, cache_timeout=None):
     self.json_dir = json_dir or settings_fallback('PROD_DETAILS_DIR')
     self.cache_timeout = cache_timeout or settings_fallback(
         'PROD_DETAILS_CACHE_TIMEOUT')
     cache_name = cache_name or settings_fallback('PROD_DETAILS_CACHE_NAME')
     self._cache = get_django_cache(cache_name)
예제 #12
0
 def __init__(self, json_dir=None, cache_name=None, cache_timeout=None):
     self.json_dir = json_dir or settings_fallback('PROD_DETAILS_DIR')
     self.cache_timeout = cache_timeout or settings_fallback('PROD_DETAILS_CACHE_TIMEOUT')
     cache_name = cache_name or settings_fallback('PROD_DETAILS_CACHE_NAME')
     self._cache = get_django_cache(cache_name)
 def __init__(self, cache_name=None, cache_timeout=None, **kwargs):
     self._cache_timeout = cache_timeout or settings_fallback('PROD_DETAILS_CACHE_TIMEOUT')
     cache_name = cache_name or settings_fallback('PROD_DETAILS_CACHE_NAME')
     self._cache = get_django_cache(cache_name)
 def __init__(self, json_dir=None, cache_name=None, cache_timeout=None):
     super(PDFileStorage, self).__init__(cache_name, cache_timeout)
     self.json_dir = json_dir or settings_fallback('PROD_DETAILS_DIR')
    def __init__(self, *args, **kwargs):
        # some settings
        self.PROD_DETAILS_DIR = settings_fallback('PROD_DETAILS_DIR')
        self.PROD_DETAILS_URL = settings_fallback('PROD_DETAILS_URL')

        super(Command, self).__init__(*args, **kwargs)
예제 #16
0
from collections import defaultdict

from django.utils.module_loading import import_string

from product_details.utils import settings_fallback


class MissingJSONData(IOError):
    pass


__version__ = '0.10'
__all__ = ['__version__', 'product_details', 'version_compare']

log = logging.getLogger('product_details')
log.setLevel(settings_fallback('LOG_LEVEL'))


class ProductDetails(object):
    """
    Main product details class. Implements the JSON files' content as
    attributes, e.g.: product_details.firefox_version_history .
    """
    _cache_key = 'prod-details:{0}'

    def __init__(self, json_dir=None, cache_name=None, cache_timeout=None,
                 storage_class=None):
        storage_class = import_string(storage_class or settings_fallback('PROD_DETAILS_STORAGE'))
        self._storage = storage_class(cache_name=cache_name, cache_timeout=cache_timeout,
                                      json_dir=json_dir)
import logging
import re

from django.db import transaction
from django.utils.six.moves.urllib.parse import urljoin
from django.core.management.base import BaseCommand, CommandError
from django.utils.module_loading import import_string

import requests
from requests.exceptions import RequestException

from product_details.utils import settings_fallback

log = logging.getLogger('prod_details')
log.addHandler(logging.StreamHandler())
log.setLevel(settings_fallback('LOG_LEVEL'))
STORAGE_CLASS = import_string(settings_fallback('PROD_DETAILS_STORAGE'))


class Command(BaseCommand):
    help = 'Update Mozilla product details off SVN.'
    requires_model_validation = False

    def __init__(self, *args, **kwargs):
        # some settings
        self.PROD_DETAILS_DIR = settings_fallback('PROD_DETAILS_DIR')
        self.PROD_DETAILS_URL = settings_fallback('PROD_DETAILS_URL')
        self._storage = STORAGE_CLASS(json_dir=self.PROD_DETAILS_DIR)
        self.is_db_storage = self._storage.storage_type == 'db'

        super(Command, self).__init__(*args, **kwargs)
    def __init__(self, *args, **kwargs):
        # some settings
        self.PROD_DETAILS_DIR = settings_fallback('PROD_DETAILS_DIR')
        self.PROD_DETAILS_URL = settings_fallback('PROD_DETAILS_URL')

        super(Command, self).__init__(*args, **kwargs)