nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 113 lines 5.5 kB view raw
1diff --git c/auto_cpufreq/bin/auto_cpufreq.py i/auto_cpufreq/bin/auto_cpufreq.py 2index 7192366..0bf087e 100755 3--- c/auto_cpufreq/bin/auto_cpufreq.py 4+++ i/auto_cpufreq/bin/auto_cpufreq.py 5@@ -149,41 +149,7 @@ def main(monitor, live, daemon, install, update, remove, force, config, stats, g 6 deploy_daemon() 7 deploy_complete_msg() 8 elif update: 9- root_check() 10- custom_dir = "/opt/auto-cpufreq/source" 11- for arg in sys.argv: 12- if arg.startswith("--update="): 13- custom_dir = arg.split("=")[1] 14- sys.argv.remove(arg) 15- 16- if "--update" in sys.argv: 17- update = True 18- sys.argv.remove("--update") 19- if len(sys.argv) == 2: custom_dir = sys.argv[1] 20- 21- if IS_INSTALLED_WITH_SNAP: 22- print("Detected auto-cpufreq was installed using snap") 23- # refresh snap directly using this command 24- # path wont work in this case 25- 26- print("Please update using snap package manager, i.e: `sudo snap refresh auto-cpufreq`.") 27- #check for AUR 28- elif IS_INSTALLED_WITH_AUR: print("Arch-based distribution with AUR support detected. Please refresh auto-cpufreq using your AUR helper.") 29- else: 30- is_new_update = check_for_update() 31- if not is_new_update: return 32- ans = input("Do you want to update auto-cpufreq to the latest release? [Y/n]: ").strip().lower() 33- if not os.path.exists(custom_dir): os.makedirs(custom_dir) 34- if os.path.exists(os.path.join(custom_dir, "auto-cpufreq")): rmtree(os.path.join(custom_dir, "auto-cpufreq")) 35- if ans in ['', 'y', 'yes']: 36- remove_daemon() 37- remove_complete_msg() 38- new_update(custom_dir) 39- print("enabling daemon") 40- run(["auto-cpufreq", "--install"]) 41- print("auto-cpufreq is installed with the latest version") 42- run(["auto-cpufreq", "--version"]) 43- else: print("Aborted") 44+ print("update is disabled in the nix package") 45 elif remove: 46 root_check() 47 if IS_INSTALLED_WITH_SNAP: 48diff --git c/auto_cpufreq/core.py i/auto_cpufreq/core.py 49index b51d55d..99eeed8 100755 50--- c/auto_cpufreq/core.py 51+++ i/auto_cpufreq/core.py 52@@ -7,9 +7,8 @@ from math import isclose 53 from pathlib import Path 54 from pickle import dump, load 55 from re import search 56-from requests import get, exceptions 57 from shutil import copy 58-from subprocess import call, check_output, DEVNULL, getoutput, run 59+from subprocess import call, DEVNULL, getoutput, run 60 from time import sleep 61 from warnings import filterwarnings 62 63@@ -105,49 +104,7 @@ def app_version(): 64 except Exception as e: print(repr(e)) 65 66 def check_for_update(): 67- # returns True if a new release is available from the GitHub repo 68- 69- # Specify the repository and package name 70- # IT IS IMPORTANT TO THAT IF THE REPOSITORY STRUCTURE IS CHANGED, THE FOLLOWING FUNCTION NEEDS TO BE UPDATED ACCORDINGLY 71- # Fetch the latest release information from GitHub API 72- latest_release_url = GITHUB.replace("github.com", "api.github.com/repos") + "/releases/latest" 73- try: 74- response = get(latest_release_url) 75- if response.status_code == 200: latest_release = response.json() 76- else: 77- message = response.json().get("message") 78- print("Error fetching recent release!") 79- if message is not None and message.startswith("API rate limit exceeded"): 80- print("GitHub Rate limit exceeded. Please try again later within 1 hour or use different network/VPN.") 81- else: print("Unexpected status code:", response.status_code) 82- return False 83- except (exceptions.ConnectionError, exceptions.Timeout, 84- exceptions.RequestException, exceptions.HTTPError): 85- print("Error Connecting to server!") 86- return False 87- 88- latest_version = latest_release.get("tag_name") 89- 90- if latest_version is not None: 91- # Get the current version of auto-cpufreq 92- # Extract version number from the output string 93- output = check_output(['auto-cpufreq', '--version']).decode('utf-8') 94- try: version_line = next((search(r'\d+\.\d+\.\d+', line).group() for line in output.split('\n') if line.startswith('auto-cpufreq version')), None) 95- except AttributeError: 96- print("Error Retrieving Current Version!") 97- exit(1) 98- installed_version = "v" + version_line 99- #Check whether the same is installed or not 100- # Compare the latest version with the installed version and perform update if necessary 101- if latest_version == installed_version: 102- print("auto-cpufreq is up to date") 103- return False 104- else: 105- print(f"Updates are available,\nCurrent version: {installed_version}\nLatest version: {latest_version}") 106- print("Note that your previous custom settings might be erased with the following update") 107- return True 108- # Handle the case where "tag_name" key doesn't exist 109- else: print("Malformed Released data!\nReinstall manually or Open an issue on GitHub for help!") 110+ pass 111 112 def new_update(custom_dir): 113 os.chdir(custom_dir)