* better checks

* moved expose code to plugin
 * download-buttons are not working as expected atm (needs change in plugin download mechanism)
This commit is contained in:
age 2007-07-31 09:59:16 +00:00
parent 1f395025a3
commit d5c630393a
3 changed files with 23 additions and 23 deletions

View File

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

View File

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

View File

@ -434,21 +434,6 @@ class WebInterfaceSites:
time.sleep(1) time.sleep(1)
yield "</ul></p></html>" 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 ########################## ##################### input checker ##########################