diff --git a/mapadroid/utils/updater.py b/mapadroid/utils/updater.py index b4a77fc69..1c1d89fa9 100644 --- a/mapadroid/utils/updater.py +++ b/mapadroid/utils/updater.py @@ -1,4 +1,3 @@ -import glob import json import os import re @@ -6,6 +5,7 @@ from datetime import datetime, timedelta from enum import Enum from multiprocessing import Event, Queue +from pathlib import Path from queue import Empty from threading import RLock, Thread @@ -91,16 +91,16 @@ def init_jobs(self): # load personal commands - for command_file in glob.glob(os.path.join("personal_commands", "*.json")): + for command_file in Path("personal_commands").rglob("*.json"): try: with open(command_file) as personal_command: - peronal_cmd = json.loads(personal_command.read()) - for command in peronal_cmd: + personal_cmd = json.load(personal_command) + for command in personal_cmd: if command in self._commands: logger.error("Command {} already exist - skipping", command) else: logger.info('Loading personal command: {}', command) - self._commands[command] = peronal_cmd[command] + self._commands[command] = personal_cmd[command] except Exception as e: logger.error('Cannot add job {} - Reason: {}', command_file, e)