Rewrite code related to GitHub REST API request quota

This commit is contained in:
Hoang Hong Quan
2024-09-29 02:28:32 +07:00
parent 1efe59a82a
commit 88a62db33e
3 changed files with 26 additions and 19 deletions
+17 -6
View File
@@ -60,21 +60,32 @@ class Updater:
self.utils.write_file(self.sha_version, sha_version_info)
def run_update(self):
self.utils.head("Check for update")
self.utils.head("Check for Updates")
print("")
current_sha_version = self.get_current_sha_version()
if not self.github.check_ratelimit():
print("GitHub REST API request quota has been exhausted. Automatic update check is unavailable now.")
print("Please check for updates manually if needed.")
print("")
self.utils.request_input()
return False
latest_sha_version = self.get_latest_sha_version()
print("Current script SHA version: {}".format(current_sha_version))
print("Latest script SHA version: {}".format(latest_sha_version))
print("")
if latest_sha_version != current_sha_version:
print("Updating from version {} to {}\n".format(current_sha_version, latest_sha_version))
print("Updating from version {} to {}".format(current_sha_version, latest_sha_version))
print("")
self.download_update()
self.update_files()
self.save_latest_sha_version(latest_sha_version)
print("\n\n{}\n".format(self.utils.message("The program needs to restart to complete the update process.", "reminder")))
return True
print("\n")
print("The program needs to restart to complete the update process.")
print("\n")
self.utils.request_input()
else:
print("You are already using the latest version")
return False
return latest_sha_version != current_sha_version