[WebUI] Keep debug js in packaging and fix script lookup
Packaging: - Decided that the debug files are useful for end-user so keep them in package installation. For debug script_type to be usable all debug file need to be avaialble so extjs debug files also included. Script type selection: - Fixed dev and debug request args to be properly decoded on Python 3, otherwise comparison would fail and allowed any case for values. - Modified the choosing of the script type to pick debug if specified as previously always choosing dev type if dev version was True. A rare scenario but useful but now debug is used if specified otherwise use dev. - Changed the order when looking for alternative script types to start with dev so that if debug is specified but missing it uses a similar script type as previously would fallback to normal which is likely undesired.
This commit is contained in:
parent
7d896599b8
commit
ee354eb107
|
@ -564,15 +564,15 @@ class TopLevel(resource.Resource):
|
|||
|
||||
def render(self, request):
|
||||
uri_true = ('true', 'yes', '1')
|
||||
debug_arg = request.args.get('debug', [''])[-1] in uri_true
|
||||
dev_arg = request.args.get('dev', [''])[-1] in uri_true
|
||||
debug_arg = request.args.get('debug', [b''])[-1].decode().lower() in uri_true
|
||||
dev_arg = request.args.get('dev', [b''])[-1].decode().lower() in uri_true
|
||||
dev_ver = 'dev' in common.get_version()
|
||||
|
||||
script_type = 'normal'
|
||||
if debug_arg:
|
||||
script_type = 'debug'
|
||||
# Override debug if dev arg or version.
|
||||
if dev_arg or dev_ver:
|
||||
elif dev_arg or dev_ver:
|
||||
# Also use dev files if development version.
|
||||
script_type = 'dev'
|
||||
|
||||
if not self.js.has_script_type_files(script_type):
|
||||
|
@ -581,9 +581,10 @@ class TopLevel(resource.Resource):
|
|||
'Failed to enable WebUI "%s" mode, script files are missing!',
|
||||
script_type,
|
||||
)
|
||||
# Fallback to checking other types in order and selecting first with files available.
|
||||
# Fallback to checking other types in order and selecting first with
|
||||
# files available. Ordered to start with dev files lookup.
|
||||
for alt_script_type in [
|
||||
x for x in ['normal', 'debug', 'dev'] if x != script_type
|
||||
x for x in ['dev', 'debug', 'normal'] if x != script_type
|
||||
]:
|
||||
if self.js.has_script_type_files(alt_script_type):
|
||||
script_type = alt_script_type
|
||||
|
|
13
setup.py
13
setup.py
|
@ -162,6 +162,8 @@ class CleanWebUI(cmd.Command):
|
|||
|
||||
def run(self):
|
||||
js_basedir = os.path.join(os.path.dirname(__file__), BuildWebUI.JS_DIR)
|
||||
|
||||
# Remove files generated by minify script.
|
||||
for js_src_dir in BuildWebUI.JS_SRC_DIRS:
|
||||
for file_type in ('.js', '-debug.js'):
|
||||
js_file = os.path.join(js_basedir, js_src_dir + file_type)
|
||||
|
@ -171,6 +173,14 @@ class CleanWebUI(cmd.Command):
|
|||
except OSError:
|
||||
pass
|
||||
|
||||
# Remove generated gettext.js
|
||||
js_file = os.path.join(js_basedir, 'gettext.js')
|
||||
print('Deleting {}'.format(js_file))
|
||||
try:
|
||||
os.remove(js_file)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
class BuildTranslations(cmd.Command):
|
||||
description = 'Compile .po files into .mo files & create .desktop file'
|
||||
|
@ -532,9 +542,6 @@ _package_data['deluge.ui.web'] = [
|
|||
]
|
||||
_package_data['deluge.ui.gtkui'] = ['glade/*.ui']
|
||||
|
||||
if 'dev' not in _version:
|
||||
_exclude_package_data['deluge.ui.web'] = ['*-debug.js', '*-debug.css']
|
||||
|
||||
docs_require = ['sphinx', 'recommonmark', 'sphinx-rtd-theme']
|
||||
tests_require = [
|
||||
'coverage',
|
||||
|
|
Loading…
Reference in New Issue