IQ.Pilot Prebuilt Release @ 27f668a
This commit is contained in:
21
iqpilot/system/loggerd/uploader_common.py
Normal file
21
iqpilot/system/loggerd/uploader_common.py
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
|
||||
from iqpilot.common.swaglog import cloudlog
|
||||
|
||||
|
||||
def get_directory_sort(d: str) -> list[str]:
|
||||
prefix = ["0"] if d.startswith("2024-") else ["1"]
|
||||
return prefix + [s.rjust(10, "0") for s in d.rsplit("--", 1)]
|
||||
|
||||
|
||||
def listdir_by_creation(d: str) -> list[str]:
|
||||
if not os.path.isdir(d):
|
||||
return []
|
||||
|
||||
try:
|
||||
paths = [f for f in os.listdir(d) if os.path.isdir(os.path.join(d, f))]
|
||||
return sorted(paths, key=get_directory_sort)
|
||||
except OSError:
|
||||
cloudlog.exception("uploader_common.listdir_by_creation_failed")
|
||||
return []
|
||||
Reference in New Issue
Block a user