Allow to show site directory in local file browser

This commit is contained in:
shortcutme 2017-10-04 12:31:57 +02:00
parent d0f85f3d04
commit 53da40fe5d
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -875,15 +875,24 @@ class UiWebsocket(object):
sys.modules["main"].file_server.stop() sys.modules["main"].file_server.stop()
sys.modules["main"].ui_server.stop() sys.modules["main"].ui_server.stop()
def actionServerShowdirectory(self, to, directory="backup"): def actionServerShowdirectory(self, to, directory="backup", inner_path=""):
if self.request.env["REMOTE_ADDR"] != "127.0.0.1":
return self.response(to, {"error": "Only clients from 127.0.0.1 allowed to run this command"})
import webbrowser import webbrowser
if directory == "backup": if directory == "backup":
directory = os.path.abspath(config.data_dir) path = os.path.abspath(config.data_dir)
elif directory == "log": elif directory == "log":
directory = os.path.abspath(config.log_dir) path = os.path.abspath(config.log_dir)
elif directory == "site":
path = os.path.abspath(self.site.storage.getPath(helper.getDirname(inner_path)))
webbrowser.open('file://' + directory) if os.path.isdir(path):
self.log.debug("Opening: %s" % path)
webbrowser.open('file://' + path)
return self.response(to, "ok")
else:
return self.response(to, {"error": "Not a directory"})
def actionConfigSet(self, to, key, value): def actionConfigSet(self, to, key, value):
if key not in ["tor", "language"]: if key not in ["tor", "language"]: