PHP 8.2.30
Preview: function_cpuinfo_check.py Size: 1011 B
//usr/lib/python3.6/site-packages/tuned/profiles/functions/function_cpuinfo_check.py

import re
import tuned.logs
from . import base

log = tuned.logs.get()

class cpuinfo_check(base.Function):
	"""
	Checks regexes against /proc/cpuinfo. Accepts arguments in the
	following form: REGEX1, STR1, REGEX2, STR2, ...[, STR_FALLBACK]
	If REGEX1 matches something in /proc/cpuinfo it expands to STR1,
	if REGEX2 matches it expands to STR2. It stops on the first match,
	i.e. if REGEX1 matches, no more regexes are processed. If none
	regex matches it expands to STR_FALLBACK. If there is no fallback,
	it expands to empty string.
	"""
	def __init__(self):
		# unlimited number of arguments, min 2 arguments
		super(cpuinfo_check, self).__init__("cpuinfo_check", 0, 2)

	def execute(self, args):
		if not super(cpuinfo_check, self).execute(args):
			return None
		cpuinfo = self._cmd.read_file("/proc/cpuinfo")
		for i in range(0, len(args), 2):
			if i + 1 < len(args):
				if re.search(args[i], cpuinfo, re.MULTILINE):
					return args[i + 1]
		if len(args) % 2:
			return args[-1]
		else:
			return ""

Directory Contents

Dirs: 1 × Files: 24

Name Size Perms Modified Actions
- drwxr-xr-x 2025-03-13 07:10:07
Edit Download
1.02 KB lrw-r--r-- 2024-02-22 12:23:28
Edit Download
2.10 KB lrw-r--r-- 2024-02-22 12:23:28
Edit Download
767 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
811 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
1.60 KB lrw-r--r-- 2024-02-22 12:23:28
Edit Download
650 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
1011 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
460 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
470 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
624 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
659 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
651 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
637 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
691 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
511 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
487 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
472 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
405 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
554 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
417 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
406 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
595 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download
1.25 KB lrw-r--r-- 2024-02-22 12:23:28
Edit Download
35 B lrw-r--r-- 2024-02-22 12:23:28
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).