richie 3.1.0__py2.py3-none-any.whl → 3.1.1.dev2__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of richie might be problematic. Click here for more details.

@@ -2,6 +2,7 @@
2
2
  ElasticSearch indices utilities.
3
3
  """
4
4
 
5
+ import logging
5
6
  import re
6
7
  from functools import reduce
7
8
 
@@ -16,6 +17,8 @@ from .elasticsearch import bulk_compat
16
17
  from .indexers import ES_INDICES
17
18
  from .text_indexing import ANALYSIS_SETTINGS
18
19
 
20
+ logger = logging.getLogger(__name__)
21
+
19
22
 
20
23
  def richie_bulk(actions):
21
24
  """Wrap bulk helper to set default parameters."""
@@ -37,16 +40,16 @@ def get_indices_by_alias(existing_indices, alias):
37
40
  yield index, alias
38
41
 
39
42
 
40
- def perform_create_index(indexable, logger=None):
43
+ def perform_create_index(indexable):
41
44
  """
42
45
  Create a new index in ElasticSearch from an indexable instance
43
46
  """
47
+ logger.info("Creating the index %s...", indexable.index_name)
44
48
  # Create a new index name, suffixing its name with a timestamp
45
49
  new_index = f"{indexable.index_name:s}_{timezone.now():%Y-%m-%d-%Hh%Mm%S.%fs}"
46
50
 
47
51
  # Create the new index
48
- if logger:
49
- logger.info(f'Creating a new Elasticsearch index "{new_index:s}"...')
52
+ logger.info("Creating a new Elasticsearch index %s...", new_index)
50
53
  ES_INDICES_CLIENT.create(index=new_index)
51
54
 
52
55
  # The index needs to be closed before we set an analyzer
@@ -63,11 +66,12 @@ def perform_create_index(indexable, logger=None):
63
66
  return new_index
64
67
 
65
68
 
66
- def regenerate_indices(logger):
69
+ def regenerate_indices():
67
70
  """
68
71
  Create new indices for our indexables and replace possible existing indices with
69
72
  a new one only once it has successfully built it.
70
73
  """
74
+ logger.info("Regenerating ES indices...")
71
75
  # Get all existing indices once; we'll look up into this list many times
72
76
  try:
73
77
  existing_indices = ES_INDICES_CLIENT.get_alias("*")
@@ -75,11 +79,10 @@ def regenerate_indices(logger):
75
79
  # Provide a fallback empty list so we don't have to check for its existence later on
76
80
  existing_indices = []
77
81
 
82
+ logger.info("Creating new ES indices...")
78
83
  # Create a new index for each of those modules
79
84
  # NB: we're mapping perform_create_index which produces side-effects
80
- indices_to_create = zip(
81
- list(map(lambda ix: perform_create_index(ix, logger), ES_INDICES)), ES_INDICES
82
- )
85
+ indices_to_create = [(perform_create_index(ix), ix) for ix in ES_INDICES]
83
86
 
84
87
  # Prepare to alias them so they can be swapped-in for the previous versions
85
88
  actions_to_create_aliases = [
@@ -152,13 +155,16 @@ def regenerate_indices(logger):
152
155
  ES_INDICES_CLIENT.delete(index=useless_index, ignore=[400, 404])
153
156
 
154
157
 
155
- def store_es_scripts(logger=None):
158
+ def store_es_scripts():
156
159
  """
157
160
  Iterate over the indexers listed in the settings, import them, and store the scripts
158
161
  they define on their "scripts" key in ElasticSearch
159
162
  """
160
163
  for indexer in ES_INDICES:
161
164
  for script_id, script_body in indexer.scripts.items():
162
- if logger:
163
- logger.info(f'Storing script "{script_id:s}"...')
165
+ logger.info(
166
+ "Storing script %s for indexer %s...",
167
+ script_id,
168
+ indexer.__name__,
169
+ )
164
170
  ES_CLIENT.put_script(id=script_id, body=script_body)
@@ -2,6 +2,7 @@
2
2
  ElasticSearch person document management utilities
3
3
  """
4
4
 
5
+ import logging
5
6
  from collections import defaultdict
6
7
 
7
8
  from django.conf import settings
@@ -20,6 +21,8 @@ from ..text_indexing import MULTILINGUAL_TEXT
20
21
  from ..utils.i18n import get_best_field_language
21
22
  from ..utils.indexers import slice_string_for_completion
22
23
 
24
+ logger = logging.getLogger(__name__)
25
+
23
26
 
24
27
  class PersonsIndexer:
25
28
  """
@@ -78,6 +81,11 @@ class PersonsIndexer:
78
81
  ):
79
82
  language = portrait.cmsplugin_ptr.language
80
83
  with translation.override(language):
84
+ logger.debug(
85
+ "Indexing %s portrait for language %s",
86
+ person.extended_object.get_absolute_url(language),
87
+ language,
88
+ )
81
89
  portrait_images[language] = get_picture_info(portrait, "portrait")
82
90
 
83
91
  # Get bio texts
@@ -27,7 +27,7 @@ class Command(BaseCommand):
27
27
 
28
28
  # Creates new indices each time, populates them, and atomically replaces
29
29
  # the old indices once the new ones are ready.
30
- regenerate_indices(logger)
30
+ regenerate_indices()
31
31
 
32
32
  # Confirm operation success through a console log
33
33
  logger.info("ES indices regenerated.")
@@ -35,6 +35,6 @@ class Command(BaseCommand):
35
35
  logger.info("Starting to store ES scripts...")
36
36
 
37
37
  # Iterates over indexables to find all the necessary scripts and store them
38
- store_es_scripts(logger)
38
+ store_es_scripts()
39
39
 
40
40
  logger.info("ES scripts stored.")
@@ -1,7 +1,11 @@
1
1
  """SimplePicture plugin for DjangoCMS."""
2
2
 
3
+ import logging
4
+
3
5
  from .defaults import SIMPLEPICTURE_PRESETS
4
6
 
7
+ logger = logging.getLogger(__name__)
8
+
5
9
 
6
10
  def get_picture_info(instance, preset_name):
7
11
  """
@@ -43,15 +47,29 @@ def get_picture_info(instance, preset_name):
43
47
  # - src
44
48
  options = preset["src"].copy()
45
49
  options.update(location_dict)
46
- picture_info["src"] = thumbnailer.get_thumbnail(options).url
50
+ try:
51
+ picture_info["src"] = thumbnailer.get_thumbnail(options).url
52
+ except ValueError as exc:
53
+ logger.error(
54
+ "Error while generating thumbnail for %s: %s",
55
+ options,
56
+ exc,
57
+ )
47
58
 
48
59
  # - srcset
49
60
  srcset = []
50
61
  for info in preset.get("srcset", []):
51
62
  options = info["options"].copy()
52
63
  options.update(location_dict)
53
- url = thumbnailer.get_thumbnail(options).url
54
- srcset.append(f"{url:s} {info['descriptor']:s}")
64
+ try:
65
+ url = thumbnailer.get_thumbnail(options).url
66
+ srcset.append(f"{url:s} {info['descriptor']:s}")
67
+ except ValueError as exc:
68
+ logger.error(
69
+ "Error while generating thumbnail for %s: %s",
70
+ options,
71
+ exc,
72
+ )
55
73
  picture_info["srcset"] = ", ".join(srcset) if srcset else None
56
74
 
57
75
  # - sizes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: richie
3
- Version: 3.1.0
3
+ Version: 3.1.1.dev2
4
4
  Summary: A CMS to build learning portals for open education
5
5
  Author-email: "Open FUN (France Université Numérique)" <fun.dev@fun-mooc.fr>
