Browse Source

* better checks

* moved expose code to plugin
 * download-buttons are not working as expected atm (needs change in plugin download mechanism)
master
age 15 years ago
parent
commit
d5c630393a
  1. 29
      plugins/logs/logs.py
  2. 2
      plugins/logs/show_log.cs
  3. 15
      src/cryptobox/web/sites.py

29
plugins/logs/logs.py

@ -73,18 +73,19 @@ class logs(cryptobox.plugins.base.CryptoBoxPlugin):
self.cbox.prefs["Log"]["Destination"].lower()
## this generates more download buttons if the files are available
try:
syslogfile = self.defaults["syslogfile"].lower()
if os.access(syslogfile, os.R_OK):
if "syslogfile" in self.defaults:
try:
syslogfile = self.defaults["syslogfile"]
except KeyError:
self.cbox.log.error("could not evaluate the config setting: "
+ "[logs]->syslogfile")
if syslogfile and os.access(syslogfile, os.R_OK):
self.cbox.log.info("[logs]->syslogfile: '%s' will be exported" % syslogfile)
self.hdf[self.hdf_prefix + "syslogfile"] = "readable"
self.cbox.prefs["Log"]["syslogfile"] = syslogfile
else:
self.cbox.log.warn("[logs]->syslogfile: '%s' is not readable for cryptobox user" % syslogfile)
self.hdf[self.hdf_prefix + "syslogfile"] = "not readable"
except KeyError:
self.cbox.log.error(
"could not evaluate the config setting: "
+ "[logs]->syslogfile")
return "show_log"
@ -94,12 +95,26 @@ class logs(cryptobox.plugins.base.CryptoBoxPlugin):
**kargs are necessary - we have to ignore 'weblang' and so on ...
"""
##TODO: check the download url to know which file is wanted
if self.cbox.prefs["Log"]["syslogfile"]:
try:
syslogfile = self.cbox.prefs["Log"]["syslogfile"]
except KeyError:
self.cbox.log.error("could not evaluate the config setting: "
+ "[logs]->syslogfile %s")
if syslogfile and os.access(syslogfile, os.R_OK):
return cherrypy.lib.cptools.serveFile(syslogfile,
disposition="attachment", name="syslog.txt")
else:
self.cbox.log.error("'%s' could not be exposed" % syslogfile)
log_file = self.__get_log_destination_file()
if log_file is None:
return ""
else:
return cherrypy.lib.cptools.serveFile(log_file,
disposition="attachment", name="cryptobox_logfile.txt")
def get_status(self):
"""The current status includes the log configuration details.

2
plugins/logs/show_log.cs

@ -71,7 +71,7 @@
</p>
</form>
<?cs if:Data.Plugins.logs.syslogfile == "readable" ?>
<?cs call:print_form_header("download-syslog", "syslog") ?>
<?cs call:print_form_header("download-syslog", "downloads/logs/syslog") ?>
<p style="text-align:center">
<button type="submit" value="refresh"><?cs
var:html_escape(Lang.Plugins.logs.Text.DownloadSysLogFile) ?></button>

15
src/cryptobox/web/sites.py

@ -434,21 +434,6 @@ class WebInterfaceSites:
time.sleep(1)
yield "</ul></p></html>"
@cherrypy.expose
def syslog(self, weblang="", help="0", device=None):
"""export syslog
"""
from cherrypy.lib.cptools import serveFile
try:
syslogfile = self.cbox.prefs["PluginSettings"]["logs"]["syslogfile"]
if os.access(syslogfile, os.R_OK):
return serveFile(syslogfile, disposition="attachment", name="syslog")
else:
self.cbox.log.error("'%s' could not be exposed" % syslogfile)
except KeyError:
self.cbox.log.error(
"could not evaluate the config setting: "
+ "[logs]->syslogfile %s")
##################### input checker ##########################

Loading…
Cancel
Save