diff --git a/.gitignore b/.gitignore index a25196b..22c1bd0 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,7 @@ theonionbox/theonionbox.ltd # Special to The Onion Box # Glide Library comes with a 'dist' directory that we need! !theonionbox/libs/glide-*/dist/ +/node_modules/ + +# Rapydscript +*.pyj-cached \ No newline at end of file diff --git a/LICENSE b/LICENSE index ab450ac..fafc7ad 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 - 2019 Ralph Wetzel +Copyright (c) 2015 - 2020 Ralph Wetzel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/cc/ControlCenter/dialogs/about.pyj b/cc/ControlCenter/dialogs/about.pyj index aa3ae9e..8ba79bb 100644 --- a/cc/ControlCenter/dialogs/about.pyj +++ b/cc/ControlCenter/dialogs/about.pyj @@ -53,7 +53,7 @@ class About(DialogBase): $.post({ 'url': self.base_path + "/" + self.session_id + "/cc/" + "about" - , 'timeout': 2000 + , 'timeout': 5000 }) .done(def(data): $('#about').removeClass('text-center').addClass('text-left') diff --git a/cc/ControlCenter/dialogs/launcher.pyj b/cc/ControlCenter/dialogs/launcher.pyj index 0f2abb8..304b341 100644 --- a/cc/ControlCenter/dialogs/launcher.pyj +++ b/cc/ControlCenter/dialogs/launcher.pyj @@ -27,7 +27,7 @@ class Launcher(DialogBase):
diff --git a/setup.py b/setup.py index a54ac86..3ffb20f 100644 --- a/setup.py +++ b/setup.py @@ -302,14 +302,18 @@ def generate_data_files(data_files): } package_data = { - 'theonionbox': ['config/*', - 'css/*', - 'libs/*', - 'pages/*', - 'scripts/*', - 'sections/*', - 'tor/*' - ] + 'theonionbox': [ + 'config/*', + 'css/*', + 'libs/*', + 'pages/*', + 'scripts/*', + 'sections/*', + 'tor/*' + ], + 'theonionbox.tob.system.windows': [ + 'uptime/*' + ] } package_data_exclude = { @@ -326,13 +330,13 @@ def generate_data_files(data_files): ('service/FreeBSD', ['FreeBSD/theonionbox.sh']), ('service/init.d', ['init.d/theonionbox.sh']), ('service/systemd', ['systemd/theonionbox.service']), - ('service/Docker', ['Docker/Dockerfile', 'Docker/theonionbox.cfg']), - ('support', []), - ('support/osxtemp', []), - ('support/osxtemp/libsmc', ['support/osxtemp/libsmc/LICENSE', 'support/osxtemp/libsmc/Makefile']), - ('support/osxtemp/libsmc/include', ['support/osxtemp/libsmc/include/smc.h']), - ('support/osxtemp/libsmc/src', ['support/osxtemp/libsmc/src/smc.c']), - ('theonionbox/tob/system/windows/uptime', ['theonionbox/tob/system/windows/uptime/*.*']), + ('service/Docker', ['Docker/Dockerfile', 'Docker/theonionbox.cfg']) + # , ('support', []) + # , ('support/osxtemp', []) + # , ('support/osxtemp/libsmc', ['support/osxtemp/libsmc/LICENSE', 'support/osxtemp/libsmc/Makefile']) + # , ('support/osxtemp/libsmc/include', ['support/osxtemp/libsmc/include/smc.h']) + # , ('support/osxtemp/libsmc/src', ['support/osxtemp/libsmc/src/smc.c']) + # , ('theonionbox/tob/system/windows/uptime', ['theonionbox/tob/system/windows/uptime/*.*']), ] # print(generate_data_files(data_files)) @@ -439,6 +443,6 @@ def generate_data_files(data_files): 'Topic :: System :: Networking :: Monitoring', 'Topic :: Utilities', ], - platforms=['Linux', 'Windows', 'MacOS X', 'FreeBSD'], + platforms=['Linux', 'Windows', 'MacOSX', 'FreeBSD'], # ext_modules=extensions(), ) diff --git a/theonionbox/__main__.py b/theonionbox/__main__.py index cf50a7c..78d580c 100644 --- a/theonionbox/__main__.py +++ b/theonionbox/__main__.py @@ -1,29 +1,31 @@ #!/usr/bin/env python -from __future__ import absolute_import -import sys, os +import os +import pathlib +import site +import sys def main(): - # the import executes the scripting part... - if __name__ == '__main__': - # we can't use relative imports here!! - # get an absolute path to the directory that contains mypackage - this_dir = os.path.dirname(os.path.join(os.getcwd(), __file__)) - sys.path.append(os.path.normpath(os.path.join(this_dir, '..'))) + if __name__ == '__main__' and __package__ in ['', None]: - from theonionbox import main as onion_main + # Being __main__, we need to add the current dir to the site-dirs, to allow ABSOLUTE import + # We resolve this Path, as __file__ might be relative, if __name__ == __main__. + cp = pathlib.Path(__file__).resolve() + cp = cp.parent + assert cp.exists() + # Add the current dir to the site-dirs, to allow ABSOLUTE import + site.addsitedir(cp) + from theonionbox import main as onion_main else: + # we're in a package => RELATIVE should work. from .theonionbox import main as onion_main - # ... and main() launches the server! + # The scripting part of theonionbox is being executed as we 'import'. + # Now we launch the server: onion_main() if __name__ == '__main__': - - # args = sys.argv[1:] main() - - diff --git a/theonionbox/css/box.css b/theonionbox/css/box.css index 1644492..f091cb6 100644 --- a/theonionbox/css/box.css +++ b/theonionbox/css/box.css @@ -139,7 +139,9 @@ body { <% from bottle import TemplateError import logging + css_log = logging.getLogger('theonionbox') + for section in sections: special = section[0] diff --git a/theonionbox/pages/cc.html b/theonionbox/pages/cc.html index 4784c69..0ffd1f6 100644 --- a/theonionbox/pages/cc.html +++ b/theonionbox/pages/cc.html @@ -1,7 +1,12 @@ <% - from tob.template_tools import * + try: + from tob.template_tools import * + except ModuleNotFoundError: + from theonionbox.tob.template_tools import * + end + base_path = get('virtual_basepath', '') + '/' %> diff --git a/theonionbox/pages/index.html b/theonionbox/pages/index.html index 8571057..6cd0034 100644 --- a/theonionbox/pages/index.html +++ b/theonionbox/pages/index.html @@ -1,7 +1,11 @@ <% - from tob.template_tools import * + try: + from tob.template_tools import * + except ModuleNotFoundError: + from theonionbox.tob.template_tools import * + end base_path = get('virtual_basepath', '') + '/' session = get('session') @@ -42,6 +46,7 @@ import logging bL = logging.getLogger('theonionbox') div_open = False + for section in sections: if section == '-': @@ -69,16 +74,12 @@ file = 'sections/{0}/{0}.html'.format(section) - if os.path.exists(file): - try: - include(file) - except Exception as exc: - import sys, traceback - exc_type, exc_val, exc_tb = sys.exc_info() - bL.warning("While including '{}' into 'index_page.html':\n{}".format(file, traceback.format_exc())) - end - else: - bL.debug("While including '{0}' into 'index_page.html': '{0}' does not exist!".format(file)) + try: + include(file) + except Exception as exc: + import logging + bL = logging.getLogger('theonionbox') + bL.debug("While including '{}' into 'index_page.html': {}".format(file, exc)) end end out = ('<' + '/div>') if div_open else '' diff --git a/theonionbox/scripts/box.js b/theonionbox/scripts/box.js index f2dc357..8b30da6 100644 --- a/theonionbox/scripts/box.js +++ b/theonionbox/scripts/box.js @@ -7,7 +7,12 @@ <% base_path = get('virtual_basepath', '') + '/' sections = get('sections', []) - from tob.template_tools import * + + try: + from tob.template_tools import * + except ModuleNotFoundError: + from theonionbox.tob.template_tools import * + end login = get('box.js_login', False) token = get('token', 'ThisIsAnError') diff --git a/theonionbox/scripts/cc.js b/theonionbox/scripts/cc.js index 9956c0e..69b5345 100644 --- a/theonionbox/scripts/cc.js +++ b/theonionbox/scripts/cc.js @@ -8072,7 +8072,7 @@ return this.__repr__(); Launcher.prototype.create = function create() { var self = this; var html; - html = "\n