6
6
  License: MIT License
@@ -1119,7 +1119,7 @@ richie/apps/search/description.apib,sha256=UPTZaDWUV_U29qLFjHRWumEFPwH97eUbYideb
1119
1119
  richie/apps/search/elasticsearch.py,sha256=mE20jsQzLnp1VIQ2zntu_UYluECSkmjI2vAEgF60xCA,3811
1120
1120
  richie/apps/search/exceptions.py,sha256=Ld3tYIYJhigNvA_dymZRMQQTYvQmxRTIPbfu37s5K-4,479
1121
1121
  richie/apps/search/forms.py,sha256=4niV0PUZmhz6GwRdN6JT41nRNa4NsNKbgkhZTrT1Fho,15377
1122
- richie/apps/search/index_manager.py,sha256=lSggqzm9qZaujKMTqsWbAchmCkcAHsiZhrlRBMKSseM,6328
1122
+ richie/apps/search/index_manager.py,sha256=zeAZRLjy6_UULBkySakSBSkfWrVmzaxsIfs9jklinus,6509
1123
1123
  richie/apps/search/models.py,sha256=xJZX2xiPjJlIRwy0eiBFMzBULWnUMgdPTTY3zOzQ0I0,371
1124
1124
  richie/apps/search/signals.py,sha256=waq5ju9F-sdc5_X1YqRpaa78Na7yJK8xt38qEweb9PM,7143
1125
1125
  richie/apps/search/text_indexing.py,sha256=0jFAb1fGJCnUKptW8SYTeS2AdPkEZOmi0Bud3lcHMLc,5647
@@ -1138,10 +1138,10 @@ richie/apps/search/indexers/categories.py,sha256=AqLVVgbiOagmS9DkWmxvbB-QtFzFrVv
1138
1138
  richie/apps/search/indexers/courses.py,sha256=4exoJxm-bHBEUxZj9bXPyID_KcJjzY36ABDTp3hFWgA,34948
1139
1139
  richie/apps/search/indexers/licences.py,sha256=kZ0vT1jIOqCXSQUsQEKVmTiMIhCFpdiPQeDxAiMgInQ,3691
1140
1140
  richie/apps/search/indexers/organizations.py,sha256=uBTNBHiott4SMcxd4UdAliDdsUSDlWUK4gcoL-TJzCo,5774
1141
- richie/apps/search/indexers/persons.py,sha256=jgSxoJBtaxS5Kchza6Ov0FvYy-baXzV-qNhNDxKvAws,5479
1141
+ richie/apps/search/indexers/persons.py,sha256=4yD7wiuvXRX8G4UxyjO_MFF5j4NtCmeORscmZFDHTm8,5741
1142
1142
  richie/apps/search/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1143
1143
  richie/apps/search/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1144
- richie/apps/search/management/commands/bootstrap_elasticsearch.py,sha256=4PalSxcMWC9nWOKnF8OhzWL8isuvGGboivZzoClENrE,1176
1144
+ richie/apps/search/management/commands/bootstrap_elasticsearch.py,sha256=ZCzXV_uUIe0xroAgOOGhvS3o49L-XepUtrFJ54m194s,1164
1145
1145
  richie/apps/search/templates/search/search.html,sha256=9F8RlGnVGYJh9lIlhlCBMKs44ZNYRu6wXjUXHz6l0bs,1110
1146
1146
  richie/apps/search/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1147
1147
  richie/apps/search/utils/i18n.py,sha256=dHIQ362xGFZUOYP8QtjKhP8xIDYTHfDKUHlb8TmRBP8,695
@@ -1270,7 +1270,7 @@ richie/plugins/simple_picture/cms_plugins.py,sha256=lOOCeT3i-c09csJef0aDjcjxgmdI
1270
1270
  richie/plugins/simple_picture/defaults.py,sha256=kuRx6XesGMbLoO9I9X1k96o1BfaLW9nH3op8ozuVpnA,567
