Преглед изворни кода

[core] Avoid 500 error in server mode when looking at stats

Romain Rigaux пре 5 година
родитељ
комит
b67dd15d5d
1 измењених фајлова са 6 додато и 5 уклоњено
  1. 6 5
      desktop/core/src/desktop/lib/apputil.py

+ 6 - 5
desktop/core/src/desktop/lib/apputil.py

@@ -36,8 +36,8 @@ def get_current_app(frame=None):
   while frame:
     module = inspect.getmodule(frame.f_code)
     if not module:
-      raise Exception((
-          "No module for code %s (frame %s). Perhaps you have an old .pyc file hanging around?") %
+      raise Exception(
+          "No module for code %s (frame %s). Perhaps you have an old .pyc file hanging around?" %
           (repr(frame.f_code), repr(frame))
       )
     app = get_app_for_module(module)
@@ -45,15 +45,16 @@ def get_current_app(frame=None):
       return app
     frame = frame.f_back
 
-  # Did not find any app
   return None
 
 def get_app_for_module(module):
   for app in settings.INSTALLED_APPS:
     if module.__name__.startswith('desktop.lib.metrics.views'):
       return app
-    if module.__name__.startswith('desktop.lib.connectors'):
+    elif module.__name__.startswith('desktop.lib.analytics.views'):
       return app
-    if module.__name__.startswith(app) and not module.__name__.startswith("desktop.lib"):
+    elif module.__name__.startswith('desktop.lib.connectors'):
+      return app
+    elif module.__name__.startswith(app) and not module.__name__.startswith("desktop.lib"):
       return app
   return None