Add a button to easily clear server logs in Preferences->Sharing over the net->Show server logs. Fixes #1730046 [Add a button to clear Content server log](https://bugs.launchpad.net/calibre/+bug/1730046)

This commit is contained in:
Kovid Goyal 2017-11-30 10:26:13 +05:30
parent d5445e6ef1
commit 0ada98b5ec
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1059,6 +1059,21 @@ class ConfigWidget(ConfigWidgetBase):
bx = QDialogButtonBox(QDialogButtonBox.Ok)
layout.addWidget(bx)
bx.accepted.connect(d.accept)
b = bx.addButton(_('&Clear logs'), bx.ActionRole)
def clear_logs():
if getattr(self.server, 'is_running', False):
return error_dialog(d, _('Server running'), _(
'Cannot clear logs while the server is running. First stop the server.'), show=True)
for x in (log_error_file, log_access_file):
try:
os.remove(x)
except EnvironmentError as err:
if err.errno != errno.ENOENT:
raise
el.setPlainText(''), al.setPlainText('')
b.clicked.connect(clear_logs)
d.show()
def save_changes(self):