1271
1271
  richie/plugins/simple_picture/factories.py,sha256=J3g2e8TpSqTQAvAov1LaNTPythQ85V9eG6PcJiI0QUw,396
1272
1272
  richie/plugins/simple_picture/forms.py,sha256=QgzrpWW6M-Tz7eO_Sw57PeOfLSY5-fyvW6AfL1pQBSo,325
1273
- richie/plugins/simple_picture/helpers.py,sha256=Xil2gwLvQSktu1lPo7ygHIALCrgOUi9nHuCH6W0HKxE,1895
1273
+ richie/plugins/simple_picture/helpers.py,sha256=L4XGZVcVZuuaKHyVngvMtWIVW3iJbTGTsqeUCuOeULI,2325
1274
1274
  richie/plugins/simple_picture/templates/richie/simple_picture/picture.html,sha256=93nk3QA4sKZDj0F0a7kTnS9lbMluUfm02tsBz6NUd5g,417
1275
1275
  richie/plugins/simple_text_ckeditor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1276
1276
  richie/plugins/simple_text_ckeditor/cms_plugins.py,sha256=eVFJGafPoa7TpY6Dfztcz_xw6iBuBAMV9MzkhqndXgE,2501
@@ -2483,9 +2483,9 @@ richie/static/richie/js/build/99870.3d03ecf7f738aadec697.index.js,sha256=EaUT_FS
2483
2483
  richie/static/richie/js/build/99895.3d03ecf7f738aadec697.index.js,sha256=qRHNNUPr0-zKKVYjzx2QkSOBuxGzN5pyB6nTvyITQqs,2570
2484
2484
  richie/static/richie/js/build/99953.3d03ecf7f738aadec697.index.js,sha256=OWoLPJnHrmvF3HBQPgXooAGo5E0yJpJ7QTFHFghJpI8,135
2485
2485
  richie/static/richie/js/build/index.js,sha256=uUvBbc-sZ5PQa9zVpzcK1GzBcpxyfxZEEq9PSAUBAgY,1332827
2486
- richie-3.1.0.dist-info/licenses/LICENSE,sha256=5LKjFIE1kpKzBfR2iwq_RGHhHM5XawdlfZrcHTsCLpA,1079
2487
- richie-3.1.0.dist-info/METADATA,sha256=256HVegh56RkOsxX8Ht2zkjBfR2dzrxOfee7rLdqBvk,7025
2488
- richie-3.1.0.dist-info/WHEEL,sha256=_z0Kb-VmhLeNt2nZ-PsoQBjD25rP0tBwgAyRYD7oTKI,109
2489
- richie-3.1.0.dist-info/top_level.txt,sha256=WJvFAAHtUQ5T5MOuG6jRynDJG9kVfl4jtuf1qxIXND8,16
2490
- richie-3.1.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
2491
- richie-3.1.0.dist-info/RECORD,,
2486
+ richie-3.1.1.dev2.dist-info/licenses/LICENSE,sha256=5LKjFIE1kpKzBfR2iwq_RGHhHM5XawdlfZrcHTsCLpA,1079
2487
+ richie-3.1.1.dev2.dist-info/METADATA,sha256=XR0Ettyg7cNpZJqEmAbc5fon7lNG8wrE7Ny_Hy3rZDc,7030
2488
+ richie-3.1.1.dev2.dist-info/WHEEL,sha256=egKm5cKfE6OqlHwodY8Jjp4yqZDBXgsj09UsV5ojd_U,109
2489
+ richie-3.1.1.dev2.dist-info/top_level.txt,sha256=WJvFAAHtUQ5T5MOuG6jRynDJG9kVfl4jtuf1qxIXND8,16
2490
+ richie-3.1.1.dev2.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
2491
+ richie-3.1.1.dev2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.7.1)
2
+ Generator: setuptools (80.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any