Skip to content
Snippets Groups Projects
Verified Commit a817add1 authored by Davide Gardenal's avatar Davide Gardenal
Browse files

upgrade_oniro_utils: create find_latest_backup


Signed-off-by: Davide Gardenal's avatarDavide Gardenal <davide.gardenal@huawei.com>
parent 03a32d3c
No related branches found
No related tags found
No related merge requests found
...@@ -11,10 +11,34 @@ def get_manifest_projects(): ...@@ -11,10 +11,34 @@ def get_manifest_projects():
projects in Oniro's manifest. projects in Oniro's manifest.
Returns: Returns:
A new list of dict with all the projects' properties A new list of dict with all the projects' properties.
""" """
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
tree = ET.parse("oniro/manifests/default.xml") tree = ET.parse("oniro/manifests/default.xml")
root = tree.getroot() root = tree.getroot()
return [project.attrib for project in root.findall("project")] return [project.attrib for project in root.findall("project")]
def find_latest_backup():
"""
Find the latest backup of Oniro. This will search only in the
current directory.
Returns:
The latest backup name if found, None otherwise.
"""
from pathlib import Path
this_dir = Path(".")
backup_info_list = []
for item in this_dir.iterdir():
if "upgrade_oniro_backup" in item.name:
backup_info = {
"name": item.name,
"timestamp": item.name.split("-")[1].split(".")[:2]
}
print(backup_info)
backup_info_list.append(backup_info)
return max(backup_info_list, key=lambda x: int(f'{x["timestamp"][0]}{x["timestamp"][1]}'))["name"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment