Repository: translate/pootle

Issue:
Ensure update_stores command fails on error
Seems like update_stores may swallow (some) errors. This is not helpful for sysadmins 8/


Discussion:
With current master and `DEBUG` set to both True and False ive triggered exceptions at various points in the stack without the exception being swallowed.

I also checked through the codebase for bare `except:` s, to try and find anywhere that might swallow errors during update, but didnt find any.

This may just have been a legacy issue, so closing unless able to reproduce

I guess that `except Exception` is not an issue?
which one - i didnt search on that

Resolving patch:
diff --git a/pootle/apps/pootle_app/management/commands/__init__.py b/pootle/apps/pootle_app/management/commands/__init__.py
--- a/pootle/apps/pootle_app/management/commands/__init__.py
+++ b/pootle/apps/pootle_app/management/commands/__init__.py
@@ -9,7 +9,7 @@
 import datetime
 import logging
 
-from django.core.management.base import BaseCommand
+from django.core.management.base import BaseCommand, CommandError
 
 from pootle.runner import set_sync_mode
 from pootle_project.models import Project
@@ -68,37 +68,19 @@ def __init__(self, *args, **kwargs):
         super(PootleCommand, self).__init__(*args, **kwargs)
 
     def do_translation_project(self, tp, **options):
-        process_stores = True
-
         if hasattr(self, "handle_translation_project"):
             logging.info(u"Running %s over %s", self.name, tp)
-            try:
-                process_stores = self.handle_translation_project(tp, **options)
-            except Exception:
-                logging.exception(u"Failed to run %s over %s", self.name, tp)
-                return
-
-            if not process_stores:
+            if not self.handle_translation_project(tp, **options):
                 return
-
         if hasattr(self, "handle_all_stores"):
             logging.info(u"Running %s over %s's files", self.name, tp)
-            try:
-                self.handle_all_stores(tp, **options)
-            except Exception:
-                logging.exception(u"Failed to run %s over %s's files",
-                                  self.name, tp)
-                return
+            self.handle_all_stores(tp, **options)
         elif hasattr(self, "handle_store"):
             store_query = tp.stores.live()
             for store in store_query.iterator():
                 logging.info(u"Running %s over %s",
                              self.name, store.pootle_path)
-                try:
-                    self.handle_store(store, **options)
-                except Exception:
-                    logging.exception(u"Failed to run %s over %s",
-                                      self.name, store.pootle_path)
+                self.handle_store(store, **options)
 
     def handle(self, **options):
         # adjust debug level to the verbosity option
@@ -125,7 +107,10 @@ def handle(self, **options):
         start = datetime.datetime.now()
         logging.info('Start running of %s', self.name)
 
-        self.handle_all(**options)
+        try:
+            self.handle_all(**options)
+        except Exception as e:
+            raise CommandError(e)
 
         # info finish
         end = datetime.datetime.now()
diff --git a/pootle/apps/pootle_app/management/commands/sync_stores.py b/pootle/apps/pootle_app/management/commands/sync_stores.py
--- a/pootle/apps/pootle_app/management/commands/sync_stores.py
+++ b/pootle/apps/pootle_app/management/commands/sync_stores.py
@@ -50,11 +50,3 @@ def handle_all_stores(self, translation_project, **options):
                 skip_missing=options['skip_missing'],
                 only_newer=not options['force']
             )
-
-    def handle_store(self, store, **options):
-        store.sync(
-            conservative=not options['overwrite'],
-            update_structure=options['overwrite'],
-            skip_missing=options['skip_missing'],
-            only_newer=not options['force']
-        )


Test patch: