Show More
@@ -50,7 +50,7 b' class ExceptionsTrackerView(BaseAppView)' | |||||
50 | count +=1 |
|
50 | count +=1 | |
51 | return count |
|
51 | return count | |
52 |
|
52 | |||
53 | def get_all_exceptions(self, read_metadata=False, limit=None): |
|
53 | def get_all_exceptions(self, read_metadata=False, limit=None, type_filter=None): | |
54 | exc_store_path = exc_tracking.get_exc_store() |
|
54 | exc_store_path = exc_tracking.get_exc_store() | |
55 | exception_list = [] |
|
55 | exception_list = [] | |
56 |
|
56 | |||
@@ -59,7 +59,7 b' class ExceptionsTrackerView(BaseAppView)' | |||||
59 | return val.split('_')[-1] |
|
59 | return val.split('_')[-1] | |
60 | except Exception: |
|
60 | except Exception: | |
61 | return 0 |
|
61 | return 0 | |
62 | count = 0 |
|
62 | ||
63 | for fname in reversed(sorted(os.listdir(exc_store_path), key=key_sorter)): |
|
63 | for fname in reversed(sorted(os.listdir(exc_store_path), key=key_sorter)): | |
64 |
|
64 | |||
65 | parts = fname.split('_', 2) |
|
65 | parts = fname.split('_', 2) | |
@@ -83,13 +83,17 b' class ExceptionsTrackerView(BaseAppView)' | |||||
83 | except Exception: |
|
83 | except Exception: | |
84 | log.exception('Failed to read exc data from:{}'.format(full_path)) |
|
84 | log.exception('Failed to read exc data from:{}'.format(full_path)) | |
85 | pass |
|
85 | pass | |
86 |
|
||||
87 | # convert our timestamp to a date obj, for nicer representation |
|
86 | # convert our timestamp to a date obj, for nicer representation | |
88 | exc['exc_utc_date'] = time_to_utcdatetime(exc['exc_timestamp']) |
|
87 | exc['exc_utc_date'] = time_to_utcdatetime(exc['exc_timestamp']) | |
89 | exception_list.append(exc) |
|
|||
90 |
|
88 | |||
91 | count += 1 |
|
89 | type_present = exc.get('exc_type') | |
92 | if limit and count >= limit: |
|
90 | if type_filter: | |
|
91 | if type_present and type_present == type_filter: | |||
|
92 | exception_list.append(exc) | |||
|
93 | else: | |||
|
94 | exception_list.append(exc) | |||
|
95 | ||||
|
96 | if limit and len(exception_list) >= limit: | |||
93 | break |
|
97 | break | |
94 | return exception_list |
|
98 | return exception_list | |
95 |
|
99 | |||
@@ -103,8 +107,10 b' class ExceptionsTrackerView(BaseAppView)' | |||||
103 | c = self.load_default_context() |
|
107 | c = self.load_default_context() | |
104 | c.active = 'exceptions_browse' |
|
108 | c.active = 'exceptions_browse' | |
105 | c.limit = safe_int(self.request.GET.get('limit')) or 50 |
|
109 | c.limit = safe_int(self.request.GET.get('limit')) or 50 | |
|
110 | c.type_filter = self.request.GET.get('type_filter') | |||
106 | c.next_limit = c.limit + 50 |
|
111 | c.next_limit = c.limit + 50 | |
107 |
c.exception_list = self.get_all_exceptions( |
|
112 | c.exception_list = self.get_all_exceptions( | |
|
113 | read_metadata=True, limit=c.limit, type_filter=c.type_filter) | |||
108 | c.exception_list_count = self.count_all_exceptions() |
|
114 | c.exception_list_count = self.count_all_exceptions() | |
109 | c.exception_store_dir = exc_tracking.get_exc_store() |
|
115 | c.exception_store_dir = exc_tracking.get_exc_store() | |
110 | return self._get_template_context(c) |
|
116 | return self._get_template_context(c) | |
@@ -132,12 +138,20 b' class ExceptionsTrackerView(BaseAppView)' | |||||
132 | def exception_delete_all(self): |
|
138 | def exception_delete_all(self): | |
133 | _ = self.request.translate |
|
139 | _ = self.request.translate | |
134 | c = self.load_default_context() |
|
140 | c = self.load_default_context() | |
|
141 | type_filter = self.request.POST.get('type_filter') | |||
135 |
|
142 | |||
136 | c.active = 'exceptions' |
|
143 | c.active = 'exceptions' | |
137 | all_exc = self.get_all_exceptions() |
|
144 | all_exc = self.get_all_exceptions(read_metadata=bool(type_filter), type_filter=type_filter) | |
138 |
exc_count = |
|
145 | exc_count = 0 | |
|
146 | ||||
139 | for exc in all_exc: |
|
147 | for exc in all_exc: | |
140 | exc_tracking.delete_exception(exc['exc_id'], prefix=None) |
|
148 | if type_filter: | |
|
149 | if exc.get('exc_type') == type_filter: | |||
|
150 | exc_tracking.delete_exception(exc['exc_id'], prefix=None) | |||
|
151 | exc_count += 1 | |||
|
152 | else: | |||
|
153 | exc_tracking.delete_exception(exc['exc_id'], prefix=None) | |||
|
154 | exc_count += 1 | |||
141 |
|
155 | |||
142 | h.flash(_('Removed {} Exceptions').format(exc_count), category='success') |
|
156 | h.flash(_('Removed {} Exceptions').format(exc_count), category='success') | |
143 | raise HTTPFound(h.route_path('admin_settings_exception_tracker')) |
|
157 | raise HTTPFound(h.route_path('admin_settings_exception_tracker')) |
@@ -6,18 +6,24 b'' | |||||
6 | % if c.exception_list_count == 1: |
|
6 | % if c.exception_list_count == 1: | |
7 | ${_('There is {} stored exception.').format(c.exception_list_count)} |
|
7 | ${_('There is {} stored exception.').format(c.exception_list_count)} | |
8 | % else: |
|
8 | % else: | |
9 | ${_('There are {} stored exceptions.').format(c.exception_list_count)} |
|
9 | ${_('There are total {} stored exceptions.').format(c.exception_list_count)} | |
10 | % endif |
|
10 | % endif | |
|
11 | <br/> | |||
11 | ${_('Store directory')}: ${c.exception_store_dir} |
|
12 | ${_('Store directory')}: ${c.exception_store_dir} | |
12 |
|
13 | |||
13 | ${h.secure_form(h.route_path('admin_settings_exception_tracker_delete_all'), request=request)} |
|
14 | ${h.secure_form(h.route_path('admin_settings_exception_tracker_delete_all'), request=request)} | |
14 | <div style="margin: 0 0 20px 0" class="fake-space"></div> |
|
15 | <div style="margin: 0 0 20px 0" class="fake-space"></div> | |
15 |
|
16 | <input type="hidden" name="type_filter", value="${c.type_filter}"> | ||
16 | <div class="field"> |
|
17 | <div class="field"> | |
17 | <button class="btn btn-small btn-danger" type="submit" |
|
18 | <button class="btn btn-small btn-danger" type="submit" | |
18 | onclick="return confirm('${_('Confirm to delete all exceptions')}');"> |
|
19 | onclick="return confirm('${_('Confirm to delete all exceptions')}');"> | |
19 | <i class="icon-remove-sign"></i> |
|
20 | <i class="icon-remove-sign"></i> | |
20 | ${_('Delete All')} |
|
21 | % if c.type_filter: | |
|
22 | ${_('Delete All `{}`').format(c.type_filter)} | |||
|
23 | % else: | |||
|
24 | ${_('Delete All')} | |||
|
25 | % endif | |||
|
26 | ||||
21 | </button> |
|
27 | </button> | |
22 | </div> |
|
28 | </div> | |
23 |
|
29 | |||
@@ -48,7 +54,9 b'' | |||||
48 | <td><a href="${h.route_path('admin_settings_exception_tracker_show', exception_id=tb['exc_id'])}"><code>${tb['exc_id']}</code></a></td> |
|
54 | <td><a href="${h.route_path('admin_settings_exception_tracker_show', exception_id=tb['exc_id'])}"><code>${tb['exc_id']}</code></a></td> | |
49 | <td>${h.format_date(tb['exc_utc_date'])}</td> |
|
55 | <td>${h.format_date(tb['exc_utc_date'])}</td> | |
50 | <td>${tb['app_type']}</td> |
|
56 | <td>${tb['app_type']}</td> | |
51 |
<td> |
|
57 | <td> | |
|
58 | <a href="${h.current_route_path(request, type_filter=tb['exc_type'])}">${tb['exc_type']}</a> | |||
|
59 | </td> | |||
52 | </tr> |
|
60 | </tr> | |
53 | <% cnt -=1 %> |
|
61 | <% cnt -=1 %> | |
54 | % endfor |
|
62 | % endfor |
General Comments 0
You need to be logged in to leave comments.
Login now