[tuned] fixed powertop2tuned compatibility with powertop-2.0

Jan Kaluža jkaluza at fedoraproject.org
Tue Jun 12 10:49:38 UTC 2012


commit effc86626ae1b721d5b03cbb2fe1728ca86cad66
Author: Jan Kaluza <hanzz.k at gmail.com>
Date:   Tue Jun 12 12:46:06 2012 +0200

    fixed powertop2tuned compatibility with powertop-2.0

 tuned-powertop2.patch |   63 +++++++++++++++++++++++++++++++++++++++++++++++++
 tuned.spec            |    8 ++++-
 2 files changed, 69 insertions(+), 2 deletions(-)
---
diff --git a/tuned-powertop2.patch b/tuned-powertop2.patch
new file mode 100644
index 0000000..7d3daf4
--- /dev/null
+++ b/tuned-powertop2.patch
@@ -0,0 +1,63 @@
+diff --git a/experiments/powertop2tuned.py b/experiments/powertop2tuned.py
+index 02a5b23..70c6f0b 100755
+--- a/experiments/powertop2tuned.py
++++ b/experiments/powertop2tuned.py
+@@ -74,6 +74,8 @@ class PowertopHTMLParser(HTMLParser):
+ 
+ 	def handle_starttag(self, tag, attrs):
+ 		self.lastStartTag = tag
++		if self.lastStartTag == "div" and dict(attrs)["id"]  == "tuning":
++			self.inProperTable = True
+ 		if self.inProperTable and tag == "td":
+ 			self.tdCounter += 1
+ 
+@@ -92,8 +94,6 @@ class PowertopHTMLParser(HTMLParser):
+ 
+ 	def handle_data(self, data):
+ 		prefix = self.prefix
+-		if self.lastStartTag == "h2" and data == "Software settings in need of tuning":
+-			self.inProperTable = True
+ 		if self.inProperTable and self.tdCounter == 1:
+ 			self.lastDesc = data
+ 			if self.lastDesc.lower().find("autosuspend") != -1 and (self.lastDesc.lower().find("keyboard") != -1 or self.lastDesc.lower().find("mouse") != -1):
+@@ -103,10 +103,10 @@ class PowertopHTMLParser(HTMLParser):
+ 			self.tdCounter = 0
+ 			if not self.inScript:
+ 				self.data += "\t# " + self.lastDesc + "\n"
+-				self.data += "\t" + prefix + data
++				self.data += "\t" + prefix + data.strip()
+ 				self.inScript = True
+ 			else:
+-				self.data += data
++				self.data += data.strip()
+ 
+ class PowertopProfile:
+ 	BAD_PRIVS = 100
+@@ -132,16 +132,18 @@ class PowertopProfile:
+ 		return True
+ 
+ 	def generateHTML(self):
+-		f = tempfile.NamedTemporaryFile()
+-		name = unicode(f.name)
+-		f.close()
+-		
+-		ret = os.system('powertop --html="%s"' % (name))
+-		if ret != 0:
+-			os.unlink(name)
+-			return ret
++		proc = Popen(["powertop", "--html=/tmp/powertop"], stdout=PIPE)
++		output = proc.communicate()[0]
++		if proc.returncode != 0:
++				return ret
++
++		prefix = "PowerTOP outputing using base filename "
++		if output.find(prefix) == -1:
++				return -1
+ 
+-		return name;
++		name = output[output.find(prefix)+len(prefix):-1]
++		#print "Parsed filename=", [name]
++		return name
+ 
+ 	def parseHTML(self, enable_tunings):
+ 		f = open(self.name)
diff --git a/tuned.spec b/tuned.spec
index 04d860b..8be03c0 100644
--- a/tuned.spec
+++ b/tuned.spec
@@ -1,7 +1,7 @@
 Summary: A dynamic adaptive system tuning daemon
 Name: tuned
 Version: 2.0.1
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: GPLv2
 # The source for this package was pulled from upstream git.  Use the
 # following commands to get the corresponding tarball:
@@ -10,6 +10,7 @@ License: GPLv2
 #  git checkout v%%{version}
 #  make archive
 Source: tuned-%{version}.tar.bz2
+Patch0: tuned-powertop2.patch
 URL: https://fedorahosted.org/tuned/
 BuildArch: noarch
 BuildRequires: python, systemd-units
@@ -45,7 +46,7 @@ It can be also used to fine tune your system for specific scenarios.
 
 %prep
 %setup -q
-
+%patch0 -p1 -b .powertop2
 
 %build
 
@@ -134,6 +135,9 @@ fi
 %{_prefix}/lib/tuned/spindown-disk
 
 %changelog
+* Tue Jun 12 2012 Jan Kaluza <jkaluza at redhat.com> - 2.0.1-2
+- fixed powertop2tuned compatibility with powertop-2.0
+
 * Tue Apr 03 2012 Jaroslav Škarvada <jskarvad at redhat.com> - 2.0.1-1
 - new version
 


More information about the scm-commits mailing list