[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cpupower f7f4671e69 30/35: now with version checking
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cpupower f7f4671e69 30/35: now with version checking |
Date: |
Thu, 5 May 2022 15:57:47 -0400 (EDT) |
branch: externals/cpupower
commit f7f4671e698a069d581b4b253103826428219767
Author: smeister <smeister@awstruepower.com>
Commit: smeister <smeister@awstruepower.com>
now with version checking
---
cpupower.el | 41 ++++++++++++++++++++++++++++++++++++-----
1 file changed, 36 insertions(+), 5 deletions(-)
diff --git a/cpupower.el b/cpupower.el
index b0ce586dad..ab795c9492 100644
--- a/cpupower.el
+++ b/cpupower.el
@@ -64,7 +64,13 @@ messages buffer"
(defconst cpupower--compatible-versions
'("5.4")
- "Versions of cpupower which cpupower.el can work with.")
+ "Versions of cpupower which cpupower.el can work with.
+
+It is possible that other versions of cpupower have the same
+command line input/output structure. If you are working with a
+version of cpupower not listed here but you suspect is
+compatible, extending this list with you version will all you to
+test.")
(defvar cpupower--cache
nil
@@ -86,13 +92,33 @@ will be called if the value is not cached."
derived-value))))
(defun cpupower--get-version ()
- "Return the cpupower executable version or 'nil on failure"
+ "Return the cpupower executable version or 'nil on failure.
+
+Note: this function skips the safety check because the safety
+check is composed of this function."
(cpupower--with-cache-slot :version
- (let* ((output (cpupower--run "--version"))
+ (let* ((output (cpupower--run "--version" t))
(tokens (split-string output)))
(when (string-equal (car tokens) "cpupower")
(cadr tokens)))))
+(defun cpupower--ensure-executable-valid ()
+ "This function will cause an error if an invalid configuration is detected.
+
+The cpupower command must be executable and must indicate an
+acceptible version."
+ (let ((is-valid (cpupower--with-cache-slot :valid
+ (cl-member (cpupower--get-version)
+ cpupower--compatible-versions
+ :test 'string-equal))))
+ (unless is-valid
+ (let ((version (cpupower--get-version)))
+ (if (null version)
+ (error "Unable to communicate with cpupower (shell command:
\"%s\")"
+ cpupower-cmd)
+ (error "Invalid cpu power version %s. Must be one of: %s"
+ version (mapconcat 'identity cpupower--compatible-versions ",
")))))))
+
(defun cpupower--get-num-cpus ()
"Return the number of CPUs on this system."
(cpupower--with-cache-slot :num-cpus
@@ -111,8 +137,13 @@ cpus but currently it just finds _all_ governors."
"available cpufreq governors:"
"\n")))))
-(defun cpupower--run (subcommand)
- "Execute cpupower with SUBCOMMAND arguments return the output as a string."
+(defun cpupower--run (subcommand &optional skip-safety-check)
+ "Execute cpupower with SUBCOMMAND arguments return the output as a string.
+
+When SKIP-SAFETY-CHECK is non-nil the cpupower configuration will
+be checked before executing any commands."
+ (unless skip-safety-check
+ (cpupower--ensure-executable-valid))
(with-temp-buffer
(let ((command (format "%s %s" cpupower-cmd subcommand)))
(when cpupower-enable-logging
- [elpa] externals/cpupower 9f283594a9 20/35: :shrug:, (continued)
- [elpa] externals/cpupower 9f283594a9 20/35: :shrug:, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower 40952ede70 32/35: using keyword recommended by the manual, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower a18d913837 29/35: logging control, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower e9127b20a4 21/35: now working with quelpa without warnings, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower 41cd60e2e5 26/35: keywords?, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower a8da800f6a 18/35: testing?, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower 26d745d610 35/35: Merge branch 'review-feedback-changes' into 'main', ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower a1c0d4e1d1 34/35: Update cpupower.el, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower 0b3d8f2d89 23/35: you need that semi-colon to get package info, TIL, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower 56406a83b1 22/35: Merge branch 'testing', ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower f7f4671e69 30/35: now with version checking,
ELPA Syncer <=