Skip to content

Commit 1c5affc

Browse files
committed
Use pathlib instead of glob for loading updater files
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.
1 parent 7b6d406 commit 1c5affc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: mapadroid/updater/updater.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import asyncio
2-
import glob
32
import json
43
import os
54
import re
65
import time
76
from asyncio import CancelledError, Task
87
from datetime import datetime, timedelta
8+
from pathlib import Path
99
from typing import AsyncGenerator, Dict, List, Optional, Tuple, Union
1010

1111
import asyncio_rlock
@@ -98,14 +98,14 @@ async def _load_jobs(self):
9898
if os.path.exists('commands.json'):
9999
await self._load_jobs_from_file('commands.json')
100100
# load personal commands
101-
for command_file in glob.glob(os.path.join("personal_commands", "*.json")):
101+
for command_file in Path("personal_commands").rglob("*.json"):
102102
try:
103103
await self._load_jobs_from_file(command_file)
104104
except Exception as e:
105105
logger.error('Cannot add job {} - Reason: {}', command_file, e)
106106

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

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

0 commit comments

Comments
 (0)