diff --git a/main.py b/main.py index 5967bc2..333b41d 100644 --- a/main.py +++ b/main.py @@ -594,140 +594,13 @@ def vtoi(version: str): def upgrade_packages(): """ - upgrade_packages(): this function is the main upgrade function for xpykg + upgrade_packages(): this function is a dummy for the upgrade function in xpykg """ - print( - "{}{}[xpykg:note]:{} updating database".format( - Style.BRIGHT, Fore.BLUE, Fore.RESET - ) - ) - - if sync_database() != 0: - print( - "{}{}[xpykg:error]:{} database failed to sync".format( - Style.BRIGHT, Fore.RED, Fore.RESET - ) - ) - return 1 - - version_list = [] - version = [] - - with open("C:\\Program Files\\xpykg\\db.json", "r") as db: - contents = loads(db.read()) - - for i in list(contents.keys()): - try: - if is_installed(i) == True and vtoi(contents[i]["version"]) > vtoi( - get_installed_package_version(i) - ): - version_list.append(i) - version.append(contents[i]["version"]) - except SyntaxError: - continue - - db.close() - - if len(version_list) == 0: - print( - "{}{}[xpykg:info]:{} all packages are up to date".format( - Style.BRIGHT, Fore.BLUE, Fore.RESET - ) - ) - return 0 - else: - print( - "{}{}[xpykg:info]: {}{}{} packages to be upgraded".format( - Style.BRIGHT, Fore.BLUE, Fore.YELLOW, len(version), Fore.RESET - ) - ) - for i in version_list: - print( - "[{}] {} {}{}{} -> {}{}{}".format( - version_list.index(i) + 1, - i, - Fore.RED, - get_installed_package_version(i), - Fore.RESET, - Fore.GREEN, - version[version_list.index(i)], - Fore.RESET, - ) - ) - - print( - "{}{}[xpykg:input]:{} proceed[{}y{}/{}N{}]? ".format( - Style.BRIGHT, - Fore.MAGENTA, - Fore.RESET, - Fore.GREEN, - Fore.RESET, - Fore.RED, - Fore.RESET, - ), - end="", - ) - choice = input() - failed_packages = [] - if choice not in ["y", "yes", "Y"]: print( - "{}{}[xpykg:error]:{} user decided not to proceed.".format( + "{}{}[xpykg:error]:{} xpykg no longer supports upgrading. remove and install the program to upgrade it.".format( Style.BRIGHT, Fore.RED, Fore.RESET ) - ) - return 1 - - for i in version_list: - print( - "{}{}[xpykg:info]: {}{}{}/{}{}{} removing old version and installing new version of package {}{}{}".format( - Style.BRIGHT, - Fore.BLUE, - Fore.YELLOW, - version_list.index(i) + 1, - Fore.RESET, - Fore.YELLOW, - len(version_list), - Fore.RESET, - Fore.YELLOW, - i, - Fore.RESET, - ) - ) - if uninstall_package(i) == 0: - if install_package(i) == 0: - continue - else: - print( - "{}{}[xpykg:error]:{} package {}{}{} failed to upgrade".format( - Style.BRIGHT, Fore.RED, Fore.RESET, Fore.YELLOW, i, Fore.RESET - ) - ) - failed_packages.append(i) - else: - print( - "{}{}[xpykg:error]:{} package {}{}{} failed to upgrade".format( - Style.BRIGHT, Fore.RED, Fore.RESET, Fore.YELLOW, i, Fore.RESET - ) - ) - failed_packages.append(i) - - if len(failed_packages) == 0: - print( - "{}{}[xpykg:success]:{} all packages were upgraded sucessfully".format( - Style.BRIGHT, Fore.GREEN, Fore.RESET - ) - ) - else: - with open("C:\\Program Files\\xpykg\\pkgs_failed_to_upgrade", "w") as file: - file.write(str(failed_packages)) - file.close() - - print( - "{}{}[xpykg:error]:{} some packages failed to upgrade".format( - Style.BRIGHT, Fore.RED, Fore.RESET - ) - ) return 1