2024-09-19 14:19:46 +00:00
|
|
|
diff --git c/auto_cpufreq/bin/auto_cpufreq.py i/auto_cpufreq/bin/auto_cpufreq.py
|
|
|
|
index 7192366..0bf087e 100755
|
|
|
|
--- c/auto_cpufreq/bin/auto_cpufreq.py
|
|
|
|
+++ i/auto_cpufreq/bin/auto_cpufreq.py
|
|
|
|
@@ -149,41 +149,7 @@ def main(monitor, live, daemon, install, update, remove, force, config, stats, g
|
|
|
|
deploy_daemon()
|
|
|
|
deploy_complete_msg()
|
2024-06-05 15:53:02 +00:00
|
|
|
elif update:
|
|
|
|
- root_check()
|
|
|
|
- custom_dir = "/opt/auto-cpufreq/source"
|
|
|
|
- for arg in sys.argv:
|
|
|
|
- if arg.startswith("--update="):
|
|
|
|
- custom_dir = arg.split("=")[1]
|
|
|
|
- sys.argv.remove(arg)
|
|
|
|
-
|
|
|
|
- if "--update" in sys.argv:
|
|
|
|
- update = True
|
|
|
|
- sys.argv.remove("--update")
|
2024-09-19 14:19:46 +00:00
|
|
|
- if len(sys.argv) == 2: custom_dir = sys.argv[1]
|
2024-06-05 15:53:02 +00:00
|
|
|
-
|
2024-09-19 14:19:46 +00:00
|
|
|
- if IS_INSTALLED_WITH_SNAP:
|
2024-06-05 15:53:02 +00:00
|
|
|
- print("Detected auto-cpufreq was installed using snap")
|
|
|
|
- # refresh snap directly using this command
|
|
|
|
- # path wont work in this case
|
|
|
|
-
|
|
|
|
- print("Please update using snap package manager, i.e: `sudo snap refresh auto-cpufreq`.")
|
|
|
|
- #check for AUR
|
2024-09-19 14:19:46 +00:00
|
|
|
- elif IS_INSTALLED_WITH_AUR: print("Arch-based distribution with AUR support detected. Please refresh auto-cpufreq using your AUR helper.")
|
2024-06-05 15:53:02 +00:00
|
|
|
- else:
|
|
|
|
- is_new_update = check_for_update()
|
2024-09-19 14:19:46 +00:00
|
|
|
- if not is_new_update: return
|
2024-06-05 15:53:02 +00:00
|
|
|
- ans = input("Do you want to update auto-cpufreq to the latest release? [Y/n]: ").strip().lower()
|
2024-09-19 14:19:46 +00:00
|
|
|
- if not os.path.exists(custom_dir): os.makedirs(custom_dir)
|
|
|
|
- if os.path.exists(os.path.join(custom_dir, "auto-cpufreq")): rmtree(os.path.join(custom_dir, "auto-cpufreq"))
|
2024-06-05 15:53:02 +00:00
|
|
|
- if ans in ['', 'y', 'yes']:
|
|
|
|
- remove_daemon()
|
|
|
|
- remove_complete_msg()
|
|
|
|
- new_update(custom_dir)
|
|
|
|
- print("enabling daemon")
|
|
|
|
- run(["auto-cpufreq", "--install"])
|
|
|
|
- print("auto-cpufreq is installed with the latest version")
|
|
|
|
- run(["auto-cpufreq", "--version"])
|
2024-09-19 14:19:46 +00:00
|
|
|
- else: print("Aborted")
|
2024-06-05 15:53:02 +00:00
|
|
|
+ print("update is disabled in the nix package")
|
2024-09-19 14:19:46 +00:00
|
|
|
elif remove:
|
|
|
|
root_check()
|
|
|
|
if IS_INSTALLED_WITH_SNAP:
|
|
|
|
diff --git c/auto_cpufreq/core.py i/auto_cpufreq/core.py
|
|
|
|
index b51d55d..99eeed8 100755
|
|
|
|
--- c/auto_cpufreq/core.py
|
|
|
|
+++ i/auto_cpufreq/core.py
|
|
|
|
@@ -7,9 +7,8 @@ from math import isclose
|
2024-06-05 15:53:02 +00:00
|
|
|
from pathlib import Path
|
2024-09-19 14:19:46 +00:00
|
|
|
from pickle import dump, load
|
|
|
|
from re import search
|
|
|
|
-from requests import get, exceptions
|
|
|
|
from shutil import copy
|
|
|
|
-from subprocess import call, check_output, DEVNULL, getoutput, run
|
|
|
|
+from subprocess import call, DEVNULL, getoutput, run
|
|
|
|
from time import sleep
|
|
|
|
from warnings import filterwarnings
|
2024-06-05 15:53:02 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
@@ -105,49 +104,7 @@ def app_version():
|
|
|
|
except Exception as e: print(repr(e))
|
2024-06-05 15:53:02 +00:00
|
|
|
|
|
|
|
def check_for_update():
|
|
|
|
- # returns True if a new release is available from the GitHub repo
|
|
|
|
-
|
|
|
|
- # Specify the repository and package name
|
|
|
|
- # IT IS IMPORTANT TO THAT IF THE REPOSITORY STRUCTURE IS CHANGED, THE FOLLOWING FUNCTION NEEDS TO BE UPDATED ACCORDINGLY
|
|
|
|
- # Fetch the latest release information from GitHub API
|
2024-09-19 14:19:46 +00:00
|
|
|
- latest_release_url = GITHUB.replace("github.com", "api.github.com/repos") + "/releases/latest"
|
2024-06-05 15:53:02 +00:00
|
|
|
- try:
|
2024-09-19 14:19:46 +00:00
|
|
|
- response = get(latest_release_url)
|
|
|
|
- if response.status_code == 200: latest_release = response.json()
|
2024-06-05 15:53:02 +00:00
|
|
|
- else:
|
|
|
|
- message = response.json().get("message")
|
|
|
|
- print("Error fetching recent release!")
|
|
|
|
- if message is not None and message.startswith("API rate limit exceeded"):
|
|
|
|
- print("GitHub Rate limit exceeded. Please try again later within 1 hour or use different network/VPN.")
|
2024-09-19 14:19:46 +00:00
|
|
|
- else: print("Unexpected status code:", response.status_code)
|
2024-06-05 15:53:02 +00:00
|
|
|
- return False
|
2024-09-19 14:19:46 +00:00
|
|
|
- except (exceptions.ConnectionError, exceptions.Timeout,
|
|
|
|
- exceptions.RequestException, exceptions.HTTPError):
|
2024-06-05 15:53:02 +00:00
|
|
|
- print("Error Connecting to server!")
|
|
|
|
- return False
|
|
|
|
-
|
|
|
|
- latest_version = latest_release.get("tag_name")
|
|
|
|
-
|
|
|
|
- if latest_version is not None:
|
|
|
|
- # Get the current version of auto-cpufreq
|
|
|
|
- # Extract version number from the output string
|
|
|
|
- output = check_output(['auto-cpufreq', '--version']).decode('utf-8')
|
2024-09-19 14:19:46 +00:00
|
|
|
- try: version_line = next((search(r'\d+\.\d+\.\d+', line).group() for line in output.split('\n') if line.startswith('auto-cpufreq version')), None)
|
2024-06-05 15:53:02 +00:00
|
|
|
- except AttributeError:
|
|
|
|
- print("Error Retrieving Current Version!")
|
|
|
|
- exit(1)
|
|
|
|
- installed_version = "v" + version_line
|
|
|
|
- #Check whether the same is installed or not
|
|
|
|
- # Compare the latest version with the installed version and perform update if necessary
|
|
|
|
- if latest_version == installed_version:
|
|
|
|
- print("auto-cpufreq is up to date")
|
|
|
|
- return False
|
|
|
|
- else:
|
|
|
|
- print(f"Updates are available,\nCurrent version: {installed_version}\nLatest version: {latest_version}")
|
|
|
|
- print("Note that your previous custom settings might be erased with the following update")
|
|
|
|
- return True
|
2024-09-19 14:19:46 +00:00
|
|
|
- # Handle the case where "tag_name" key doesn't exist
|
|
|
|
- else: print("Malformed Released data!\nReinstall manually or Open an issue on GitHub for help!")
|
2024-06-05 15:53:02 +00:00
|
|
|
+ pass
|
|
|
|
|
|
|
|
def new_update(custom_dir):
|
|
|
|
os.chdir(custom_dir)
|
2024-09-19 14:19:46 +00:00
|
|
|
diff --git c/poetry.lock i/poetry.lock
|
|
|
|
index 0e6da84..b4936fe 100644
|
|
|
|
--- c/poetry.lock
|
|
|
|
+++ i/poetry.lock
|
|
|
|
@@ -1306,4 +1306,4 @@ test = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-it
|
2024-06-05 15:53:02 +00:00
|
|
|
[metadata]
|
|
|
|
lock-version = "2.0"
|
|
|
|
python-versions = "^3.8"
|
2024-09-19 14:19:46 +00:00
|
|
|
-content-hash = "cad3783d04e35b66b241352e76631d0a83c8df3d286b113979ba34a65847f06c"
|
|
|
|
+content-hash = "b21af52156d2d624602fe6941cf001abd7f8cf5b70b22ebfd7b7ad0dece1e39f"
|
|
|
|
diff --git c/pyproject.toml i/pyproject.toml
|
|
|
|
index 562a94b..cc44d8d 100644
|
|
|
|
--- c/pyproject.toml
|
|
|
|
+++ i/pyproject.toml
|
2024-06-05 15:53:02 +00:00
|
|
|
@@ -25,7 +25,6 @@ python = "^3.8"
|
2024-09-19 14:19:46 +00:00
|
|
|
psutil = "^6.0.0"
|
2024-06-05 15:53:02 +00:00
|
|
|
click = "^8.1.0"
|
|
|
|
distro = "^1.8.0"
|
2024-09-19 14:19:46 +00:00
|
|
|
-requests = "^2.32.3"
|
2024-06-05 15:53:02 +00:00
|
|
|
PyGObject = "^3.46.0"
|
|
|
|
pyinotify = {git = "https://github.com/shadeyg56/pyinotify-3.12"}
|
|
|
|
|