Skip to content

Commit

Permalink
Merge pull request #97 from h3xp/dev
Browse files Browse the repository at this point in the history
Dev v2.5.3
  • Loading branch information
mrludo001 authored Dec 31, 2022
2 parents 41b8244 + 1379af0 commit d8d259d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 17 additions & 7 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def get_available_updates(megadrive: str, status=False):
modified_date = node["ts"]
if node["t"] == 0:
file_size = convert_filesize(node["s"])
available_updates.append([file_name, file_id, modified_date, file_size])
available_updates.append([file_name, file_id, modified_date, file_size, node["s"]])
return available_updates


Expand Down Expand Up @@ -2056,7 +2056,8 @@ def get_manual_updates(path: str, available_updates: list):
for update in available_updates:
# file name check is not necessary so skip it
# if update[0] == os.path.basename(file):
if update[3] == convert_filesize(os.path.getsize(file)):
#if update[3] == convert_filesize(os.path.getsize(file)):
if update[4] == os.path.getsize(file):
manual_updates.append(update)

return manual_updates
Expand Down Expand Up @@ -2353,6 +2354,15 @@ def sort_official_updates(updates: list):
return retval


def get_total_size_of_updates(updates: list):
total_size = 0

for update in updates:
total_size += int(update[4])

return convert_filesize(str(total_size))


def official_improvements_dialog(update_dir=None, delete=False, available_updates=[]):
megadrive = check_drive()
check_wrong_permissions()
Expand Down Expand Up @@ -2393,15 +2403,15 @@ def official_improvements_dialog(update_dir=None, delete=False, available_update
menu_choices = []
all_updates = []
update_needed = False
needed_updates = 0
recommended_updates = 0
needed_updates = []
recommended_updates = []
for update in available_updates:
update_applied = is_update_applied(update[0], update[2])
if update_applied == False:
needed_updates += 1
needed_updates.append(update)
update_needed = (update_needed == True or update_applied == False)
if update_needed == True:
recommended_updates += 1
recommended_updates.append(update)
if show_all_updates == True or update_needed == True:
#TO DO: check if update has been installed from config and make True
all_updates.append(update)
Expand All @@ -2414,7 +2424,7 @@ def official_improvements_dialog(update_dir=None, delete=False, available_update
return

update_text = "Available" if show_all_updates == True else "Recommended"
code, tags = d.checklist(text="Auto Clean is {}\nShow All Updates is {}\n\nNumber of available updates: {}\nNumber of updates needed: {}\nRecommended number of updates: {}\n\n{} Updates".format("on" if auto_clean == True else "off", "on" if show_all_updates == True else "off", len(available_updates), needed_updates, recommended_updates, update_text),
code, tags = d.checklist(text="Auto Clean is {}\nShow All Updates is {}\n\nNumber of available updates: {} ({})\nNumber of updates needed: {} ({})\nRecommended number of updates: {} ({})\n\n{} Updates".format("on" if auto_clean == True else "off", "on" if show_all_updates == True else "off", len(available_updates), get_total_size_of_updates(available_updates), len(needed_updates), get_total_size_of_updates(needed_updates), len(recommended_updates), get_total_size_of_updates(recommended_updates), update_text),
choices=menu_choices,
ok_label="Apply Selected",
extra_button=True,
Expand Down
2 changes: 1 addition & 1 deletion update_tool.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[CONFIG_ITEMS]
tool_ver = 2.5.2
tool_ver = 2.5.3
home_dir = /home/pi/.update_tool
home_command = update.py
home_exe = python3
Expand Down

0 comments on commit d8d259d

Please sign in to comment.