mirror of
https://github.com/searxng/searxng.git
synced 2024-12-01 23:21:09 +00:00
[fix] resolve minor review issues
This commit is contained in:
parent
e45a269ecb
commit
dff879d07d
2 changed files with 25 additions and 23 deletions
|
@ -56,6 +56,9 @@ if not settings_path:
|
||||||
with open(settings_path, 'r', encoding='utf-8') as settings_yaml:
|
with open(settings_path, 'r', encoding='utf-8') as settings_yaml:
|
||||||
settings = safe_load(settings_yaml)
|
settings = safe_load(settings_yaml)
|
||||||
|
|
||||||
|
if settings['ui']['static_path']:
|
||||||
|
static_path = settings['ui']['static_path']
|
||||||
|
|
||||||
'''
|
'''
|
||||||
enable debug if
|
enable debug if
|
||||||
the environnement variable SEARX_DEBUG is 1 or true
|
the environnement variable SEARX_DEBUG is 1 or true
|
||||||
|
|
|
@ -17,7 +17,7 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
|
||||||
|
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from os import listdir, mkdir, remove
|
from os import makedirs, remove
|
||||||
from os.path import abspath, basename, dirname, exists, isdir, join
|
from os.path import abspath, basename, dirname, exists, isdir, join
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from sys import exit, version_info
|
from sys import exit, version_info
|
||||||
|
@ -99,14 +99,14 @@ def load_external_plugins(plugin_names):
|
||||||
|
|
||||||
pkg.__base_path = dirname(abspath(pkg.__file__))
|
pkg.__base_path = dirname(abspath(pkg.__file__))
|
||||||
|
|
||||||
fix_package_resources(pkg, name)
|
prepare_package_resources(pkg, name)
|
||||||
|
|
||||||
plugins.append(pkg)
|
plugins.append(pkg)
|
||||||
logger.debug('plugin "{0}" loaded'.format(name))
|
logger.debug('plugin "{0}" loaded'.format(name))
|
||||||
return plugins
|
return plugins
|
||||||
|
|
||||||
|
|
||||||
def check_resource(base_path, resource_path, name, target_dir, plugin_dir):
|
def sync_resource(base_path, resource_path, name, target_dir, plugin_dir):
|
||||||
dep_path = join(base_path, resource_path)
|
dep_path = join(base_path, resource_path)
|
||||||
file_name = basename(dep_path)
|
file_name = basename(dep_path)
|
||||||
resource_path = join(target_dir, file_name)
|
resource_path = join(target_dir, file_name)
|
||||||
|
@ -121,12 +121,11 @@ def check_resource(base_path, resource_path, name, target_dir, plugin_dir):
|
||||||
return join('plugins', plugin_dir, file_name)
|
return join('plugins', plugin_dir, file_name)
|
||||||
|
|
||||||
|
|
||||||
def fix_package_resources(pkg, name):
|
def prepare_package_resources(pkg, name):
|
||||||
plugin_dir = 'plugin_' + name
|
plugin_dir = 'plugin_' + name
|
||||||
target_dir = join(static_path, 'plugins', plugin_dir)
|
target_dir = join(static_path, 'plugins', plugin_dir)
|
||||||
if not isdir(target_dir):
|
|
||||||
try:
|
try:
|
||||||
mkdir(target_dir)
|
makedirs(target_dir, exist_ok=True)
|
||||||
except:
|
except:
|
||||||
logger.critical('failed to create resource directory {0} for plugin {1}'.format(target_dir, name))
|
logger.critical('failed to create resource directory {0} for plugin {1}'.format(target_dir, name))
|
||||||
exit(3)
|
exit(3)
|
||||||
|
@ -136,13 +135,13 @@ def fix_package_resources(pkg, name):
|
||||||
if hasattr(pkg, 'js_dependencies'):
|
if hasattr(pkg, 'js_dependencies'):
|
||||||
resources.extend(map(basename, pkg.js_dependencies))
|
resources.extend(map(basename, pkg.js_dependencies))
|
||||||
pkg.js_dependencies = tuple([
|
pkg.js_dependencies = tuple([
|
||||||
check_resource(pkg.__base_path, x, name, target_dir, plugin_dir)
|
sync_resource(pkg.__base_path, x, name, target_dir, plugin_dir)
|
||||||
for x in pkg.js_dependencies
|
for x in pkg.js_dependencies
|
||||||
])
|
])
|
||||||
if hasattr(pkg, 'css_dependencies'):
|
if hasattr(pkg, 'css_dependencies'):
|
||||||
resources.extend(map(basename, pkg.css_dependencies))
|
resources.extend(map(basename, pkg.css_dependencies))
|
||||||
pkg.css_dependencies = tuple([
|
pkg.css_dependencies = tuple([
|
||||||
check_resource(pkg.__base_path, x, name, target_dir, plugin_dir)
|
sync_resource(pkg.__base_path, x, name, target_dir, plugin_dir)
|
||||||
for x in pkg.css_dependencies
|
for x in pkg.css_dependencies
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue