Skip to content

Commit

Permalink
Use pathlib instead of glob for loading updater files
Browse files Browse the repository at this point in the history
This allows for recursively loading personal_commands which enables
flexibility in distributing them as separate directories, for example
loading the ATV command library as as a submodule.
  • Loading branch information
jinnatar authored and Jinna Kiisuo committed Sep 24, 2023
1 parent 6fdc6e3 commit 2c0a1d4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mapadroid/updater/updater.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import asyncio
import glob
import json
import os
import re
import time
from asyncio import CancelledError, Task
from datetime import datetime, timedelta
from pathlib import Path
from typing import AsyncGenerator, Dict, List, Optional, Tuple, Union

import asyncio_rlock
Expand Down Expand Up @@ -98,14 +98,14 @@ async def _load_jobs(self):
if os.path.exists('commands.json'):
await self._load_jobs_from_file('commands.json')
# 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:
await self._load_jobs_from_file(command_file)
except Exception as e:
logger.error('Cannot add job {} - Reason: {}', command_file, e)

# Read all .apk files in the upload dir
for apk_file in glob.glob(str(MadGlobals.application_args.upload_path) + "/*.apk"):
for apk_file in Path(MadGlobals.application_args.upload_path).rglob("*.apk"):
created: int = int(os.path.getmtime(apk_file))

self._available_jobs[os.path.basename(apk_file)] = [SubJob(TYPE=JobType.INSTALLATION,
Expand Down

0 comments on commit 2c0a1d4

Please sign in to comment.