Fix diagnosis/ vs. diagnosis.py ambiguity, breaking python imports

This commit is contained in:
Alexandre Aubin 2021-11-18 01:23:00 +01:00
parent 7bfa15d471
commit bc9a9414a2
15 changed files with 9 additions and 9 deletions

View file

@ -37,7 +37,7 @@ full-tests:
- *install_debs - *install_debs
- yunohost tools postinstall -d domain.tld -p the_password --ignore-dyndns --force-diskspace - yunohost tools postinstall -d domain.tld -p the_password --ignore-dyndns --force-diskspace
script: script:
- python3 -m pytest --cov=yunohost tests/ src/tests/ src/diagnosis/ --junitxml=report.xml - python3 -m pytest --cov=yunohost tests/ src/tests/ src/diagnosers/ --junitxml=report.xml
- cd tests - cd tests
- bash test_helpers.sh - bash test_helpers.sh
needs: needs:
@ -59,7 +59,7 @@ test-i18n-keys:
changes: changes:
- locales/en.json - locales/en.json
- src/*.py - src/*.py
- src/diagnosis/*.py - src/diagnosers/*.py
test-translation-format-consistency: test-translation-format-consistency:
extends: .test-stage extends: .test-stage

View file

@ -660,7 +660,7 @@ class Diagnoser:
def _list_diagnosis_categories(): def _list_diagnosis_categories():
paths = glob.glob(os.path.dirname(__file__) + "/diagnosis/??-*.py") paths = glob.glob(os.path.dirname(__file__) + "/diagnosers/??-*.py")
names = sorted([os.path.basename(path)[: -len(".py")] for path in paths]) names = sorted([os.path.basename(path)[: -len(".py")] for path in paths])
return names return names
@ -670,7 +670,7 @@ def _load_diagnoser(diagnoser_name):
logger.debug(f"Loading diagnoser {diagnoser_name}") logger.debug(f"Loading diagnoser {diagnoser_name}")
paths = glob.glob(os.path.dirname(__file__) + f"/diagnosis/??-{diagnoser_name}.py") paths = glob.glob(os.path.dirname(__file__) + f"/diagnosers/??-{diagnoser_name}.py")
if len(paths) != 1: if len(paths) != 1:
raise YunohostError(f"Uhoh, found several matches (or none?) for diagnoser {diagnoser_name} : {paths}", raw_msg=True) raise YunohostError(f"Uhoh, found several matches (or none?) for diagnoser {diagnoser_name} : {paths}", raw_msg=True)
@ -681,7 +681,7 @@ def _load_diagnoser(diagnoser_name):
# this is python builtin method to import a module using a name, we # this is python builtin method to import a module using a name, we
# use that to import the migration as a python object so we'll be # use that to import the migration as a python object so we'll be
# able to run it in the next loop # able to run it in the next loop
module = import_module("yunohost.diagnosis.{}".format(module_id)) module = import_module("yunohost.diagnosers.{}".format(module_id))
return module.MyDiagnoser() return module.MyDiagnoser()
except Exception as e: except Exception as e:
import traceback import traceback

View file

@ -28,7 +28,7 @@ def find_expected_string_keys():
python_files.extend(glob.glob("src/utils/*.py")) python_files.extend(glob.glob("src/utils/*.py"))
python_files.extend(glob.glob("src/migrations/*.py")) python_files.extend(glob.glob("src/migrations/*.py"))
python_files.extend(glob.glob("src/authenticators/*.py")) python_files.extend(glob.glob("src/authenticators/*.py"))
python_files.extend(glob.glob("src/diagnosis/*.py")) python_files.extend(glob.glob("src/diagnosers/*.py"))
python_files.append("bin/yunohost") python_files.append("bin/yunohost")
for python_file in python_files: for python_file in python_files:
@ -51,7 +51,7 @@ def find_expected_string_keys():
# For each diagnosis, try to find strings like "diagnosis_stuff_foo" (c.f. diagnosis summaries) # For each diagnosis, try to find strings like "diagnosis_stuff_foo" (c.f. diagnosis summaries)
# Also we expect to have "diagnosis_description_<name>" for each diagnosis # Also we expect to have "diagnosis_description_<name>" for each diagnosis
p3 = re.compile(r"[\"\'](diagnosis_[a-z]+_\w+)[\"\']") p3 = re.compile(r"[\"\'](diagnosis_[a-z]+_\w+)[\"\']")
for python_file in glob.glob("src/diagnosis/*.py"): for python_file in glob.glob("src/diagnosers/*.py"):
content = open(python_file).read() content = open(python_file).read()
for m in p3.findall(content): for m in p3.findall(content):
if m.endswith("_"): if m.endswith("_"):

View file

@ -29,7 +29,7 @@ def find_expected_string_keys():
python_files.extend(glob.glob("src/utils/*.py")) python_files.extend(glob.glob("src/utils/*.py"))
python_files.extend(glob.glob("src/migrations/*.py")) python_files.extend(glob.glob("src/migrations/*.py"))
python_files.extend(glob.glob("src/authenticators/*.py")) python_files.extend(glob.glob("src/authenticators/*.py"))
python_files.extend(glob.glob("src/diagnosis/*.py")) python_files.extend(glob.glob("src/diagnosers/*.py"))
python_files.append("bin/yunohost") python_files.append("bin/yunohost")
for python_file in python_files: for python_file in python_files:
@ -52,7 +52,7 @@ def find_expected_string_keys():
# For each diagnosis, try to find strings like "diagnosis_stuff_foo" (c.f. diagnosis summaries) # For each diagnosis, try to find strings like "diagnosis_stuff_foo" (c.f. diagnosis summaries)
# Also we expect to have "diagnosis_description_<name>" for each diagnosis # Also we expect to have "diagnosis_description_<name>" for each diagnosis
p3 = re.compile(r"[\"\'](diagnosis_[a-z]+_\w+)[\"\']") p3 = re.compile(r"[\"\'](diagnosis_[a-z]+_\w+)[\"\']")
for python_file in glob.glob("src/diagnosis/*.py"): for python_file in glob.glob("src/diagnosers/*.py"):
content = open(python_file).read() content = open(python_file).read()
for m in p3.findall(content): for m in p3.findall(content):
if m.endswith("_"): if m.endswith("_"):