Codebase list sugar-log-activity / 50c0331
Remove log file from list when deleted When logs are deleted by the user they are removed from the list, except logs from previous Sugar sessions, because they were not monitored for change. - add previous logs to the watcher, - on a changed event, convert the absolute path into displayed path, - refactor common code for Gio.File and Gio.FileMonitor, - update line numbers in translations template. Regression was introduced in 3673659a2ef602a507619f1448226aa546512d27 or the port to GTK+ 3. Fixes https://github.com/sugarlabs/log-activity/issues/12 Co-authored-by: James Cameron <quozl@laptop.org> nswarup14 authored 5 years ago James Cameron committed 5 years ago
2 changed file(s) with 36 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
173173 return 0
174174
175175 def _configure_watcher(self):
176 # Setting where GIO will be watching
177176 for p in self.paths:
178 monitor = Gio.File.new_for_path(p)\
179 .monitor_directory(Gio.FileMonitorFlags.NONE, None)
180 monitor.connect('changed', self._log_file_changed_cb)
181 self._gio_monitors.append(monitor)
182
183 # We don't need monitor old logs, them will no change
177 for q in os.listdir(p):
178 r = os.path.join(p, q)
179 if os.path.isdir(r):
180 self._create_gio_monitor(r)
181 self._create_gio_monitor(p)
184182
185183 for f in self.extra_files:
186 monitor = Gio.File.new_for_path(f)\
187 .monitor_file(Gio.FileMonitorFlags.NONE, None)
188 monitor.connect('changed', self._log_file_changed_cb)
189 self._gio_monitors.append(monitor)
184 self._create_gio_monitor(f)
185
186 def _create_gio_monitor(self, direc_path):
187 monitor = Gio.File.new_for_path(direc_path)\
188 .monitor_directory(Gio.FileMonitorFlags.NONE, None)
189 monitor.connect('changed', self._log_file_changed_cb)
190 self._gio_monitors.append(monitor)
190191
191192 def _log_file_changed_cb(self, monitor, log_file, other_file, event):
192 logfile = log_file.get_basename()
193 filepath = log_file.get_path()
194 logfile = None
195 for p in self.paths:
196 if filepath.startswith(p):
197 logfile = os.path.relpath(filepath, p)
198 break
193199
194200 if event == Gio.FileMonitorEvent.CHANGED:
195201 if logfile in self.logs:
77 msgstr ""
88 "Project-Id-Version: PACKAGE VERSION\n"
99 "Report-Msgid-Bugs-To: \n"
10 "POT-Creation-Date: 2018-09-18 18:56+1000\n"
10 "POT-Creation-Date: 2019-01-23 13:01+0530\n"
1111 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1212 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313 "Language-Team: LANGUAGE <LL@li.org>\n"
3434 msgid "Other"
3535 msgstr ""
3636
37 #: logviewer.py:230
37 #: logviewer.py:239
3838 #, python-format
3939 msgid "ERROR: Failed to look for files in '%(path)s'."
4040 msgstr ""
4141
42 #: logviewer.py:250
42 #: logviewer.py:259
4343 #, python-format
4444 msgid "ERROR: File '%(file)s' does not exist."
4545 msgstr ""
4646
47 #: logviewer.py:255
47 #: logviewer.py:264
4848 #, python-format
4949 msgid "ERROR: Unable to read file '%(file)s'."
5050 msgstr ""
5151
52 #: logviewer.py:403
52 #: logviewer.py:412
5353 #, python-format
5454 msgid "Error: Can't open file '%s'\n"
5555 msgstr ""
5656
57 #: logviewer.py:457
57 #: logviewer.py:466
5858 msgid "Show list of files"
5959 msgstr ""
6060
61 #: logviewer.py:467
61 #: logviewer.py:476
6262 msgid "Word Wrap"
6363 msgstr ""
6464
65 #: logviewer.py:483
65 #: logviewer.py:492
6666 msgid "Previous"
6767 msgstr ""
6868
69 #: logviewer.py:488
69 #: logviewer.py:497
7070 msgid "Next"
7171 msgstr ""
7272
73 #: logviewer.py:502
73 #: logviewer.py:511
7474 msgid "Delete Log File"
7575 msgstr ""
7676
77 #: logviewer.py:608
77 #: logviewer.py:617
7878 msgid "Error"
7979 msgstr ""
8080
81 #: logviewer.py:609
81 #: logviewer.py:618
8282 #, python-format
8383 msgid "%(error)s when deleting %(file)s"
8484 msgstr ""
8585
86 #: logviewer.py:620
86 #: logviewer.py:629
8787 msgid "Log Collector: Capture information"
8888 msgstr ""
8989
90 #: logviewer.py:626
90 #: logviewer.py:635
9191 msgid ""
9292 "This captures information about the system\n"
9393 "and running processes to a journal entry.\n"
9494 "Use this to improve a problem report."
9595 msgstr ""
9696
97 #: logviewer.py:631
97 #: logviewer.py:640
9898 msgid "Capture information"
9999 msgstr ""
100100
101 #: logviewer.py:660
101 #: logviewer.py:669
102102 msgid "Logs not captured"
103103 msgstr ""
104104
105 #: logviewer.py:661
105 #: logviewer.py:670
106106 msgid "The logs could not be captured."
107107 msgstr ""
108108
109 #: logviewer.py:671
109 #: logviewer.py:680
110110 #, python-format
111111 msgid "log-%s"
112112 msgstr ""